summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2010-09-22 16:41:58 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2010-09-22 16:46:15 (GMT)
commitcbb286c0b25e806d817ceb540312f34a7e1aa9a5 (patch)
tree980ef26a196cebe980bd902383b8877968c29d50 /Source/cmMakefile.cxx
parent62be1f78aea0f38e245e7f8b748a24f95eadb37a (diff)
downloadCMake-cbb286c0b25e806d817ceb540312f34a7e1aa9a5.zip
CMake-cbb286c0b25e806d817ceb540312f34a7e1aa9a5.tar.gz
CMake-cbb286c0b25e806d817ceb540312f34a7e1aa9a5.tar.bz2
Fix the path detection to work for top-level
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx23
1 files changed, 18 insertions, 5 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 70d3495..57c354f 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1774,17 +1774,30 @@ bool cmMakefile::VariableUsed(const char* var) const
void cmMakefile::CheckForUnused(const char* reason, const char* name) const
{
- if (this->WarnUnused && !this->VariableUsed(name) && this->CallStack.size())
+ if (this->WarnUnused && !this->VariableUsed(name))
{
- const cmListFileContext* file = this->CallStack.back().Context;
+ cmStdString path;
+ int line;
+ if (this->CallStack.size())
+ {
+ const cmListFileContext* file = this->CallStack.back().Context;
+ path = file->FilePath.c_str();
+ line = file->Line;
+ }
+ else
+ {
+ path = this->GetStartDirectory();
+ path += "/CMakeLists.txt";
+ line = 0;
+ }
if (this->CheckSystemVars ||
- cmSystemTools::IsSubDirectory(file->FilePath.c_str(),
+ cmSystemTools::IsSubDirectory(path.c_str(),
this->GetHomeDirectory()) ||
- cmSystemTools::IsSubDirectory(file->FilePath.c_str(),
+ cmSystemTools::IsSubDirectory(path.c_str(),
this->GetHomeOutputDirectory()))
{
cmOStringStream msg;
- msg << file->FilePath << ":" << file->Line << ":" <<
+ msg << path << ":" << line << ":" <<
" warning: (" << reason << ") unused variable \'" << name << "\'";
cmSystemTools::Message(msg.str().c_str());
}