diff --git a/CMakeLists.txt b/CMakeLists.txt index 96655a3af7..35efb93ec6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) # diff --git a/Source/UnitTests/CMakeLists.txt b/Source/UnitTests/CMakeLists.txt index 9b7338532c..95cedf5c30 100644 --- a/Source/UnitTests/CMakeLists.txt +++ b/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})