From 69b9bfec51fdf9c885bb1a5485980fc9744fa185 Mon Sep 17 00:00:00 2001 From: Peter LaValle Date: Sun, 31 May 2015 13:14:16 +0100 Subject: [PATCH] skips tests on systems without git --- cmake-modules/AddGTest.cmake | 64 ++++++++++++++++++++---------------- test/CMakeLists.txt | 2 ++ 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/cmake-modules/AddGTest.cmake b/cmake-modules/AddGTest.cmake index 5257148c9..8dd77415d 100644 --- a/cmake-modules/AddGTest.cmake +++ b/cmake-modules/AddGTest.cmake @@ -30,35 +30,43 @@ endif() set(GTEST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/gtest") -ExternalProject_Add(gtest - GIT_REPOSITORY https://chromium.googlesource.com/external/googletest - TIMEOUT 10 - PREFIX "${GTEST_PREFIX}" - CMAKE_ARGS "${GTEST_CMAKE_ARGS}" - LOG_DOWNLOAD ON - LOG_CONFIGURE ON - LOG_BUILD ON - # Disable install - INSTALL_COMMAND "" -) +# try to find git - if found, setup gtest +find_package(Git) +if(NOT GIT_FOUND) + set(AddGTest_FOUND false CACHE BOOL "Was gtest setup correctly?") +else(NOT GIT_FOUND) + set(AddGTest_FOUND true CACHE BOOL "Was gtest setup correctly?") + + ExternalProject_Add(gtest + GIT_REPOSITORY https://chromium.googlesource.com/external/googletest + TIMEOUT 10 + PREFIX "${GTEST_PREFIX}" + CMAKE_ARGS "${GTEST_CMAKE_ARGS}" + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON + # Disable install + INSTALL_COMMAND "" + ) -set(LIB_PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}") -set(LIB_SUFFIX "${CMAKE_STATIC_LIBRARY_SUFFIX}") -set(GTEST_LOCATION "${GTEST_PREFIX}/src/gtest-build") -set(GTEST_DEBUG_LIBRARIES - "${GTEST_LOCATION}/${DEBUG_LIB_DIR}/${LIB_PREFIX}gtest${LIB_SUFFIX}" - "${CMAKE_THREAD_LIBS_INIT}") -SET(GTEST_RELEASE_LIBRARIES - "${GTEST_LOCATION}/${RELEASE_LIB_DIR}/${LIB_PREFIX}gtest${LIB_SUFFIX}" - "${CMAKE_THREAD_LIBS_INIT}") + set(LIB_PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}") + set(LIB_SUFFIX "${CMAKE_STATIC_LIBRARY_SUFFIX}") + set(GTEST_LOCATION "${GTEST_PREFIX}/src/gtest-build") + set(GTEST_DEBUG_LIBRARIES + "${GTEST_LOCATION}/${DEBUG_LIB_DIR}/${LIB_PREFIX}gtest${LIB_SUFFIX}" + "${CMAKE_THREAD_LIBS_INIT}") + SET(GTEST_RELEASE_LIBRARIES + "${GTEST_LOCATION}/${RELEASE_LIB_DIR}/${LIB_PREFIX}gtest${LIB_SUFFIX}" + "${CMAKE_THREAD_LIBS_INIT}") -if(MSVC_VERSION EQUAL 1700) - add_definitions(-D_VARIADIC_MAX=10) -endif() + if(MSVC_VERSION EQUAL 1700) + add_definitions(-D_VARIADIC_MAX=10) + endif() -ExternalProject_Get_Property(gtest source_dir) -include_directories(${source_dir}/include) -include_directories(${source_dir}/gtest/include) + ExternalProject_Get_Property(gtest source_dir) + include_directories(${source_dir}/include) + include_directories(${source_dir}/gtest/include) -ExternalProject_Get_Property(gtest binary_dir) -link_directories(${binary_dir}) + ExternalProject_Get_Property(gtest binary_dir) + link_directories(${binary_dir}) +endif(NOT GIT_FOUND) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 287f51698..967dfd313 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -46,6 +46,7 @@ SET( TEST_SRCS SOURCE_GROUP( tests FILES ${TEST_SRCS} ) +if(AddGTest_FOUND) add_executable( unit unit/CCompilerTest.c unit/Main.cpp @@ -60,5 +61,6 @@ target_link_libraries( unit assimp debug ${GTEST_DEBUG_LIBRARIES} optimized ${GTEST_RELEASE_LIBRARIES} ) +endif(AddGTest_FOUND) add_subdirectory(headercheck)