diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-05-21 22:38:03 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-05-21 23:21:35 (GMT) |
commit | 8b4b9631f5f79ffee11b33c1e8826cd4064b3a23 (patch) | |
tree | 0f9bbb56aba29f8e5f715950c0d2ac944f29439b | |
parent | 46656aa1fa69b79aa0c645a131d7abfdc34e621c (diff) | |
download | CMake-8b4b9631f5f79ffee11b33c1e8826cd4064b3a23.zip CMake-8b4b9631f5f79ffee11b33c1e8826cd4064b3a23.tar.gz CMake-8b4b9631f5f79ffee11b33c1e8826cd4064b3a23.tar.bz2 |
cmake: Add IssueMessage overload taking a single cmListFileContext.
Port appropriate clients to use it.
-rw-r--r-- | Source/cmCommandArgumentParserHelper.cxx | 9 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 40 | ||||
-rw-r--r-- | Source/cmake.cxx | 18 | ||||
-rw-r--r-- | Source/cmake.h | 3 |
4 files changed, 44 insertions, 26 deletions
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index c816c23..bd098a5 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -14,6 +14,7 @@ #include "cmSystemTools.h" #include "cmMakefile.h" #include "cmState.h" +#include "cmLocalGenerator.h" #include "cmCommandArgumentLexer.h" @@ -139,14 +140,14 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) this->Makefile->GetHomeOutputDirectory())) { std::ostringstream msg; - cmListFileBacktrace bt(this->Makefile->GetLocalGenerator()); cmListFileContext lfc; - lfc.FilePath = this->FileName; + lfc.FilePath = this->Makefile->GetLocalGenerator() + ->Convert(this->FileName, cmLocalGenerator::HOME); + lfc.Line = this->FileLine; - bt.Append(lfc); msg << "uninitialized variable \'" << var << "\'"; this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, - msg.str(), bt); + msg.str(), lfc); } } return 0; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2a49c8f..3e8ae85 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -249,19 +249,13 @@ void cmMakefile::IssueMessage(cmake::MessageType t, std::string const& text) const { // Collect context information. - cmLocalGenerator* localGen = this->GetLocalGenerator(); - if(this->CallStack.empty() && this->GetCMakeInstance()->GetIsInTryCompile()) - { - localGen = 0; - } - cmListFileBacktrace backtrace(localGen); if(!this->CallStack.empty()) { if((t == cmake::FATAL_ERROR) || (t == cmake::INTERNAL_ERROR)) { this->CallStack.back().Status->SetNestedError(true); } - backtrace = this->GetBacktrace(); + this->GetCMakeInstance()->IssueMessage(t, text, this->GetBacktrace()); } else { @@ -278,12 +272,15 @@ void cmMakefile::IssueMessage(cmake::MessageType t, // command. Add whatever context information we have. lfc.FilePath = this->ListFileStack.back(); } + if(!this->CallStack.empty() + || !this->GetCMakeInstance()->GetIsInTryCompile()) + { + lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath, + cmLocalGenerator::HOME); + } lfc.Line = 0; - backtrace.Append(lfc); + this->GetCMakeInstance()->IssueMessage(t, text, lfc); } - - // Issue the message. - this->GetCMakeInstance()->IssueMessage(t, text, backtrace); } //---------------------------------------------------------------------------- @@ -1837,22 +1834,22 @@ void cmMakefile::LogUnused(const char* reason, if (this->WarnUnused) { std::string path; - cmListFileBacktrace bt(this->GetLocalGenerator()); + cmListFileContext lfc; if (!this->CallStack.empty()) { - cmListFileContext file = this->GetExecutionContext(); - bt.Append(file); - path = file.FilePath; + lfc = this->GetExecutionContext(); + path = lfc.FilePath; } else { path = this->GetCurrentSourceDirectory(); path += "/CMakeLists.txt"; - cmListFileContext lfc; lfc.FilePath = path; lfc.Line = 0; - bt.Append(lfc); } + lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath, + cmLocalGenerator::HOME); + if (this->CheckSystemVars || cmSystemTools::IsSubDirectory(path, this->GetHomeDirectory()) || @@ -1865,7 +1862,7 @@ void cmMakefile::LogUnused(const char* reason, msg << "unused variable (" << reason << ") \'" << name << "\'"; this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, msg.str(), - bt); + lfc); } } } @@ -2769,14 +2766,13 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew( this->GetHomeOutputDirectory())) { std::ostringstream msg; - cmListFileBacktrace bt(this->GetLocalGenerator()); cmListFileContext lfc; - lfc.FilePath = filename; + lfc.FilePath = this->LocalGenerator + ->Convert(filename, cmLocalGenerator::HOME); lfc.Line = line; - bt.Append(lfc); msg << "uninitialized variable \'" << lookup << "\'"; this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, - msg.str(), bt); + msg.str(), lfc); } } } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 15ea755..38a67cd 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2553,6 +2553,24 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, } //---------------------------------------------------------------------------- +void cmake::IssueMessage(cmake::MessageType t, std::string const& text, + cmListFileContext const& lfc) +{ + std::ostringstream msg; + if (!this->PrintMessagePreamble(t, msg)) + { + return; + } + + // Add the immediate context. + msg << (lfc.Line ? " at " : " in ") << lfc; + + printMessageText(msg, text); + + displayMessage(t, msg); +} + +//---------------------------------------------------------------------------- std::vector<std::string> cmake::GetDebugConfigs() { std::vector<std::string> configs; diff --git a/Source/cmake.h b/Source/cmake.h index d83c6fc..7f95fb6 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -303,6 +303,9 @@ class cmake /** Display a message to the user. */ void IssueMessage(cmake::MessageType t, std::string const& text, cmListFileBacktrace const& backtrace = cmListFileBacktrace(NULL)); + void IssueMessage(cmake::MessageType t, std::string const& text, + cmListFileContext const& lfc); + ///! run the --build option int Build(const std::string& dir, const std::string& target, |