Move creation of check target to BasicConfig.cmake

* So other tests like tidy check can be added
* Even if there are no tests after all, the
  check target shoudn't cause any problems
This commit is contained in:
Martchus 2017-04-04 20:13:13 +02:00
parent 0a4fc2d326
commit b74327d961
2 changed files with 16 additions and 16 deletions

View File

@ -170,6 +170,22 @@ if(NOT EXISTS "${CLANG_FORMAT_RULES}")
set(CLANG_FORMAT_RULES "${CPP_UTILITIES_CONFIG_DIRS}/codingstyle.clang-format")
endif()
# add autotools-style check target
if(NOT TARGET check)
set(CMAKE_CTEST_COMMAND ${CMAKE_CTEST_COMMAND} -V)
add_custom_target(check
COMMAND ${CMAKE_CTEST_COMMAND}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
# enable testing
enable_testing()
get_directory_property(HAS_PARENT PARENT_DIRECTORY)
if(HAS_PARENT)
message(STATUS "For the check target to work, it is required to call enable_testing() on the source directory root.")
endif()
# add target for tidying with clang-format
if(EXISTS "${CLANG_FORMAT_RULES}")
find_program(CLANG_FORMAT_BIN clang-format)

View File

@ -22,22 +22,6 @@ if(CPP_UNIT_LIB)
set(META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS ${META_PRIVATE_COMPILE_DEFINITIONS} ${META_ADDITIONAL_PRIVATE_SHARED_COMPILE_DEFINITIONS})
endif()
# add autotools-style check target and enable testing
if(NOT TARGET check)
set(CMAKE_CTEST_COMMAND ctest -V)
add_custom_target(check
COMMAND ${CMAKE_CTEST_COMMAND}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
# enable testing
enable_testing()
get_directory_property(HAS_PARENT PARENT_DIRECTORY)
if(HAS_PARENT)
message(STATUS "For the check target to work, it is required to call enable_testing() on the source directory root.")
endif()
# add target for test executable, but exclude it from the "all target" when EXCLUDE_TESTS_FROM_ALL is set
if(EXCLUDE_TESTS_FROM_ALL)
set(TESTS_EXCLUSION EXCLUDE_FROM_ALL)