Skip to content

Commit

Permalink
Allow tribits_deprecated[_command]() to take multiple message arguments
Browse files Browse the repository at this point in the history
This was missed in TriBITSPub#538.
  • Loading branch information
KyleFromKitware committed Nov 3, 2022
1 parent f0430db commit a4d32e6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion test/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ tribits_add_advanced_test( TestingFunctionMacro_UnitTests
-D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR}
-P "${CMAKE_CURRENT_SOURCE_DIR}/TestingFunctionMacro_UnitTests.cmake"
PASS_REGULAR_EXPRESSION_ALL
"Final UnitTests Result: num_run = 717"
"Final UnitTests Result: num_run = 719"
"Final UnitTests Result: PASSED"
)

Expand Down
24 changes: 23 additions & 1 deletion test/core/TestingFunctionMacro_UnitTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4597,6 +4597,16 @@ function(unittest_tribits_deprecated)
"DEPRECATION;This is a deprecation message with TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE unset"
)

message("Testing tribits_deprecated() with multiple message arguments")
unset(TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE)
global_set(MESSAGE_WRAPPER_INPUT)
tribits_deprecated("This is a deprecation message with"
" multiple message arguments")
unittest_compare_const(
MESSAGE_WRAPPER_INPUT
"DEPRECATION;This is a deprecation message with; multiple message arguments"
)

message("Testing tribits_deprecated() with TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE set to empty string")
set(TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE "")
global_set(MESSAGE_WRAPPER_INPUT)
Expand Down Expand Up @@ -4691,6 +4701,18 @@ function(unittest_tribits_deprecated_command)
"DEPRECATION;TriBITS command 'tribits_another_deprecated_command' is deprecated.\n\nUse tribits_some_new_command instead."
)

message("Testing tribits_deprecated_command() with multiple MESSAGE arguments")
unset(TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE)
global_set(MESSAGE_WRAPPER_INPUT)
tribits_deprecated_command(tribits_yet_another_deprecated_command
MESSAGE "This is a deprecation message with"
" multiple arguments."
)
unittest_compare_const(
MESSAGE_WRAPPER_INPUT
"DEPRECATION;TriBITS command 'tribits_yet_another_deprecated_command' is deprecated.\n\nThis is a deprecation message with; multiple arguments."
)

endfunction()


Expand Down Expand Up @@ -4791,4 +4813,4 @@ message("*** Determine final result of all unit tests")
message("***\n")

# Pass in the number of expected tests that must pass!
unittest_final_result(717)
unittest_final_result(719)
12 changes: 7 additions & 5 deletions tribits/core/utils/TribitsDeprecatedHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ set(TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE_ALL_VALID_VALUES
#
# tribits_deprecated(<message>)
#
function(tribits_deprecated message)
function(tribits_deprecated)
cmake_parse_arguments(PARSE_ARGV 0 FWD "" "" "")

if ("${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE}" STREQUAL "")
set(TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE DEPRECATION)
endif()

if ("${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE}" IN_LIST TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE_VALUES_THAT_CALL_MESSAGE)
message_wrapper("${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE}" "${message}")
message_wrapper("${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE}" ${FWD_UNPARSED_ARGUMENTS})
elseif (NOT "${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE}" IN_LIST TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE_ALL_VALID_VALUES)
message_wrapper(FATAL_ERROR "Invalid value for TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE: '${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE}'")
endif()
Expand All @@ -96,11 +98,11 @@ endfunction()
#
function(tribits_deprecated_command name)
# Parse input arguments
set(argOneValArgKeywords MESSAGE)
set(argMultiValArgKeywords MESSAGE)
cmake_parse_arguments(PARSE_ARGV 1 PREFIX
"" # options
"${argOneValArgKeywords}" # one_value_keywords
"" # multi_value_keywords
"" # one_value_keywords
"${argMultiValArgKeywords}" # multi_value_keywords
)
tribits_check_for_unparsed_arguments(PREFIX)

Expand Down

0 comments on commit a4d32e6

Please sign in to comment.