Add -W options to control deprecated warning messages.
Add 'deprecated' warning options type, to allow setting CMAKE_WARN_DEPRECATED via the -W '-Wdeprecated' and '-Wno-deprecated' options. Add tests for new options and updated documentation.
This commit is contained in:
parent
07388f83b6
commit
da688bcb3b
|
@ -84,3 +84,15 @@
|
|||
|
||||
Enable warnings that are meant for the author of the CMakeLists.txt
|
||||
files.
|
||||
|
||||
``-Wdeprecated``
|
||||
Enable deprecated functionality warnings.
|
||||
|
||||
Enable warnings for usage of deprecated functionality, that are meant
|
||||
for the author of the CMakeLists.txt files.
|
||||
|
||||
``-Wno-deprecated``
|
||||
Suppress deprecated functionality warnings.
|
||||
|
||||
Suppress warnings for usage of deprecated functionality, that are meant
|
||||
for the author of the CMakeLists.txt files.
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
cmake-W-options
|
||||
---------------
|
||||
|
||||
* The :variable:`CMAKE_WARN_DEPRECATED` variable can now be set using the
|
||||
``-Wdeprecated`` and ``-Wno-deprecated`` :manual:`cmake(1)` options.
|
|
@ -1,7 +1,10 @@
|
|||
CMAKE_WARN_DEPRECATED
|
||||
---------------------
|
||||
|
||||
Whether to issue deprecation warnings for macros and functions.
|
||||
Whether to issue warnings for deprecated functionality.
|
||||
|
||||
If ``TRUE``, this can be used by macros and functions to issue deprecation
|
||||
warnings. This variable is ``FALSE`` by default.
|
||||
If ``TRUE``, use of deprecated functionality will issue warnings.
|
||||
If this variable is not set, CMake behaves as if it were set to ``FALSE``.
|
||||
|
||||
When running :manual:`cmake(1)`, this option can be enabled with the
|
||||
``-Wdeprecated`` option, or disabled with the ``-Wno-deprecated`` option.
|
||||
|
|
|
@ -1263,6 +1263,26 @@ int cmake::Configure()
|
|||
{
|
||||
DiagLevel diagLevel;
|
||||
|
||||
if (this->DiagLevels.count("deprecated") == 1)
|
||||
{
|
||||
|
||||
diagLevel = this->DiagLevels["deprecated"];
|
||||
if (diagLevel == DIAG_IGNORE)
|
||||
{
|
||||
this->AddCacheEntry("CMAKE_WARN_DEPRECATED", "FALSE",
|
||||
"Whether to issue warnings for deprecated "
|
||||
"functionality.",
|
||||
cmState::INTERNAL);
|
||||
}
|
||||
else if (diagLevel == DIAG_WARN)
|
||||
{
|
||||
this->AddCacheEntry("CMAKE_WARN_DEPRECATED", "TRUE",
|
||||
"Whether to issue warnings for deprecated "
|
||||
"functionality.",
|
||||
cmState::INTERNAL);
|
||||
}
|
||||
}
|
||||
|
||||
if (this->DiagLevels.count("dev") == 1)
|
||||
{
|
||||
|
||||
|
|
|
@ -444,7 +444,9 @@ private:
|
|||
{"-T <toolset-name>", "Specify toolset name if supported by generator."}, \
|
||||
{"-A <platform-name>", "Specify platform name if supported by generator."}, \
|
||||
{"-Wno-dev", "Suppress developer warnings."},\
|
||||
{"-Wdev", "Enable developer warnings."}
|
||||
{"-Wdev", "Enable developer warnings."},\
|
||||
{"-Wdeprecated", "Enable deprecation warnings."},\
|
||||
{"-Wno-deprecated", "Suppress deprecation warnings."}
|
||||
|
||||
#define FOR_EACH_C_FEATURE(F) \
|
||||
F(c_function_prototypes) \
|
||||
|
|
|
@ -133,6 +133,14 @@ set(RunCMake_TEST_OPTIONS -Wdev)
|
|||
run_cmake(Wdev)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS -Wdeprecated)
|
||||
run_cmake(Wdeprecated)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS -Wno-deprecated)
|
||||
run_cmake(Wno-deprecated)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
# Dev warnings should be on by default
|
||||
run_cmake(Wdev)
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
^CMake Deprecation Warning at Wdeprecated.cmake:1 \(message\):
|
||||
Some deprecated warning
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
|
@ -0,0 +1 @@
|
|||
message(DEPRECATION "Some deprecated warning")
|
|
@ -0,0 +1 @@
|
|||
message(DEPRECATION "Some deprecated warning")
|
Loading…
Reference in New Issue