Merge pull request #124 from delroth/master

Do not hard fail when running 'make unittests' without GTest.
This commit is contained in:
Matthew Parlane 2014-03-03 15:15:13 +13:00
commit 2d6810be9f
2 changed files with 15 additions and 12 deletions

View File

@ -331,15 +331,6 @@ if(NOT OPENMP_FOUND)
message("OpenMP parallelization disabled")
endif()
include(FindGTest OPTIONAL)
if(GTEST_FOUND)
enable_testing()
include_directories(${GTEST_INCLUDE_DIRS})
message("GTest found, unit tests can be compiled and ran with 'make unittests'")
else()
message("GTest NOT found, disabling unit tests")
endif(GTEST_FOUND)
if(NOT ANDROID)
include(FindOpenGL)
@ -477,6 +468,21 @@ if(NOT ANDROID)
endif()
endif()
########################################
# Unit testing: only enabled if GTest is present.
#
add_custom_target(unittests)
include(FindGTest OPTIONAL)
if(GTEST_FOUND)
enable_testing()
include_directories(${GTEST_INCLUDE_DIRS})
add_custom_command(TARGET unittests POST_BUILD COMMAND ${CMAKE_CTEST_COMMAND})
message("GTest found, unit tests can be compiled and ran with 'make unittests'")
else()
add_custom_command(TARGET unittests POST_BUILD COMMAND echo Running unittests requires GTest.)
message("GTest NOT found, disabling unit tests")
endif(GTEST_FOUND)
########################################
# Setup include directories (and make sure they are preferred over the Externals)
#

View File

@ -1,6 +1,3 @@
add_custom_target(unittests)
add_custom_command(TARGET unittests POST_BUILD COMMAND ${CMAKE_CTEST_COMMAND})
macro(add_dolphin_test target srcs libs)
add_executable(Tests/${target} EXCLUDE_FROM_ALL ${srcs})
target_link_libraries(Tests/${target} ${libs} ${GTEST_BOTH_LIBRARIES})