Use cmake::IssueMessage for warnings

This commit is contained in:
Ben Boeckel 2010-12-07 16:38:25 -05:00
parent 88cd4c1e92
commit 668e005db5
2 changed files with 18 additions and 9 deletions

View File

@ -137,9 +137,14 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
this->Makefile->GetHomeOutputDirectory())) this->Makefile->GetHomeOutputDirectory()))
{ {
cmOStringStream msg; cmOStringStream msg;
msg << this->FileName << ":" << this->FileLine << ":" << cmListFileBacktrace bt;
" CMake Warning: uninitialized variable \'" << var << "\'"; cmListFileContext lfc;
cmSystemTools::Message(msg.str().c_str()); lfc.FilePath = this->FileName;
lfc.Line = this->FileLine;
bt.push_back(lfc);
msg << "uninitialized variable \'" << var << "\'";
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
msg.str().c_str(), bt);
} }
} }
return 0; return 0;

View File

@ -1777,18 +1777,21 @@ void cmMakefile::CheckForUnused(const char* reason, const char* name) const
if (this->WarnUnused && !this->VariableUsed(name)) if (this->WarnUnused && !this->VariableUsed(name))
{ {
cmStdString path; cmStdString path;
long line; cmListFileBacktrace bt;
if (this->CallStack.size()) if (this->CallStack.size())
{ {
const cmListFileContext* file = this->CallStack.back().Context; const cmListFileContext* file = this->CallStack.back().Context;
bt.push_back(*file);
path = file->FilePath.c_str(); path = file->FilePath.c_str();
line = file->Line;
} }
else else
{ {
path = this->GetStartDirectory(); path = this->GetStartDirectory();
path += "/CMakeLists.txt"; path += "/CMakeLists.txt";
line = 0; cmListFileContext lfc;
lfc.FilePath = path;
lfc.Line = 0;
bt.push_back(lfc);
} }
if (this->CheckSystemVars || if (this->CheckSystemVars ||
cmSystemTools::IsSubDirectory(path.c_str(), cmSystemTools::IsSubDirectory(path.c_str(),
@ -1799,9 +1802,10 @@ void cmMakefile::CheckForUnused(const char* reason, const char* name) const
cmake::GetCMakeFilesDirectory()))) cmake::GetCMakeFilesDirectory())))
{ {
cmOStringStream msg; cmOStringStream msg;
msg << path << ":" << line << ":" << msg << "unused variable (" << reason << ") \'" << name << "\'";
" CMake Warning: (" << reason << ") unused variable \'" << name << "\'"; this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
cmSystemTools::Message(msg.str().c_str()); msg.str().c_str(),
bt);
} }
} }
} }