Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #124 from delroth/master
Do not hard fail when running 'make unittests' without GTest.
  • Loading branch information
Parlane committed Mar 3, 2014
2 parents 6176424 + 2d71571 commit 2d6810b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
24 changes: 15 additions & 9 deletions CMakeLists.txt
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
#
Expand Down
3 changes: 0 additions & 3 deletions Source/UnitTests/CMakeLists.txt
@@ -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})
Expand Down

0 comments on commit 2d6810b

Please sign in to comment.