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()))
{
cmOStringStream msg;
msg << this->FileName << ":" << this->FileLine << ":" <<
" CMake Warning: uninitialized variable \'" << var << "\'";
cmSystemTools::Message(msg.str().c_str());
cmListFileBacktrace bt;
cmListFileContext lfc;
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;

View File

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