| 1 |
# @HEADER |
| 2 |
# ***************************************************************************** |
| 3 |
# TriBITS: Tribal Build, Integrate, and Test System |
| 4 |
# |
| 5 |
# Copyright 2013-2016 NTESS and the TriBITS contributors. |
| 6 |
# SPDX-License-Identifier: BSD-3-Clause |
| 7 |
# ***************************************************************************** |
| 8 |
# @HEADER |
| 9 |
|
| 10 |
include_guard() |
| 11 |
|
| 12 |
include("${CMAKE_CURRENT_LIST_DIR}/MessageWrapper.cmake") |
| 13 |
include("${CMAKE_CURRENT_LIST_DIR}/TribitsParseArgumentsHelpers.cmake") |
| 14 |
|
| 15 |
|
| 16 |
set(TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE_VALUES_THAT_CALL_MESSAGE |
| 17 |
DEPRECATION AUTHOR_WARNING SEND_ERROR FATAL_ERROR ) |
| 18 |
set(TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE_VALUES_THAT_DONT_CALL_MESSAGE |
| 19 |
IGNORE ) |
| 20 |
set(TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE_ALL_VALID_VALUES |
| 21 |
${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE_VALUES_THAT_CALL_MESSAGE} |
| 22 |
${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE_VALUES_THAT_DONT_CALL_MESSAGE} ) |
| 23 |
|
| 24 |
|
| 25 |
# @FUNCTION: tribits_deprecated() |
| 26 |
# |
| 27 |
# Notify the user that some TriBITS functionality is deprecated. |
| 28 |
# |
| 29 |
# Usage:: |
| 30 |
# |
| 31 |
# tribits_deprecated(<message>) |
| 32 |
# |
| 33 |
# Depending on the value of the cache variable |
| 34 |
# `TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE`_, this can do one of several |
| 35 |
# things: |
| 36 |
# |
| 37 |
# - ``DEPRECATION`` or empty string (or variable not defined): Issue a CMake |
| 38 |
# ``DEPRECATION`` message and continue. |
| 39 |
# - ``AUTHOR_WARNING``: Issue a CMake ``AUTHOR_WARNING`` message and continue. |
| 40 |
# - ``SEND_ERROR``: Issue a CMake ``SEND_ERROR`` message and continue. |
| 41 |
# - ``FATAL_ERROR``: Issue a CMake ``FATAL_ERROR`` message and exit. |
| 42 |
# - ``IGNORE``: Issue no message and continue. |
| 43 |
# |
| 44 |
function(tribits_deprecated) |
| 45 |
cmake_parse_arguments(PARSE_ARGV 0 FWD "" "" "") |
| 46 |
|
| 47 |
if ("${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE}" STREQUAL "") |
| 48 |
set(TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE DEPRECATION) |
| 49 |
endif() |
| 50 |
|
| 51 |
if ("${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE}" IN_LIST TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE_VALUES_THAT_CALL_MESSAGE) |
| 52 |
message_wrapper("${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE}" |
| 53 |
${FWD_UNPARSED_ARGUMENTS} |
| 54 |
"\n\nNOTE: To Make these warnings go away, set -D" |
| 55 |
" TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE=IGNORE (see the build reference guide).") |
| 56 |
elseif (NOT "${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE}" IN_LIST |
| 57 |
TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE_ALL_VALID_VALUES |
| 58 |
) |
| 59 |
message_wrapper(FATAL_ERROR "Invalid value for" |
| 60 |
" TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE=" |
| 61 |
"'${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE}'") |
| 62 |
endif() |
| 63 |
endfunction() |
| 64 |
|
| 65 |
|
| 66 |
# @FUNCTION: tribits_deprecated_command() |
| 67 |
# |
| 68 |
# Notify the user that a TriBITS function or macro is deprecated. This should |
| 69 |
# be the first command called at the top of any deprecated function or macro. |
| 70 |
# |
| 71 |
# Usage:: |
| 72 |
# |
| 73 |
# tribits_deprecated_command(<name> |
| 74 |
# [MESSAGE <message>] |
| 75 |
# ) |
| 76 |
# |
| 77 |
function(tribits_deprecated_command name) |
| 78 |
# Parse input arguments |
| 79 |
set(argMultiValArgKeywords MESSAGE) |
| 80 |
cmake_parse_arguments(PARSE_ARGV 1 PREFIX |
| 81 |
"" # options |
| 82 |
"" # one_value_keywords |
| 83 |
"${argMultiValArgKeywords}" # multi_value_keywords |
| 84 |
) |
| 85 |
tribits_check_for_unparsed_arguments(PREFIX) |
| 86 |
|
| 87 |
set(deprecationMessage "TriBITS command '${name}' is deprecated.") |
| 88 |
if (NOT "${PREFIX_MESSAGE}" STREQUAL "") |
| 89 |
string(APPEND deprecationMessage "\n\n${PREFIX_MESSAGE}") |
| 90 |
endif() |
| 91 |
|
| 92 |
tribits_deprecated("${deprecationMessage}") |
| 93 |
endfunction() |