From cb02d5c7338d90d9116910719f71d792b82409ed Mon Sep 17 00:00:00 2001 From: Martchus Date: Thu, 19 Oct 2017 16:20:49 +0200 Subject: [PATCH] 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. --- cmake/modules/TestTarget.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmake/modules/TestTarget.cmake b/cmake/modules/TestTarget.cmake index 3374974..3887dfd 100644 --- a/cmake/modules/TestTarget.cmake +++ b/cmake/modules/TestTarget.cmake @@ -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}) 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) set(TESTS_EXCLUSION EXCLUDE_FROM_ALL) else() @@ -64,6 +64,13 @@ if(CPP_UNIT_LIB OR META_NO_CPP_UNIT) endif() 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) if(NOT META_PROJECT_TYPE OR "${META_PROJECT_TYPE}" STREQUAL "library") # when testing a library, the test application always needs to link against it