Skip to content

Commit eb5d20d

Browse files
committed
Updated GoogleTest, auto-install
Signed-off-by: Vlad Gheorghiu <[email protected]>
1 parent 116c770 commit eb5d20d

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

unit_tests/CMakeLists.txt

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
include(GoogleTest)
22
set(TARGET_NAME "unit_tests")
3-
4-
# Link Google Test dynamically if using MSVC
3+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
4+
5+
# GoogleTest
6+
include(FetchContent)
7+
message(STATUS "Fetching GoogleTest...")
8+
FetchContent_Declare(
9+
googletest
10+
GIT_REPOSITORY https://github.com/google/googletest.git
11+
GIT_TAG main
12+
GIT_SHALLOW TRUE
13+
GIT_PROGRESS TRUE)
14+
# For Windows: Prevent overriding the parent project's compiler/linker settings,
15+
# and add /bigobj option
516
if(MSVC)
17+
add_compile_options(/bigobj)
618
set(gtest_force_shared_crt
719
ON
820
CACHE BOOL "" FORCE)
921
endif()
10-
11-
add_subdirectory(libs/googletest-release-1.12.1 EXCLUDE_FROM_ALL)
22+
FetchContent_MakeAvailable(googletest)
1223

1324
aux_source_directory(tests TEST_FILES)
1425
aux_source_directory(tests/parser TEST_FILES)
@@ -17,9 +28,7 @@ aux_source_directory(tests/utils TEST_FILES)
1728
add_executable(${TARGET_NAME} EXCLUDE_FROM_ALL tests/main.cpp)
1829
add_dependencies(unit_tests ${TARGET_NAME})
1930

20-
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13")
21-
cmake_policy(SET CMP0076 NEW)
22-
endif()
31+
cmake_policy(SET CMP0076 NEW)
2332

2433
# Build all tests in ${TEST_FILES}
2534
foreach(file ${TEST_FILES})

0 commit comments

Comments
 (0)