summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorMichael Scott <michael.scott250@gmail.com>2015-11-08 12:20:47 (GMT)
committerBrad King <brad.king@kitware.com>2015-11-30 20:00:08 (GMT)
commitdeec3a3f06d341cfe0bef4e856b263eff347cc72 (patch)
tree3eb1f0268a400ea4fd0573c6431825ecaa0b392c /Source/cmake.cxx
parentaa427a4239eb691d4129ebc383ab7b0d61b5b94e (diff)
downloadCMake-deec3a3f06d341cfe0bef4e856b263eff347cc72.zip
CMake-deec3a3f06d341cfe0bef4e856b263eff347cc72.tar.gz
CMake-deec3a3f06d341cfe0bef4e856b263eff347cc72.tar.bz2
Make message suppression more consistent.
Make the message suppression more consistent, by adding a check for the message related CMake variables in cmake::IssueMessage, which allows callers of IssueMessage other than the message command to behave as expected. Also added a check for CMAKE_SUPPRESS_DEVELOPER_WARNINGS in the message command to mirror the deprecated message type behaviour. Added a 'force' flag to the cmake::IssueMessage method, to make the message suppression consistent, when setting the message related CMake variables directly in a CMake file. Expand message command tests to cover the AUTHOR_WARNING message type as well.
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx70
1 files changed, 57 insertions, 13 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index ee1e878..62476a1 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -2485,6 +2485,45 @@ static bool cmakeCheckStampList(const char* stampList)
return true;
}
+bool cmake::IsMessageTypeVisible(cmake::MessageType t)
+{
+ bool isVisible = true;
+
+ if(t == cmake::DEPRECATION_ERROR)
+ {
+ // if CMAKE_ERROR_DEPRECATED is on, show the message, otherwise suppress it
+ const char* errorDeprecated = this->State->GetCacheEntryValue(
+ "CMAKE_ERROR_DEPRECATED");
+ if(cmSystemTools::IsOff(errorDeprecated))
+ {
+ isVisible = false;
+ }
+ }
+ 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))
+ {
+ isVisible = false;
+ }
+ }
+ else if (t == cmake::AUTHOR_WARNING)
+ {
+ // if CMAKE_SUPPRESS_DEVELOPER_WARNINGS is on, suppress the message,
+ // otherwise show it
+ const char* suppressDevWarnings = this->State->GetCacheEntryValue(
+ "CMAKE_SUPPRESS_DEVELOPER_WARNINGS");
+ if(cmSystemTools::IsOn(suppressDevWarnings))
+ {
+ isVisible = false;
+ }
+ }
+
+ return isVisible;
+}
+
bool cmake::PrintMessagePreamble(cmake::MessageType t, std::ostream& msg)
{
// Construct the message header.
@@ -2508,20 +2547,13 @@ bool cmake::PrintMessagePreamble(cmake::MessageType t, std::ostream& msg)
{
msg << "CMake Deprecation Warning";
}
+ else if (t == cmake::AUTHOR_WARNING)
+ {
+ msg << "CMake Warning (dev)";
+ }
else
{
msg << "CMake Warning";
- if(t == cmake::AUTHOR_WARNING)
- {
- // Allow suppression of these warnings.
- const char* suppress = this->State->GetCacheEntryValue(
- "CMAKE_SUPPRESS_DEVELOPER_WARNINGS");
- if(suppress && cmSystemTools::IsOn(suppress))
- {
- return false;
- }
- msg << " (dev)";
- }
}
return true;
}
@@ -2579,10 +2611,16 @@ void displayMessage(cmake::MessageType t, std::ostringstream& msg)
//----------------------------------------------------------------------------
void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
- cmListFileBacktrace const& bt)
+ cmListFileBacktrace const& bt,
+ bool force)
{
cmListFileBacktrace backtrace = bt;
+ if (!force && !this->IsMessageTypeVisible(t))
+ {
+ return;
+ }
+
std::ostringstream msg;
if (!this->PrintMessagePreamble(t, msg))
{
@@ -2602,8 +2640,14 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
//----------------------------------------------------------------------------
void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
- cmListFileContext const& lfc)
+ cmListFileContext const& lfc,
+ bool force)
{
+ if (!force && !this->IsMessageTypeVisible(t))
+ {
+ return;
+ }
+
std::ostringstream msg;
if (!this->PrintMessagePreamble(t, msg))
{