summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-12-02 13:42:06 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-12-02 13:42:06 (GMT)
commit3fa2fc71b119751bc915f0068d2046667fdefd32 (patch)
tree19a4793166b562bdd0478289702d1abf39e4bf00 /Source
parentda78a1648fd5d4452a98c46eb9af486d16c43c9a (diff)
parentaac633d5e5765bb6b51e31364325ae7d916f021c (diff)
downloadCMake-3fa2fc71b119751bc915f0068d2046667fdefd32.zip
CMake-3fa2fc71b119751bc915f0068d2046667fdefd32.tar.gz
CMake-3fa2fc71b119751bc915f0068d2046667fdefd32.tar.bz2
Merge topic 'cmake-W-options'
aac633d5 Explicitly enable deprecated warnings by default. e8974b62 Modify dev warning options to affect deprecated warnings. b146747e Consistent documentation for deprecation message variables. da688bcb Add -W options to control deprecated warning messages. 07388f83 Refactor the -W options parser to be generic. 246b0bfb Explicitly enable author (dev) warnings by default. deec3a3f Make message suppression more consistent. aa427a42 Tests: Revise message in RunCMake.CommandLine -Wdev case
Diffstat (limited to 'Source')
-rw-r--r--Source/cmMakefile.cxx8
-rw-r--r--Source/cmMakefile.h3
-rw-r--r--Source/cmMessageCommand.cxx27
-rw-r--r--Source/cmake.cxx251
-rw-r--r--Source/cmake.h43
5 files changed, 270 insertions, 62 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 47e1731..1b0a99a 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -105,7 +105,8 @@ cmMakefile::~cmMakefile()
//----------------------------------------------------------------------------
void cmMakefile::IssueMessage(cmake::MessageType t,
- std::string const& text) const
+ std::string const& text,
+ bool force) const
{
// Collect context information.
if(!this->ExecutionStatusStack.empty())
@@ -114,7 +115,8 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
{
this->ExecutionStatusStack.back()->SetNestedError(true);
}
- this->GetCMakeInstance()->IssueMessage(t, text, this->GetBacktrace());
+ this->GetCMakeInstance()->IssueMessage(t, text, this->GetBacktrace(),
+ force);
}
else
{
@@ -129,7 +131,7 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
}
lfc.Line = 0;
- this->GetCMakeInstance()->IssueMessage(t, text, lfc);
+ this->GetCMakeInstance()->IssueMessage(t, text, lfc, force);
}
}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index fa1534d..362ea75 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -709,7 +709,8 @@ public:
};
void IssueMessage(cmake::MessageType t,
- std::string const& text) const;
+ std::string const& text,
+ bool force = false) const;
/** Set whether or not to report a CMP0000 violation. */
void SetCheckCMP0000(bool b) { this->CheckCMP0000 = b; }
diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx
index 2854a82..8272eb0 100644
--- a/Source/cmMessageCommand.cxx
+++ b/Source/cmMessageCommand.cxx
@@ -43,7 +43,15 @@ bool cmMessageCommand
}
else if (*i == "AUTHOR_WARNING")
{
- type = cmake::AUTHOR_WARNING;
+ if (this->Makefile->GetCMakeInstance()->GetSuppressDevWarnings(
+ this->Makefile))
+ {
+ return true;
+ }
+ else
+ {
+ type = cmake::AUTHOR_WARNING;
+ }
++i;
}
else if (*i == "STATUS")
@@ -58,13 +66,17 @@ bool cmMessageCommand
fatal = true;
type = cmake::DEPRECATION_ERROR;
}
- else if (this->Makefile->IsOn("CMAKE_WARN_DEPRECATED"))
- {
- type = cmake::DEPRECATION_WARNING;
- }
else
{
- return true;
+ if (this->Makefile->GetCMakeInstance()->GetSuppressDeprecatedWarnings(
+ this->Makefile))
+ {
+ return true;
+ }
+ else
+ {
+ type = cmake::DEPRECATION_WARNING;
+ }
}
++i;
}
@@ -73,7 +85,8 @@ bool cmMessageCommand
if (type != cmake::MESSAGE)
{
- this->Makefile->IssueMessage(type, message);
+ // we've overriden the message type, above, so force IssueMessage to use it
+ this->Makefile->IssueMessage(type, message, true);
}
else
{
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index ee1e878..c0a1196 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -127,8 +127,6 @@ cmake::cmake()
this->WarnUnused = false;
this->WarnUnusedCli = true;
this->CheckSystemVars = false;
- this->SuppressDevWarnings = false;
- this->DoSuppressDevWarnings = false;
this->DebugOutput = false;
this->DebugTryCompile = false;
this->ClearBuildSystem = false;
@@ -274,15 +272,51 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
return false;
}
}
- else if(arg.find("-Wno-dev",0) == 0)
+ else if(cmHasLiteralPrefix(arg, "-W"))
{
- this->SuppressDevWarnings = true;
- this->DoSuppressDevWarnings = true;
- }
- else if(arg.find("-Wdev",0) == 0)
- {
- this->SuppressDevWarnings = false;
- this->DoSuppressDevWarnings = true;
+ std::string entry = arg.substr(2);
+ if (entry.empty())
+ {
+ ++i;
+ if (i < args.size())
+ {
+ entry = args[i];
+ }
+ else
+ {
+ cmSystemTools::Error("-W must be followed with [no-]<name>.");
+ return false;
+ }
+ }
+
+ std::string name;
+ bool foundNo = false;
+ unsigned int nameStartPosition = 0;
+
+ if (entry.find("no-", nameStartPosition) == 0)
+ {
+ foundNo = true;
+ nameStartPosition += 3;
+ }
+
+ name = entry.substr(nameStartPosition);
+ if (name.empty())
+ {
+ cmSystemTools::Error("No warning name provided.");
+ return false;
+ }
+
+ if (!foundNo)
+ {
+ // -W<name>
+ this->DiagLevels[name] = std::max(this->DiagLevels[name],
+ DIAG_WARN);
+ }
+ else
+ {
+ // -Wno<name>
+ this->DiagLevels[name] = DIAG_IGNORE;
+ }
}
else if(arg.find("-U",0) == 0)
{
@@ -618,11 +652,7 @@ void cmake::SetArgs(const std::vector<std::string>& args,
// skip for now
i++;
}
- else if(arg.find("-Wno-dev",0) == 0)
- {
- // skip for now
- }
- else if(arg.find("-Wdev",0) == 0)
+ else if(arg.find("-W",0) == 0)
{
// skip for now
}
@@ -1231,25 +1261,74 @@ int cmake::HandleDeleteCacheVariables(const std::string& var)
int cmake::Configure()
{
- if(this->DoSuppressDevWarnings)
+ DiagLevel diagLevel;
+
+ if (this->DiagLevels.count("deprecated") == 1)
{
- if(this->SuppressDevWarnings)
+
+ diagLevel = this->DiagLevels["deprecated"];
+ if (diagLevel == DIAG_IGNORE)
{
- this->
- AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "TRUE",
- "Suppress Warnings that are meant for"
- " the author of the CMakeLists.txt files.",
- cmState::INTERNAL);
+ this->AddCacheEntry("CMAKE_WARN_DEPRECATED", "FALSE",
+ "Whether to issue warnings for deprecated "
+ "functionality.",
+ cmState::INTERNAL);
}
- else
+ else if (diagLevel == DIAG_WARN)
{
- this->
- AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "FALSE",
- "Suppress Warnings that are meant for"
- " the author of the CMakeLists.txt files.",
- cmState::INTERNAL);
+ this->AddCacheEntry("CMAKE_WARN_DEPRECATED", "TRUE",
+ "Whether to issue warnings for deprecated "
+ "functionality.",
+ cmState::INTERNAL);
}
}
+
+ if (this->DiagLevels.count("dev") == 1)
+ {
+ bool setDeprecatedVariables = false;
+
+ const char* cachedWarnDeprecated =
+ this->State->GetCacheEntryValue("CMAKE_WARN_DEPRECATED");
+
+ // don't overwrite deprecated warning setting from a previous invocation
+ if (!cachedWarnDeprecated)
+ {
+ setDeprecatedVariables = true;
+ }
+
+ diagLevel = this->DiagLevels["dev"];
+ if (diagLevel == DIAG_IGNORE)
+ {
+ this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "TRUE",
+ "Suppress Warnings that are meant for"
+ " the author of the CMakeLists.txt files.",
+ cmState::INTERNAL);
+
+ if (setDeprecatedVariables)
+ {
+ this->AddCacheEntry("CMAKE_WARN_DEPRECATED", "FALSE",
+ "Whether to issue warnings for deprecated "
+ "functionality.",
+ cmState::INTERNAL);
+ }
+ }
+ else if (diagLevel == DIAG_WARN)
+ {
+ this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "FALSE",
+ "Suppress Warnings that are meant for"
+ " the author of the CMakeLists.txt files.",
+ cmState::INTERNAL);
+
+ if (setDeprecatedVariables)
+ {
+ this->AddCacheEntry("CMAKE_WARN_DEPRECATED", "TRUE",
+ "Whether to issue warnings for deprecated "
+ "functionality.",
+ cmState::INTERNAL);
+ }
+ }
+ }
+
int ret = this->ActualConfigure();
const char* delCacheVars = this->State
->GetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_");
@@ -1580,6 +1659,7 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
{
this->AddCMakePaths();
}
+
// Add any cache args
if ( !this->SetCacheArgs(args) )
{
@@ -2485,6 +2565,38 @@ 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 (this->GetSuppressDeprecatedWarnings())
+ {
+ isVisible = false;
+ }
+ }
+ else if (t == cmake::AUTHOR_WARNING)
+ {
+ if (this->GetSuppressDevWarnings())
+ {
+ isVisible = false;
+ }
+ }
+
+ return isVisible;
+}
+
bool cmake::PrintMessagePreamble(cmake::MessageType t, std::ostream& msg)
{
// Construct the message header.
@@ -2508,20 +2620,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 +2684,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 +2713,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))
{
@@ -2763,3 +2880,55 @@ void cmake::RunCheckForUnusedVariables()
}
#endif
}
+
+void cmake::SetSuppressDevWarnings(bool b)
+{
+ // equivalent to -Wno-dev
+ if (b)
+ {
+ this->DiagLevels["dev"] = DIAG_IGNORE;
+ }
+ // equivalent to -Wdev
+ else
+ {
+ this->DiagLevels["dev"] = std::max(this->DiagLevels["dev"],
+ DIAG_WARN);
+ }
+}
+
+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)
+{
+ /*
+ * 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);
+ }
+}
diff --git a/Source/cmake.h b/Source/cmake.h
index c584ad9..4c5515b 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -68,6 +68,11 @@ class cmake
DEPRECATION_WARNING
};
+ enum DiagLevel
+ {
+ DIAG_IGNORE,
+ DIAG_WARN
+ };
/** \brief Describes the working modes of cmake */
enum WorkingMode
@@ -303,17 +308,28 @@ class cmake
std::string const& GetCMakeEditCommand() const
{ return this->CMakeEditCommand; }
- void SetSuppressDevWarnings(bool v)
- {
- this->SuppressDevWarnings = v;
- this->DoSuppressDevWarnings = true;
- }
+ void SetSuppressDevWarnings(bool v);
+ /*
+ * Get the state of the suppression of developer (author) warnings.
+ * Returns false, by default, if developer warnings should be shown, true
+ * otherwise.
+ */
+ 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());
+ cmListFileBacktrace const& backtrace = cmListFileBacktrace(),
+ bool force = false);
void IssueMessage(cmake::MessageType t, std::string const& text,
- cmListFileContext const& lfc);
+ cmListFileContext const& lfc,
+ bool force = false);
///! run the --build option
int Build(const std::string& dir,
@@ -351,8 +367,7 @@ protected:
cmGlobalGenerator *GlobalGenerator;
cmCacheManager *CacheManager;
- bool SuppressDevWarnings;
- bool DoSuppressDevWarnings;
+ std::map<std::string, DiagLevel> DiagLevels;
std::string GeneratorPlatform;
std::string GeneratorToolset;
@@ -419,6 +434,12 @@ private:
// Print a list of valid generators to stderr.
void PrintGeneratorList();
+ /*
+ * Check if messages of this type should be output, based on the state of the
+ * warning and error output CMake variables, in the cache.
+ */
+ bool IsMessageTypeVisible(cmake::MessageType t);
+
bool PrintMessagePreamble(cmake::MessageType t, std::ostream& msg);
};
@@ -430,7 +451,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) \