Commit e1d083a1855e7d74f7ecb374e555168e06e64d20
Committed by
Mads Andreasen
1 parent
c25cadd9
Removed download of gtest if tests are not built
Showing
1 changed file
with
32 additions
and
29 deletions
CMakeLists.txt
| @@ -17,36 +17,39 @@ endif () | @@ -17,36 +17,39 @@ endif () | ||
| 17 | #========================================= gtest INSTALL =========================================# | 17 | #========================================= gtest INSTALL =========================================# |
| 18 | #=================================================================================================# | 18 | #=================================================================================================# |
| 19 | 19 | ||
| 20 | -# Download and unpack googletest at configure time | ||
| 21 | -configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) | ||
| 22 | -execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . | ||
| 23 | - RESULT_VARIABLE result | ||
| 24 | - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) | ||
| 25 | -if(result) | ||
| 26 | - message(FATAL_ERROR "CMake step for googletest failed: ${result}") | ||
| 27 | -endif() | ||
| 28 | -execute_process(COMMAND ${CMAKE_COMMAND} --build . | ||
| 29 | - RESULT_VARIABLE result | ||
| 30 | - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) | ||
| 31 | -if(result) | ||
| 32 | - message(FATAL_ERROR "Build step for googletest failed: ${result}") | ||
| 33 | -endif() | 20 | +if (BUILD_TESTS) |
| 21 | + # Download and unpack googletest at configure time | ||
| 22 | + configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) | ||
| 23 | + execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . | ||
| 24 | + RESULT_VARIABLE result | ||
| 25 | + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) | ||
| 26 | + if(result) | ||
| 27 | + message(FATAL_ERROR "CMake step for googletest failed: ${result}") | ||
| 28 | + endif() | ||
| 29 | + execute_process(COMMAND ${CMAKE_COMMAND} --build . | ||
| 30 | + RESULT_VARIABLE result | ||
| 31 | + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) | ||
| 32 | + if(result) | ||
| 33 | + message(FATAL_ERROR "Build step for googletest failed: ${result}") | ||
| 34 | + endif() | ||
| 35 | + | ||
| 36 | + # Prevent overriding the parent project's compiler/linker | ||
| 37 | + # settings on Windows | ||
| 38 | + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
| 39 | + | ||
| 40 | + # Add googletest directly to our build. This defines | ||
| 41 | + # the gtest and gtest_main targets. | ||
| 42 | + add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src | ||
| 43 | + ${CMAKE_BINARY_DIR}/googletest-build | ||
| 44 | + EXCLUDE_FROM_ALL) | ||
| 45 | + | ||
| 46 | + # The gtest/gtest_main targets carry header search path | ||
| 47 | + # dependencies automatically when using CMake 2.8.11 or | ||
| 48 | + # later. Otherwise we have to add them here ourselves. | ||
| 49 | + if (CMAKE_VERSION VERSION_LESS 2.8.11) | ||
| 50 | + include_directories("${gtest_SOURCE_DIR}/include") | ||
| 51 | + endif() | ||
| 34 | 52 | ||
| 35 | -# Prevent overriding the parent project's compiler/linker | ||
| 36 | -# settings on Windows | ||
| 37 | -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
| 38 | - | ||
| 39 | -# Add googletest directly to our build. This defines | ||
| 40 | -# the gtest and gtest_main targets. | ||
| 41 | -add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src | ||
| 42 | - ${CMAKE_BINARY_DIR}/googletest-build | ||
| 43 | - EXCLUDE_FROM_ALL) | ||
| 44 | - | ||
| 45 | -# The gtest/gtest_main targets carry header search path | ||
| 46 | -# dependencies automatically when using CMake 2.8.11 or | ||
| 47 | -# later. Otherwise we have to add them here ourselves. | ||
| 48 | -if (CMAKE_VERSION VERSION_LESS 2.8.11) | ||
| 49 | - include_directories("${gtest_SOURCE_DIR}/include") | ||
| 50 | endif() | 53 | endif() |
| 51 | 54 | ||
| 52 | #=================================================================================================# | 55 | #=================================================================================================# |