blob: b06e3266ed335e4073abdc169fed183caf4744ee [file] [log] [blame]
Brian Silverman8fce7482020-01-05 13:18:21 -08001# Download and unpack googletest at configure time
2configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)
3execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
4 RESULT_VARIABLE result
5 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
6if(result)
7 message(FATAL_ERROR "CMake step for googletest failed: ${result}")
8endif()
9execute_process(COMMAND ${CMAKE_COMMAND} --build .
10 RESULT_VARIABLE result
11 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
12if(result)
13 message(FATAL_ERROR "Build step for googletest failed: ${result}")
14endif()
15
16# Prevent overriding the parent project's compiler/linker
17# settings on Windows
18set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
19
20# Add googletest directly to our build. This defines
21# the gtest and gtest_main targets.
22add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
23 ${CMAKE_CURRENT_BINARY_DIR}/googletest-build
24 EXCLUDE_FROM_ALL)
Austin Schuh812d0d12021-11-04 20:16:48 -070025
26target_compile_features(gtest PUBLIC cxx_std_17)
27target_compile_features(gtest_main PUBLIC cxx_std_17)