Skip to content

Commit 802ff9f

Browse files
committed
Reuse gtest on the system
Try to use gtest on the system if found. Avoid using recent CMake features.
1 parent 4e6ded1 commit 802ff9f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

test/CMakeLists.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ set(BUILD_GMOCK OFF)
77
set(INSTALL_GTEST OFF)
88
set(gtest_force_shared_crt ON)
99

10-
FetchContent_Declare(
11-
gtest
12-
URL https://github.com/google/googletest/archive/main.tar.gz
13-
)
14-
FetchContent_MakeAvailable(gtest)
10+
find_package(GTest)
11+
if (NOT GTest_FOUND)
12+
FetchContent_Declare(
13+
gtest
14+
URL https://github.com/google/googletest/archive/main.tar.gz
15+
)
16+
FetchContent_MakeAvailable(gtest)
17+
endif()
1518

1619
add_executable(httplib-test test.cc)
1720
target_compile_options(httplib-test PRIVATE "$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

0 commit comments

Comments
 (0)