Skip to content

Commit 80430a6

Browse files
authored
CMake: look for system gtest (#90)
1 parent d536a4f commit 80430a6

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

test/CMakeLists.txt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,22 @@ SET(CMAKE_BUILD_TYPE DEBUG)
2020
################################################################################
2121
# download and compile GTest
2222
################################################################################
23-
INCLUDE(ExternalProject)
24-
25-
# Download from GitHub
26-
INCLUDE(FetchContent)
27-
FetchContent_Declare(
28-
googletest
29-
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip)
30-
31-
# For Windows: Prevent overriding the parent project's compiler/linker settings
32-
SET(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
33-
FetchContent_MakeAvailable(googletest)
34-
35-
INCLUDE(GoogleTest)
23+
find_package(GTest)
24+
if(NOT GTEST_FOUND)
25+
INCLUDE(ExternalProject)
26+
27+
# Download from GitHub
28+
INCLUDE(FetchContent)
29+
FetchContent_Declare(
30+
googletest
31+
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip)
32+
33+
# For Windows: Prevent overriding the parent project's compiler/linker settings
34+
SET(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
35+
FetchContent_MakeAvailable(googletest)
36+
37+
INCLUDE(GoogleTest)
38+
endif()
3639

3740
################################################################################
3841
# add gtest dependency

0 commit comments

Comments
 (0)