Explicitly enable deprecated warnings by default.
Explicitly enable deprecated warnings by default, via the cmake::GetSuppressDeprecatedWarnings method, which signals suppression is turned off unless the CMake variables are set as required. Add tests and update the documentation for the new functionality.
This commit is contained in:
parent
e8974b62d7
commit
aac633d5e5
|
@ -6,3 +6,7 @@ cmake-W-options
|
|||
|
||||
* The ``-Wdev`` and ``-Wno-dev`` :manual:`cmake(1)` options now also enable
|
||||
and suppress the deprecated warnings output by default.
|
||||
|
||||
* Warnings about deprecated functionality are now enabled by default.
|
||||
They may be suppressed with ``-Wno-deprecated`` or by setting the
|
||||
:variable:`CMAKE_WARN_DEPRECATED` variable to false.
|
||||
|
|
|
@ -3,8 +3,8 @@ CMAKE_WARN_DEPRECATED
|
|||
|
||||
Whether to issue warnings for deprecated functionality.
|
||||
|
||||
If ``TRUE``, use of deprecated functionality will issue warnings.
|
||||
If this variable is not set, CMake behaves as if it were set to ``FALSE``.
|
||||
If not ``FALSE``, use of deprecated functionality will issue warnings.
|
||||
If this variable is not set, CMake behaves as if it were set to ``TRUE``.
|
||||
|
||||
When running :manual:`cmake(1)`, this option can be enabled with the
|
||||
``-Wdeprecated`` option, or disabled with the ``-Wno-deprecated`` option.
|
||||
|
|
|
@ -66,13 +66,17 @@ bool cmMessageCommand
|
|||
fatal = true;
|
||||
type = cmake::DEPRECATION_ERROR;
|
||||
}
|
||||
else if (this->Makefile->IsOn("CMAKE_WARN_DEPRECATED"))
|
||||
else
|
||||
{
|
||||
type = cmake::DEPRECATION_WARNING;
|
||||
if (this->Makefile->GetCMakeInstance()->GetSuppressDeprecatedWarnings(
|
||||
this->Makefile))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
type = cmake::DEPRECATION_WARNING;
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
|
|
@ -2581,10 +2581,7 @@ bool cmake::IsMessageTypeVisible(cmake::MessageType t)
|
|||
}
|
||||
else if (t == cmake::DEPRECATION_WARNING)
|
||||
{
|
||||
// if CMAKE_WARN_DEPRECATED is on, show the message, otherwise suppress it
|
||||
const char* warnDeprecated = this->State->GetInitializedCacheValue(
|
||||
"CMAKE_WARN_DEPRECATED");
|
||||
if(cmSystemTools::IsOff(warnDeprecated))
|
||||
if (this->GetSuppressDeprecatedWarnings())
|
||||
{
|
||||
isVisible = false;
|
||||
}
|
||||
|
@ -2916,3 +2913,22 @@ bool cmake::GetSuppressDevWarnings(cmMakefile const* mf)
|
|||
return cmSystemTools::IsOn(cacheEntryValue);
|
||||
}
|
||||
}
|
||||
|
||||
bool cmake::GetSuppressDeprecatedWarnings(cmMakefile const* mf)
|
||||
{
|
||||
/*
|
||||
* The suppression CMake variable may be set in the CMake configuration file
|
||||
* itself, so we have to check what its set to in the makefile if we can.
|
||||
*/
|
||||
if (mf)
|
||||
{
|
||||
return (mf->IsSet("CMAKE_WARN_DEPRECATED") &&
|
||||
!mf->IsOn("CMAKE_WARN_DEPRECATED"));
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* cacheEntryValue = this->State->GetCacheEntryValue(
|
||||
"CMAKE_WARN_DEPRECATED");
|
||||
return cacheEntryValue && cmSystemTools::IsOff(cacheEntryValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -316,6 +316,13 @@ class cmake
|
|||
*/
|
||||
bool GetSuppressDevWarnings(cmMakefile const* mf = NULL);
|
||||
|
||||
/*
|
||||
* Get the state of the suppression of deprecated warnings.
|
||||
* Returns false, by default, if deprecated warnings should be shown, true
|
||||
* otherwise.
|
||||
*/
|
||||
bool GetSuppressDeprecatedWarnings(cmMakefile const* mf = NULL);
|
||||
|
||||
/** Display a message to the user. */
|
||||
void IssueMessage(cmake::MessageType t, std::string const& text,
|
||||
cmListFileBacktrace const& backtrace = cmListFileBacktrace(),
|
||||
|
|
|
@ -157,6 +157,9 @@ unset(RunCMake_TEST_OPTIONS)
|
|||
# Dev warnings should be on by default
|
||||
run_cmake(Wdev)
|
||||
|
||||
# Deprecated warnings should be on by default
|
||||
run_cmake(Wdeprecated)
|
||||
|
||||
# Conflicting -W options should honor the last value
|
||||
set(RunCMake_TEST_OPTIONS -Wno-dev -Wdev)
|
||||
run_cmake(Wdev)
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
^CMake Warning \(dev\) at defaultmessage.cmake:4 \(message\):
|
||||
^CMake Deprecation Warning at defaultmessage.cmake:2 \(message\):
|
||||
This is a deprecation warning
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
||||
|
||||
CMake Warning \(dev\) at defaultmessage.cmake:4 \(message\):
|
||||
This is a author warning
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
set(CMAKE_WARN_DEPRECATED OFF)
|
||||
|
||||
message(DEPRECATION "This is not issued")
|
||||
|
||||
set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS ON)
|
||||
|
|
Loading…
Reference in New Issue