浏览代码

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.
Ben Boeckel 15 年之前
父节点
当前提交
300fc15779
共有 2 个文件被更改,包括 7 次插入4 次删除
  1. 4 2
      Source/cmCommandArgumentParserHelper.cxx
  2. 3 2
      Source/cmMakefile.cxx

+ 4 - 2
Source/cmCommandArgumentParserHelper.cxx

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

+ 3 - 2
Source/cmMakefile.cxx

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