cmake: Deduplicate warning message control code
Remove the duplicate code in cmake::Configure to set the cache variables for the warning message suppression. Replace it with calls to the dedicated methods to carry this out.
This commit is contained in:
parent
67211011d9
commit
291275347b
|
@ -1269,17 +1269,11 @@ int cmake::Configure()
|
||||||
diagLevel = this->DiagLevels["deprecated"];
|
diagLevel = this->DiagLevels["deprecated"];
|
||||||
if (diagLevel == DIAG_IGNORE)
|
if (diagLevel == DIAG_IGNORE)
|
||||||
{
|
{
|
||||||
this->AddCacheEntry("CMAKE_WARN_DEPRECATED", "FALSE",
|
this->SetSuppressDeprecatedWarnings(true);
|
||||||
"Whether to issue warnings for deprecated "
|
|
||||||
"functionality.",
|
|
||||||
cmState::INTERNAL);
|
|
||||||
}
|
}
|
||||||
else if (diagLevel == DIAG_WARN)
|
else if (diagLevel == DIAG_WARN)
|
||||||
{
|
{
|
||||||
this->AddCacheEntry("CMAKE_WARN_DEPRECATED", "TRUE",
|
this->SetSuppressDeprecatedWarnings(false);
|
||||||
"Whether to issue warnings for deprecated "
|
|
||||||
"functionality.",
|
|
||||||
cmState::INTERNAL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1299,32 +1293,20 @@ int cmake::Configure()
|
||||||
diagLevel = this->DiagLevels["dev"];
|
diagLevel = this->DiagLevels["dev"];
|
||||||
if (diagLevel == DIAG_IGNORE)
|
if (diagLevel == DIAG_IGNORE)
|
||||||
{
|
{
|
||||||
this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "TRUE",
|
this->SetSuppressDevWarnings(true);
|
||||||
"Suppress Warnings that are meant for"
|
|
||||||
" the author of the CMakeLists.txt files.",
|
|
||||||
cmState::INTERNAL);
|
|
||||||
|
|
||||||
if (setDeprecatedVariables)
|
if (setDeprecatedVariables)
|
||||||
{
|
{
|
||||||
this->AddCacheEntry("CMAKE_WARN_DEPRECATED", "FALSE",
|
this->SetSuppressDeprecatedWarnings(true);
|
||||||
"Whether to issue warnings for deprecated "
|
|
||||||
"functionality.",
|
|
||||||
cmState::INTERNAL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (diagLevel == DIAG_WARN)
|
else if (diagLevel == DIAG_WARN)
|
||||||
{
|
{
|
||||||
this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "FALSE",
|
this->SetSuppressDevWarnings(false);
|
||||||
"Suppress Warnings that are meant for"
|
|
||||||
" the author of the CMakeLists.txt files.",
|
|
||||||
cmState::INTERNAL);
|
|
||||||
|
|
||||||
if (setDeprecatedVariables)
|
if (setDeprecatedVariables)
|
||||||
{
|
{
|
||||||
this->AddCacheEntry("CMAKE_WARN_DEPRECATED", "TRUE",
|
this->SetSuppressDeprecatedWarnings(false);
|
||||||
"Whether to issue warnings for deprecated "
|
|
||||||
"functionality.",
|
|
||||||
cmState::INTERNAL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2881,6 +2863,24 @@ void cmake::RunCheckForUnusedVariables()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cmake::GetSuppressDevWarnings(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->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const char* cacheEntryValue = this->State->GetCacheEntryValue(
|
||||||
|
"CMAKE_SUPPRESS_DEVELOPER_WARNINGS");
|
||||||
|
return cmSystemTools::IsOn(cacheEntryValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void cmake::SetSuppressDevWarnings(bool b)
|
void cmake::SetSuppressDevWarnings(bool b)
|
||||||
{
|
{
|
||||||
std::string value;
|
std::string value;
|
||||||
|
@ -2902,24 +2902,6 @@ void cmake::SetSuppressDevWarnings(bool b)
|
||||||
cmState::INTERNAL);
|
cmState::INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmake::GetSuppressDevWarnings(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->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const char* cacheEntryValue = this->State->GetCacheEntryValue(
|
|
||||||
"CMAKE_SUPPRESS_DEVELOPER_WARNINGS");
|
|
||||||
return cmSystemTools::IsOn(cacheEntryValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool cmake::GetSuppressDeprecatedWarnings(cmMakefile const* mf)
|
bool cmake::GetSuppressDeprecatedWarnings(cmMakefile const* mf)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -308,27 +308,27 @@ class cmake
|
||||||
std::string const& GetCMakeEditCommand() const
|
std::string const& GetCMakeEditCommand() const
|
||||||
{ return this->CMakeEditCommand; }
|
{ return this->CMakeEditCommand; }
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the state of the suppression of developer (author) warnings.
|
|
||||||
*/
|
|
||||||
void SetSuppressDevWarnings(bool v);
|
|
||||||
/*
|
/*
|
||||||
* Get the state of the suppression of developer (author) warnings.
|
* Get the state of the suppression of developer (author) warnings.
|
||||||
* Returns false, by default, if developer warnings should be shown, true
|
* Returns false, by default, if developer warnings should be shown, true
|
||||||
* otherwise.
|
* otherwise.
|
||||||
*/
|
*/
|
||||||
bool GetSuppressDevWarnings(cmMakefile const* mf = NULL);
|
bool GetSuppressDevWarnings(cmMakefile const* mf = NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the state of the suppression of deprecated warnings.
|
* Set the state of the suppression of developer (author) warnings.
|
||||||
*/
|
*/
|
||||||
void SetSuppressDeprecatedWarnings(bool v);
|
void SetSuppressDevWarnings(bool v);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the state of the suppression of deprecated warnings.
|
* Get the state of the suppression of deprecated warnings.
|
||||||
* Returns false, by default, if deprecated warnings should be shown, true
|
* Returns false, by default, if deprecated warnings should be shown, true
|
||||||
* otherwise.
|
* otherwise.
|
||||||
*/
|
*/
|
||||||
bool GetSuppressDeprecatedWarnings(cmMakefile const* mf = NULL);
|
bool GetSuppressDeprecatedWarnings(cmMakefile const* mf = NULL);
|
||||||
|
/*
|
||||||
|
* Set the state of the suppression of deprecated warnings.
|
||||||
|
*/
|
||||||
|
void SetSuppressDeprecatedWarnings(bool v);
|
||||||
|
|
||||||
/** Display a message to the user. */
|
/** Display a message to the user. */
|
||||||
void IssueMessage(cmake::MessageType t, std::string const& text,
|
void IssueMessage(cmake::MessageType t, std::string const& text,
|
||||||
|
|
Loading…
Reference in New Issue