Add target for building all tests

This allows to build all tests at once without
adding them to "all" target. In contrast to the
check target, the tests are not executed.
This commit is contained in:
Martchus 2017-10-19 16:20:49 +02:00
parent ba620c5e0a
commit cb02d5c733
1 changed files with 8 additions and 1 deletions

View File

@ -56,7 +56,7 @@ if(CPP_UNIT_LIB OR META_NO_CPP_UNIT)
set(META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS ${META_PRIVATE_COMPILE_DEFINITIONS} ${META_ADDITIONAL_PRIVATE_SHARED_COMPILE_DEFINITIONS}) set(META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS ${META_PRIVATE_COMPILE_DEFINITIONS} ${META_ADDITIONAL_PRIVATE_SHARED_COMPILE_DEFINITIONS})
endif() endif()
# add target for test executable, but exclude it from the "all target" when EXCLUDE_TESTS_FROM_ALL is set # add target for test executable, but exclude it from the "all" target when EXCLUDE_TESTS_FROM_ALL is set
if(EXCLUDE_TESTS_FROM_ALL) if(EXCLUDE_TESTS_FROM_ALL)
set(TESTS_EXCLUSION EXCLUDE_FROM_ALL) set(TESTS_EXCLUSION EXCLUDE_FROM_ALL)
else() else()
@ -64,6 +64,13 @@ if(CPP_UNIT_LIB OR META_NO_CPP_UNIT)
endif() endif()
add_executable(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests ${TESTS_EXCLUSION} ${TEST_HEADER_FILES} ${TEST_SRC_FILES}) add_executable(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests ${TESTS_EXCLUSION} ${TEST_HEADER_FILES} ${TEST_SRC_FILES})
# add top-level target to build all test targets conveniently, also when excluded from "all" target
if(NOT TARGET tests)
add_custom_target(tests DEPENDS ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests)
else()
add_dependencies(tests ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_tests)
endif()
# handle testing a library (which is default project type) # handle testing a library (which is default project type)
if(NOT META_PROJECT_TYPE OR "${META_PROJECT_TYPE}" STREQUAL "library") if(NOT META_PROJECT_TYPE OR "${META_PROJECT_TYPE}" STREQUAL "library")
# when testing a library, the test application always needs to link against it # when testing a library, the test application always needs to link against it