summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-04-24 11:23:50 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-04-24 11:23:50 -0700
commitac34413a35a15eec744de1e5970e07555b66a410 (patch)
treea0463d810c20ff41690d26398873bd608b967909 /CMakeLists.txt
parent38ba7177c772e2ee55396968833f9427c1a6bffc (diff)
downloadsubsurface-ac34413a35a15eec744de1e5970e07555b66a410.tar.gz
cmake: don't always build tests
Only build the tests when running them. The downside of the way this is implemented is that build errors for the tests actually show up as test errors and are only seen in the test log - but this seemed worth not having every build include the tests. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt8
1 files changed, 5 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 39d09a5b1..e4c5cc4a9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -361,15 +361,17 @@ endif()
# QTest based tests
macro(TEST NAME FILE)
- add_executable(${NAME} tests/${FILE} ${SUBSURFACE_RESOURCES})
+ add_executable(${NAME} EXCLUDE_FROM_ALL tests/${FILE} ${SUBSURFACE_RESOURCES})
target_link_libraries(${NAME} subsurface_corelib ${QT_TEST_LIBRARIES} ${SUBSURFACE_LINK_LIBRARIES})
- add_test(NAME ${NAME} COMMAND ${NAME})
+ add_test(NAME ${NAME}_build COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${NAME})
+ add_test(NAME ${NAME}_run COMMAND ${NAME})
+ set_tests_properties(${NAME}_run PROPERTIES DEPENDS ${NAME}_build)
endmacro()
-enable_testing()
add_definitions(-DSUBSURFACE_SOURCE="${CMAKE_SOURCE_DIR}")
add_definitions(-g)
if(NOT NO_TESTS)
+ enable_testing()
TEST(TestUnitConversion testunitconversion.cpp)
TEST(TestProfile testprofile.cpp)
TEST(TestGpsCoords testgpscoords.cpp)