skips tests on systems without git

pull/577/head
Peter LaValle 2015-05-31 13:14:16 +01:00
parent 99e45b995b
commit 69b9bfec51
2 changed files with 38 additions and 28 deletions

View File

@ -30,35 +30,43 @@ endif()
set(GTEST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/gtest") set(GTEST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/gtest")
ExternalProject_Add(gtest # try to find git - if found, setup gtest
GIT_REPOSITORY https://chromium.googlesource.com/external/googletest find_package(Git)
TIMEOUT 10 if(NOT GIT_FOUND)
PREFIX "${GTEST_PREFIX}" set(AddGTest_FOUND false CACHE BOOL "Was gtest setup correctly?")
CMAKE_ARGS "${GTEST_CMAKE_ARGS}" else(NOT GIT_FOUND)
LOG_DOWNLOAD ON set(AddGTest_FOUND true CACHE BOOL "Was gtest setup correctly?")
LOG_CONFIGURE ON
LOG_BUILD ON
# Disable install
INSTALL_COMMAND ""
)
set(LIB_PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}") ExternalProject_Add(gtest
set(LIB_SUFFIX "${CMAKE_STATIC_LIBRARY_SUFFIX}") GIT_REPOSITORY https://chromium.googlesource.com/external/googletest
set(GTEST_LOCATION "${GTEST_PREFIX}/src/gtest-build") TIMEOUT 10
set(GTEST_DEBUG_LIBRARIES PREFIX "${GTEST_PREFIX}"
"${GTEST_LOCATION}/${DEBUG_LIB_DIR}/${LIB_PREFIX}gtest${LIB_SUFFIX}" CMAKE_ARGS "${GTEST_CMAKE_ARGS}"
"${CMAKE_THREAD_LIBS_INIT}") LOG_DOWNLOAD ON
SET(GTEST_RELEASE_LIBRARIES LOG_CONFIGURE ON
"${GTEST_LOCATION}/${RELEASE_LIB_DIR}/${LIB_PREFIX}gtest${LIB_SUFFIX}" LOG_BUILD ON
"${CMAKE_THREAD_LIBS_INIT}") # Disable install
INSTALL_COMMAND ""
)
if(MSVC_VERSION EQUAL 1700) set(LIB_PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}")
add_definitions(-D_VARIADIC_MAX=10) set(LIB_SUFFIX "${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif() 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}")
ExternalProject_Get_Property(gtest source_dir) if(MSVC_VERSION EQUAL 1700)
include_directories(${source_dir}/include) add_definitions(-D_VARIADIC_MAX=10)
include_directories(${source_dir}/gtest/include) endif()
ExternalProject_Get_Property(gtest binary_dir) ExternalProject_Get_Property(gtest source_dir)
link_directories(${binary_dir}) include_directories(${source_dir}/include)
include_directories(${source_dir}/gtest/include)
ExternalProject_Get_Property(gtest binary_dir)
link_directories(${binary_dir})
endif(NOT GIT_FOUND)

View File

@ -46,6 +46,7 @@ SET( TEST_SRCS
SOURCE_GROUP( tests FILES ${TEST_SRCS} ) SOURCE_GROUP( tests FILES ${TEST_SRCS} )
if(AddGTest_FOUND)
add_executable( unit add_executable( unit
unit/CCompilerTest.c unit/CCompilerTest.c
unit/Main.cpp unit/Main.cpp
@ -60,5 +61,6 @@ target_link_libraries( unit assimp
debug ${GTEST_DEBUG_LIBRARIES} debug ${GTEST_DEBUG_LIBRARIES}
optimized ${GTEST_RELEASE_LIBRARIES} optimized ${GTEST_RELEASE_LIBRARIES}
) )
endif(AddGTest_FOUND)
add_subdirectory(headercheck) add_subdirectory(headercheck)