File tree 1 file changed +16
-7
lines changed 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change 1
1
include (GoogleTest)
2
2
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
5
16
if (MSVC )
17
+ add_compile_options (/bigobj)
6
18
set (gtest_force_shared_crt
7
19
ON
8
20
CACHE BOOL "" FORCE)
9
21
endif ()
10
-
11
- add_subdirectory (libs/googletest-release-1.12.1 EXCLUDE_FROM_ALL )
22
+ FetchContent_MakeAvailable(googletest)
12
23
13
24
aux_source_directory (tests TEST_FILES)
14
25
aux_source_directory (tests/parser TEST_FILES)
@@ -17,9 +28,7 @@ aux_source_directory(tests/utils TEST_FILES)
17
28
add_executable (${TARGET_NAME} EXCLUDE_FROM_ALL tests/main.cpp)
18
29
add_dependencies (unit_tests ${TARGET_NAME} )
19
30
20
- if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13" )
21
- cmake_policy (SET CMP0076 NEW)
22
- endif ()
31
+ cmake_policy (SET CMP0076 NEW)
23
32
24
33
# Build all tests in ${TEST_FILES}
25
34
foreach (file ${TEST_FILES} )
You can’t perform that action at this time.
0 commit comments