Unittests: Always use GTest from Externals (recommended way from GTest FAQ).

This commit is contained in:
Pierre Bourdon
2014-03-03 03:38:46 +01:00
parent 2d6810be9f
commit 9ea845310d
38 changed files with 31418 additions and 22 deletions

View File

@ -468,21 +468,6 @@ 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)
#
@ -738,6 +723,16 @@ file(WRITE ${PROJECT_BINARY_DIR}/Source/Core/Common/scmrev.h
)
include_directories("${PROJECT_BINARY_DIR}/Source/Core/Common")
########################################
# Unit testing.
#
include_directories(Externals/gtest/include)
add_subdirectory(Externals/gtest)
enable_testing()
add_custom_target(unittests)
add_custom_command(TARGET unittests POST_BUILD COMMAND ${CMAKE_CTEST_COMMAND})
########################################
# Start compiling our code