Merge branch 'master' into HDZero_SD_Support
[inav.git] / src / test / cmake / gtest.cmake
blob2f8bf52da4e6e3f4bd4d0ec86f37e29fd921d5c6
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}" .
4   RESULT_VARIABLE result
5   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
6 if(result)
7   message(FATAL_ERROR "CMake step for googletest failed: ${result}")
8 endif()
9 execute_process(COMMAND ${CMAKE_COMMAND} --build .
10   RESULT_VARIABLE result
11   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
12 if(result)
13   message(FATAL_ERROR "Build step for googletest failed: ${result}")
14 endif()
16 # Prevent overriding the parent project's compiler/linker
17 # settings on Windows
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
24                  EXCLUDE_FROM_ALL)
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")
31 endif()