Commit ea14915c authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[cmake] rename label function

parent f7498874
......@@ -6,36 +6,36 @@
# enable the testing suite on the CMake side.
enable_testing()
# Introduce a target that triggers the building of all tests
# introduce a target that triggers the building of all tests
add_custom_target(build_tests)
# processes labels passed to frackit_add_test
function(frackit_declare_test_label)
# register new label(s)
function(frackit_register_test_labels)
include(CMakeParseArguments)
set(OPTIONS)
set(SINGLEARGS)
set(MULTIARGS LABELS)
cmake_parse_arguments(arg "${OPTIONS}" "${SINGLEARGS}" "${MULTIARGS}" ${ARGN})
if( (DEFINED arg_UNPARSED_ARGUMENTS) AND NOT ( arg_UNPARSED_ARGUMENTS STREQUAL "" ) )
message(FATAL_ERROR "Unhandled extra arguments given to frackit_declare_test_label(): "
"<${arg_UNPARSED_ARGUMENTS}>")
cmake_parse_arguments(ARG "" "" "LABELS" ${ARGN})
if( (DEFINED ARG_UNPARSED_ARGUMENTS) AND NOT ( ARG_UNPARSED_ARGUMENTS STREQUAL "" ) )
message(WARNING "Unparsed arguments in frackit_register_test_labels(): "
"<${ARG_UNPARSED_ARGUMENTS}>")
endif()
foreach(label IN LISTS arg_LABELS)
# Make sure the label is not empty, and does not contain any funny
# characters, in particular regex characters
if(NOT (label MATCHES "[-_0-9a-zA-Z]+"))
message(FATAL_ERROR "Refusing to add label \"${label}\" since it is "
"empty or contains funny characters (characters other than "
"alphanumeric ones and \"-\" or \"_\"; the intent of this restriction "
"is to make construction of the argument to \"ctest -L\" easier")
foreach(LABEL IN LISTS ARG_LABELS)
if (LABEL STREQUAL "")
message(FATAL_ERROR "Cannot register empty labels")
endif()
set(target "build_${label}_tests")
if(NOT TARGET "${target}")
add_custom_target("${target}")
set(TARGET "build_${LABEL}_tests")
if(NOT TARGET "${TARGET}")
add_custom_target("${TARGET}")
endif()
endforeach()
endfunction(frackit_register_test_labels)
function(frackit_declare_test_label)
if(NOT DEFINED FRACKIT_TEST_LABEL_DEPR_WARNING)
message(WARNING "This function is deprecated. Use frackit_register_test_labels instead!")
set(FRACKIT_TEST_LABEL_DEPR_WARNING)
endif()
frackit_register_test_labels(${ARGV})
endfunction(frackit_declare_test_label)
# function to add a test
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment