From 3ea215e0ebf0599ed132c9fac186a8f756ae4dff Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Wed, 4 May 2022 10:30:19 -0700 Subject: [PATCH] Fall back to system GTest if available Using a submodule to download and build GTest is a great approach for most circumstances, but some may prefer to use the system-provided GTest if it is available. This change adds a fallback to using the system's GTest if the submodule is absent. --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6eb8c8a6..d3aacdb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -303,7 +303,13 @@ IF(LIBTINS_BUILD_TESTS) ENABLE_TESTING() ADD_SUBDIRECTORY(tests) ELSE() - MESSAGE(STATUS "googletest git submodule is absent. Run `git submodule init && git submodule update` to get it") + FIND_PACKAGE(GTest QUIET) + IF(${GTest_FOUND}) + ENABLE_TESTING() + ADD_SUBDIRECTORY(tests) + ELSE() + MESSAGE(STATUS "googletest git submodule is absent. Run `git submodule init && git submodule update` to get it") + ENDIF() ENDIF() ENDIF()