summaryrefslogtreecommitdiffstats
path: root/cmake/modules/buildtools/FindGtest.cmake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /cmake/modules/buildtools/FindGtest.cmake
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--cmake/modules/buildtools/FindGtest.cmake71
1 files changed, 71 insertions, 0 deletions
diff --git a/cmake/modules/buildtools/FindGtest.cmake b/cmake/modules/buildtools/FindGtest.cmake
new file mode 100644
index 0000000..eba6adc
--- /dev/null
+++ b/cmake/modules/buildtools/FindGtest.cmake
@@ -0,0 +1,71 @@
+#.rst:
+# FindGtest
+# --------
+# Finds the gtest library
+#
+# This will define the following variables::
+#
+# GTEST_FOUND - system has gtest
+# GTEST_INCLUDE_DIRS - the gtest include directories
+# GTEST_LIBRARIES - the gtest libraries
+#
+# and the following imported targets:
+#
+# Gtest::Gtest - The gtest library
+
+if(ENABLE_INTERNAL_GTEST)
+ include(cmake/scripts/common/ModuleHelpers.cmake)
+
+ set(MODULE_LC gtest)
+
+ SETUP_BUILD_VARS()
+
+ set(GTEST_VERSION ${${MODULE}_VER})
+
+ # Override build type detection and always build as release
+ set(GTEST_BUILD_TYPE Release)
+
+ set(CMAKE_ARGS -DBUILD_GMOCK=OFF
+ -DINSTALL_GTEST=ON
+ -DBUILD_SHARED_LIBS=OFF
+ -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>)
+
+ BUILD_DEP_TARGET()
+else()
+ if(PKG_CONFIG_FOUND)
+ pkg_check_modules(PC_GTEST gtest>=1.10.0 QUIET)
+ set(GTEST_VERSION ${PC_GTEST_VERSION})
+ elseif(WIN32)
+ set(GTEST_VERSION 1.10.0)
+ endif()
+
+ find_path(GTEST_INCLUDE_DIR NAMES gtest/gtest.h
+ PATHS ${PC_GTEST_INCLUDEDIR})
+
+ find_library(GTEST_LIBRARY_RELEASE NAMES gtest
+ PATHS ${PC_GTEST_LIBDIR})
+ find_library(GTEST_LIBRARY_DEBUG NAMES gtestd
+ PATHS ${PC_GTEST_LIBDIR})
+
+ include(SelectLibraryConfigurations)
+ select_library_configurations(GTEST)
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Gtest
+ REQUIRED_VARS GTEST_LIBRARY GTEST_INCLUDE_DIR
+ VERSION_VAR GTEST_VERSION)
+
+if(GTEST_FOUND)
+ set(GTEST_LIBRARIES ${GTEST_LIBRARY})
+ set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIR})
+endif()
+
+if(NOT TARGET Gtest::Gtest)
+ add_library(Gtest::Gtest UNKNOWN IMPORTED)
+ set_target_properties(Gtest::Gtest PROPERTIES
+ IMPORTED_LOCATION "${GTEST_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")
+endif()
+
+mark_as_advanced(GTEST_INCLUDE_DIR GTEST_LIBRARY)