Skip to content

Commit 7cd2b2c

Browse files
authored
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.
1 parent 2601493 commit 7cd2b2c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,13 @@ IF(LIBTINS_BUILD_TESTS)
303303
ENABLE_TESTING()
304304
ADD_SUBDIRECTORY(tests)
305305
ELSE()
306-
MESSAGE(STATUS "googletest git submodule is absent. Run `git submodule init && git submodule update` to get it")
306+
FIND_PACKAGE(GTest QUIET)
307+
IF(${GTest_FOUND})
308+
ENABLE_TESTING()
309+
ADD_SUBDIRECTORY(tests)
310+
ELSE()
311+
MESSAGE(STATUS "googletest git submodule is absent. Run `git submodule init && git submodule update` to get it")
312+
ENDIF()
307313
ENDIF()
308314
ENDIF()
309315

0 commit comments

Comments
 (0)