diff options
| author | Felix Morgner <fmorgner@hsr.ch> | 2020-02-21 14:31:53 +0100 |
|---|---|---|
| committer | Felix Morgner <fmorgner@hsr.ch> | 2020-02-21 14:31:53 +0100 |
| commit | 714c18a369e8d974821de0c86598163672533c70 (patch) | |
| tree | c8375f3591edf3610ff50920ab68495845dbdc3e | |
| parent | 300bf973264dd9ecd876582685bfa7471ba83554 (diff) | |
| download | newtype-714c18a369e8d974821de0c86598163672533c70.tar.xz newtype-714c18a369e8d974821de0c86598163672533c70.zip | |
build: convert test execution to command
| -rw-r--r-- | CMakeLists.txt | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c6a645c..37a3460 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,10 @@ project("newtype" include("CTest") include("CMakePackageConfigHelpers") +# Project Options + +option(RUN_TESTS_AFTER_BUILD "Automatically run the unit tests after building" ON) + # 'newtype' library add_library("${PROJECT_NAME}" INTERFACE) @@ -78,12 +82,14 @@ if(BUILD_TESTING) discover_tests(TARGET "${PROJECT_NAME}_tests") - add_custom_target("run_all_tests" - COMMAND ${CMAKE_CTEST_COMMAND} "--output-on-failure" - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - DEPENDS "newtype_tests" - COMMENT "Running unit tests" + if(RUN_TESTS_AFTER_BUILD) + add_custom_command(TARGET "${PROJECT_NAME}_tests" + POST_BUILD + COMMAND "${CMAKE_CTEST_COMMAND}" "--output-on-failure" + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" + COMMENT "Running unit tests" ) + endif() endif() # 'newtype' docs |
