Fix detection of system files

Instead of looking to see if the file is under CMAKE_ROOT, check to see
if it is instead under the source or binary directories in use.
This commit is contained in:
Ben Boeckel 2010-09-02 11:30:28 -04:00
parent d784e6af4d
commit 300fc15779
2 changed files with 7 additions and 4 deletions

View File

@ -130,8 +130,10 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
// not been "cleared"/initialized with a set(foo ) call // not been "cleared"/initialized with a set(foo ) call
if(this->WarnUninitialized && !this->Makefile->VariableInitialized(var)) if(this->WarnUninitialized && !this->Makefile->VariableInitialized(var))
{ {
const char* root = this->Makefile->GetDefinition("CMAKE_ROOT"); const char* srcRoot = this->Makefile->GetDefinition("CMAKE_SOURCE_DIR");
if (this->CheckSystemVars || strstr(this->FileName, root) != this->FileName) const char* binRoot = this->Makefile->GetDefinition("CMAKE_BINARY_DIR");
if (this->CheckSystemVars || strstr(this->FileName, srcRoot) == this->FileName ||
strstr(this->FileName, binRoot) == this->FileName)
{ {
cmOStringStream msg; cmOStringStream msg;
msg << this->FileName << ":" << this->FileLine << ":" << msg << this->FileName << ":" << this->FileLine << ":" <<

View File

@ -3392,8 +3392,9 @@ void cmMakefile::PopScope()
if (this->WarnUnused && usage.find(*it) == usage.end()) if (this->WarnUnused && usage.find(*it) == usage.end())
{ {
const char* cdir = this->ListFileStack.back().c_str(); const char* cdir = this->ListFileStack.back().c_str();
const char* root = this->GetDefinition("CMAKE_ROOT"); const char* srcRoot = this->GetDefinition("CMAKE_SOURCE_DIR");
if (this->CheckSystemVars || strstr(cdir, root) != cdir) const char* binRoot = this->GetDefinition("CMAKE_BINARY_DIR");
if (this->CheckSystemVars || strstr(cdir, srcRoot) == cdir || strstr(cdir, binRoot) == cdir)
{ {
cmOStringStream m; cmOStringStream m;
m << "unused variable \'" << *it << "\'"; m << "unused variable \'" << *it << "\'";