Skip to content

Commit 65ccecb

Browse files
committed
Fetch GTest if GTest package not found
1 parent dd41c98 commit 65ccecb

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ endif()
7474
# Tests
7575
option(BUILD_SLICK_SOCKET_TESTING "Build tests" ON)
7676
if(BUILD_SLICK_SOCKET_TESTING)
77-
find_package(GTest CONFIG REQUIRED)
7877
enable_testing()
7978
add_subdirectory(tests)
8079
endif()

tests/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Tests CMakeLists.txt
22

3+
find_package(GTest CONFIG REQUIRED)
4+
5+
if(NOT GTest_FOUND)
6+
include(FetchContent)
7+
FetchContent_Declare(
8+
googletest
9+
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
10+
)
11+
# For Windows: Prevent overriding the parent project's compiler/linker settings
12+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
13+
FetchContent_MakeAvailable(googletest)
14+
endif()
15+
316
# Include Google Test
417
include(GoogleTest)
518

0 commit comments

Comments
 (0)