-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Design and implement strategy for deprecating TriBITS code #429
Comments
I think having a way to enable/disable deprecation warning or error messages is sufficient. I would suggest adding one function for this purpose: tribits_deprecated(msg):
if CMAKE_ERROR_DEPRECATED
message(FATAL_ERROR, msg)
else if CMAKE_WARN_DEPRECATED
message(WARN, msg)
else
return |
@e10harvey, here is the idea demonstrated with the CMake script function(tribits_deprecated msg)
if (NOT TRIBITS_HIDE_DEPRECATED_TRIBITS_WARNING_MESSAGES)
message(DEPRECATION "${msg}")
endif()
endfunction()
# Example deprecated TriBITS function
if (NOT TRIBITS_HIDE_TRIBITS_DEPRECATED_CODE)
function(tribits_deprecated_function)
tribits_deprecated("TriBITS function '${CMAKE_CURRENT_FUNCTION}()' is deprecated!")
endfunction()
endif() # TRIBITS_HIDE_TRIBITS_DEPRECATED_CODE
# User code
function(project_function)
tribits_deprecated_function()
message(DEPRECATION "Project function '${CMAKE_CURRENT_FUNCTION}()' is deprecated!")
endfunction()
project_function() Here is the output and error return codes you get for different use cases (using CMake 3.17.1): Default (show deprecated warnings but do not trigger fail)
Hide all deprecated warnings in all CMake code (in TriBITS and the project's own CMake code):
Only hide deprecated code in TriBITS but show deprecated code in project:
Elevate deprecated warnings to errors (in TriBITS and project code)
Only show and elevate deprecated warnings to errors in project code:
Validate that project is not using any deprecated TriBITS function for sure:
That latter has the advantage over just printing a deprecated error message in that it validates that the deprecated code is actually gone. Note that another purpose of:
is that it allows you to write a tool like unifdef but for CMake code. |
@KyleFromKitware, would you be willing to look into implementing this for TriBITS? I know we are very underspent on the contract for help with TriBITS and I could use help with stuff like this (beyond just reviews). |
Perhaps it would be best to have a single variable called function(tribits_deprecated function_name)
if("${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE}" STREQUAL "" OR "${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE}" STREQUAL "WARN")
message(DEPRECATION "${function_name} is deprecated")
elseif("${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE}" STREQUAL "ERROR")
message(FATAL_ERROR "${function_name} is deprecated")
elseif(NOT "${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE}" STREQUAL "IGNORE")
message(FATAL_ERROR "Invalid value for TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE: \"${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE}\"")
endif()
endfunction()
# ...
function(tribits_some_deprecated_function)
tribits_deprecated(tribits_some_deprecated_function)
# Do some deprecated stuff...
endfunction() |
@KyleFromKitware, I have found that it is really useful to support both |
@KyleFromKitware, also, when deprecating code, it is often useful to provide an informative error message that tells the developer/user how to fix their code or at least where to look for that documentation (e.g. in the CHANGELOG.md file). |
@KyleFromKitware, with the basic support for the new
|
This issue is needs some more work:
|
The fact that this needs some work was highlighted I went to update TriBITS in Trilinos and it produced over 1,300 deprecation warnings as described in trilinos/Trilinos#11380 (comment). |
* Update the deprecation message to mention the cache var TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE and how to set it to remove deprecation warnings. * Add non-cache var TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE_DEFAULT so that a TriBITS project can provide its own default for cache var TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE. * Add documentation for the cache var TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE in the TriBITS build reference and developers guides. * Fix TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE_ALL_VALID_VALUES to pull in ${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE_VALUES_THAT_CALL_MESSAGE} and ${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE_VALUES_THAT_DONT_CALL_MESSAGE} instead of pulling in ${TRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE_VALUES_THAT_CALL_MESSAGE} twice. (If user would have tried to set -DTRIBITS_HANDLE_TRIBITS_DEPRECATED_CODE=IGNORE, it would have errored out of the configure.) * ???
Will help in future refactorings. I mostly just added this as a precursor to token-replace.py.
I will use this tool to replace deprecated functions/macros.
…riBITSPub/TriBITS#429) A refactoring in TriBITS related to tribits_include_directories() (see TriBITSPub/TriBITS#553) required renaming set_and_inc_dirs() to tribits_set_and_inc_dirs() and deprecating the former. The deprecated TriBITS macro set_and_inc_dirs() now issues a CMake Deprecation warning. This change wsa made with the TriBITS script: TriBITS/refactoring/replace_set_and_inc_dirs_r.sh
…iBITSPub/TriBITS#429) A refactoring in TriBITS related to tribits_include_directories() (see TriBITSPub/TriBITS#553) required renaming set_and_inc_dirs() to tribits_set_and_inc_dirs() and deprecating the former. The deprecated TriBITS macro set_and_inc_dirs() now issues a CMake Deprecation warning. This change wsa made with the TriBITS script: TriBITS/refactoring/replace_set_and_inc_dirs_r.sh
…riBITSPub/TriBITS#429) A refactoring in TriBITS related to tribits_include_directories() (see TriBITSPub/TriBITS#553) required renaming set_and_inc_dirs() to tribits_set_and_inc_dirs() and deprecating the former. The deprecated TriBITS macro set_and_inc_dirs() now issues a CMake Deprecation warning. This change wsa made with the TriBITS script: TriBITS/refactoring/replace_set_and_inc_dirs_r.sh
…riBITSPub/TriBITS#429) A refactoring in TriBITS related to tribits_include_directories() (see TriBITSPub/TriBITS#553) required renaming set_and_inc_dirs() to tribits_set_and_inc_dirs() and deprecating the former. The deprecated TriBITS macro set_and_inc_dirs() now issues a CMake Deprecation warning. This change wsa made with the TriBITS script: TriBITS/refactoring/replace_set_and_inc_dirs_r.sh
…riBITSPub/TriBITS#429) A refactoring in TriBITS related to tribits_include_directories() (see TriBITSPub/TriBITS#553) required renaming set_and_inc_dirs() to tribits_set_and_inc_dirs() and deprecating the former. The deprecated TriBITS macro set_and_inc_dirs() now issues a CMake Deprecation warning. This change wsa made with the TriBITS script: TriBITS/refactoring/replace_set_and_inc_dirs_r.sh
…iBITS#429) This replaces the usage of raw include_directories() with the wrapper KOKKOSKERNELS_INCLUDE_DIRECTORIES(). The deprecated TriBITS macro include_directories() now issues a CMake Deprecation warning. The fix is to use tribits_include_directories() in a TriBITS build instead. This is the same patch made in Trilinos PR trilinos/Trilinos#11380.
…TriBITS#429) The deprecated TriBITS macro include_directories() now issues a CMake Deprecation warning. The fix is to use tribits_include_directories() instead and use raw CMake include_directories() where that is the behavior you want. This matches a similar commit from PR trilinos/Trilinos#11380 I was not able to use git format-patch and git am to apply the patch from the Trilinos branch due to no current clean snapshot so I had to run the tool TriBITS/refactoring/replace_include_directories_r.sh from scratch.
…riBITSPub/TriBITS#429) A refactoring in TriBITS related to tribits_include_directories() (see TriBITSPub/TriBITS#553) required renaming set_and_inc_dirs() to tribits_set_and_inc_dirs() and deprecating the former. The deprecated TriBITS macro set_and_inc_dirs() now issues a CMake Deprecation warning. This matches a similar commit from PR trilinos/Trilinos#11380 I was not able to use git format-patch and git am to apply the patch from the Trilinos branch due to no current clean snapshot so I had to run the tool TriBITS/refactoring/replace_set_and_inc_dirs_r.sh from scratch.
…#429) The last snapshot of TriBITS 'master' into cmake/tribits/ wiped out a bunch of local changes to these files. Therefore, this commit put all of those back again.
…TriBITS#429) The deprecated TriBITS macro include_directories() now issues a CMake Deprecation warning. The fix is to use tribits_include_directories() instead and use raw CMake include_directories() where that is the behavior you want.
…SPub/TriBITS#429) Let's not generate any deprecated warnings from the deprecated TriBITS include_directories() function. Let's just not define it.
…ated SEACAS: Remove the usage of deprecated TriBITS macros and update TriBITS snapshot (TriBITSPub/TriBITS#429)
…s:develop' (2c1c93a). * trilinos-develop: (77 commits) Nox: Silence some warnings Stratimikos: Silence warnings Belos: Silence warnings Automatic snapshot commit from tribits at c2f52215 Zoltan2: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Xpetra: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Tpetra: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Thyra: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Teuchos: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Tempus: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Stratimikos: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) SEACAS: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Rythmos: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) RTOp: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) ROL: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Pike: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Percept: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) MueLu: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) ML: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) MiniTensor: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) ...
…s:develop' (2c1c93a). * trilinos-develop: (78 commits) Revert "TriBITS Snapshot 2022-12-12 working toward TriBITSPub/TriBITS#63" Nox: Silence some warnings Stratimikos: Silence warnings Belos: Silence warnings Automatic snapshot commit from tribits at c2f52215 Zoltan2: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Xpetra: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Tpetra: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Thyra: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Teuchos: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Tempus: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Stratimikos: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) SEACAS: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Rythmos: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) RTOp: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) ROL: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Pike: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Percept: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) MueLu: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) ML: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) ...
…s:develop' (2c1c93a). * trilinos-develop: (78 commits) Revert "TriBITS Snapshot 2022-12-12 working toward TriBITSPub/TriBITS#63" Nox: Silence some warnings Stratimikos: Silence warnings Belos: Silence warnings Automatic snapshot commit from tribits at c2f52215 Zoltan2: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Xpetra: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Tpetra: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Thyra: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Teuchos: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Tempus: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Stratimikos: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) SEACAS: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Rythmos: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) RTOp: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) ROL: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Pike: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) Percept: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) MueLu: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) ML: Replace set_and_inc_dirs() with tribits_set_and_inc_dirs() (TriBITSPub/TriBITS#429) ...
KokkosKernels: Use KOKKOSKERNELS_INCLUDE_DIRECTORIES() (TriBITSPub/TriBITS#429)
Using fr'....{var}...' makes for shorter and more readable string creation. Now that TriBITS requires Python 3 (or at least it is only tested with Python 3), it is good to be able to start using these newer language features. I tested this manaully locally and it seems to work correctly.
…/TriBITS#429) The deprecated TriBITS macro include_directories() now issues a CMake Deprecation warning. The fix is to use tribits_include_directories() instead and use raw CMake include_directories() where that is the behavior you want.
…BITS#429) The deprecated TriBITS macro include_directories() now issues a CMake Deprecation warning. The fix is to use tribits_include_directories() instead and use raw CMake include_directories() where that is the behavior you want.
…/TriBITS#429) The deprecated TriBITS macro include_directories() now issues a CMake Deprecation warning. The fix is to use tribits_include_directories() instead and use raw CMake include_directories() where that is the behavior you want.
…riBITSPub/TriBITS#429) A refactoring in TriBITS related to tribits_include_directories() (see TriBITSPub/TriBITS#553) required renaming set_and_inc_dirs() to tribits_set_and_inc_dirs() and deprecating the former. The deprecated TriBITS macro set_and_inc_dirs() now issues a CMake Deprecation warning. This change wsa made with the TriBITS script: TriBITS/refactoring/replace_set_and_inc_dirs_r.sh
…/TriBITS#429) The deprecated TriBITS macro include_directories() now issues a CMake Deprecation warning. The fix is to use tribits_include_directories() instead and use raw CMake include_directories() where that is the behavior you want.
…iBITS#429) The deprecated TriBITS macro include_directories() now issues a CMake Deprecation warning. The fix is to use tribits_include_directories() instead and use raw CMake include_directories() where that is the behavior you want.
…BITSPub/TriBITS#429) A refactoring in TriBITS related to tribits_include_directories() (see TriBITSPub/TriBITS#553) required renaming set_and_inc_dirs() to tribits_set_and_inc_dirs() and deprecating the former. The deprecated TriBITS macro set_and_inc_dirs() now issues a CMake Deprecation warning. This change wsa made with the TriBITS script: TriBITS/refactoring/replace_set_and_inc_dirs_r.sh
This has been implemented for a long time. No sense keeping it open anymore. |
Parent Epic: #411
Description
As noted in trilinos/Trilinos#9894 (comment), we need to consider how to handle deprecated functions and macros in TriBITS. I don't think it is desirable to just use raw
message(DEPRECATION <msg>)
since that might generate thousands of lines of output if the deprecated function/macro is used in a loop. But it would be nice to have a system where the user can decide to show deprecated code or not. Also, it would be good to allow the separation of deprecation warnings for TriBITS from deprecations for other CMake modules and packages and even the user's own project functions.A setup similar to what is described in Regulated Backward Compatibility and Deprecated Code would be good but apply it to TriBITS CMake code itself with respect to projects that use TriBITS.
What would likely be good would be to define and use a function like:
which would be called in any deprecated TriBITS function or macro. By default, this would call:
but when
TRIBITS_HIDE_DEPRECATED_TRIBITS_WARNING_MESSAGES=TRUE
, then no deprecated warnings would be printed at all.The text was updated successfully, but these errors were encountered: