فهرست منبع

Use cmake::IssueMessage for warnings

Ben Boeckel 15 سال پیش
والد
کامیت
668e005db5
2فایلهای تغییر یافته به همراه18 افزوده شده و 9 حذف شده
  1. 8 3
      Source/cmCommandArgumentParserHelper.cxx
  2. 10 6
      Source/cmMakefile.cxx

+ 8 - 3
Source/cmCommandArgumentParserHelper.cxx

@@ -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;

+ 10 - 6
Source/cmMakefile.cxx

@@ -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);
       }
     }
 }