From 7cd2b2c39648c7bdb904d18d55ec44180cec7227 Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Sat, 14 May 2022 11:07:39 -0700 Subject: [PATCH] Fall back to system GTest if available (#473) 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 6eb8c8a..d3aacdb 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()