aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2024-01-30 23:48:33 +0100
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2024-01-30 23:49:22 +0100
commitdecf2bd09207e3af8cffc0b0248a7031b1f3ddc5 (patch)
tree9246346cd1b056dcab7bd58e0d38a46bd850e442
parent52571b0f5aefb99cd55828945ccedc571c20d097 (diff)
downloadjancity-decf2bd09207e3af8cffc0b0248a7031b1f3ddc5.tar.gz
Add FindGeekbit.cmake
-rw-r--r--cmake/FindGeekbit.cmake84
1 files changed, 84 insertions, 0 deletions
diff --git a/cmake/FindGeekbit.cmake b/cmake/FindGeekbit.cmake
new file mode 100644
index 0000000..24754a2
--- /dev/null
+++ b/cmake/FindGeekbit.cmake
@@ -0,0 +1,84 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindGeekbit
+-----------
+
+Find Geekbit (an open source software development kit for the Geekbit
+handheld video game console) libraries and header files.
+
+Imported targets
+^^^^^^^^^^^^^^^^
+
+This module defines the following :prop_tgt:`IMPORTED` targets:
+
+ ``geekbit::geekbit``,
+ The geekbit library, if found.
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``GEEKBIT_FOUND``
+ true if geekbit libraries and header files were found.
+``GEEKBIT_VERSION``
+ geekbit release version
+``GEEKBIT_INCLUDE_DIRS``
+ the directory containing the geekbit headers; note
+ ``GEEKBIT_INCLUDE_DIRS`` is also required
+``GEEKBIT_LIBRARIES``
+ geekbit libraries to be linked; note ``GEEKBIT_LIBRARIES`` is also
+ required
+
+#]=======================================================================]
+
+find_path(GEEKBIT_INCLUDE_DIRS
+ NAMES
+ geekbit/gb.h
+ HINTS
+ ENV GEEKBIT_PATH
+ PATH_SUFFIXES
+ include
+)
+
+find_library(GEEKBIT_LIBRARIES
+ NAMES geekbit
+ HINTS
+ ENV GEEKBIT_PATH
+ PATH_SUFFIXES
+ lib
+)
+
+# Header files are meant to be included as "geekbit/<file>.h". Therefore,
+# the "geekbit" directory must not be referred to by GEEKBIT_INCLUDE_DIRS.
+string(REGEX REPLACE "include/geekbit[/]*$"
+ "include" GEEKBIT_INCLUDE_DIRS ${GEEKBIT_INCLUDE_DIRS})
+
+if(GEEKBIT_INCLUDE_DIRS AND EXISTS "${GEEKBIT_INCLUDE_DIRS}/geekbit/version.h")
+ set(version_regex "^#define[ \t]+GEEKBIT_VERSION_STRING[ \t]+\"([0-9\.]+)\"$")
+ file(STRINGS "${GEEKBIT_INCLUDE_DIRS}/geekbit/version.h" GEEKBIT_VERSION_LINE REGEX ${version_regex})
+ string(REGEX REPLACE ${version_regex} "\\1" GEEKBIT_VERSION "${GEEKBIT_VERSION_LINE}")
+ unset(GEEKBIT_VERSION_LINE)
+ unset(version_regex)
+endif()
+
+include(FindPackageHandleStandardArgs)
+
+find_package_handle_standard_args(Geekbit
+ REQUIRED_VARS
+ GEEKBIT_LIBRARIES GEEKBIT_INCLUDE_DIRS
+ VERSION_VAR
+ GEEKBIT_VERSION
+)
+
+if(GEEKBIT_FOUND)
+ if(NOT TARGET Geekbit::Geekbit)
+ add_library(Geekbit::Geekbit INTERFACE IMPORTED)
+ target_include_directories(Geekbit::Geekbit
+ INTERFACE "${GEEKBIT_INCLUDE_DIRS}")
+ set_target_properties(Geekbit::Geekbit PROPERTIES
+ IMPORTED_LOCATION "${GEEKBIT_LIBRARIES}")
+ endif()
+endif()