1 # Download and unpack googletest at configure time
2 configure_file(cmake/CMakeListsGTest.txt.in googletest-download/CMakeLists.txt)
3 execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
5 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
7 message(FATAL_ERROR "CMake step for googletest failed: ${result}")
9 execute_process(COMMAND ${CMAKE_COMMAND} --build .
10 RESULT_VARIABLE result
11 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
13 message(FATAL_ERROR "Build step for googletest failed: ${result}")
16 # Prevent overriding the parent project's compiler/linker
18 set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
20 # Add googletest directly to our build. This defines
21 # the gtest and gtest_main targets.
22 add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
23 ${CMAKE_CURRENT_BINARY_DIR}/googletest-build
26 # The gtest/gtest_main targets carry header search path
27 # dependencies automatically when using CMake 2.8.11 or
28 # later. Otherwise we have to add them here ourselves.
29 if (CMAKE_VERSION VERSION_LESS 2.8.11)
30 include_directories("${gtest_SOURCE_DIR}/include")