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