浏览代码

ENH: Initial framework for deprecated commands

Andy Cedilnik 22 年之前
父节点
当前提交
18c6f9e0c5
共有 1 个文件被更改,包括 19 次插入2 次删除
  1. 19 2
      Source/cmMakefile.cxx

+ 19 - 2
Source/cmMakefile.cxx

@@ -196,6 +196,23 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff)
     this->GetCMakeInstance()->GetCommand(name.c_str());
   if(rm)
     {
+    const char* versionValue
+      = this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
+    int major = 0;
+    int minor = 0;
+    if ( versionValue )
+      {
+      sscanf(versionValue, "%d.%d", &major, &minor);
+      }
+    if ( rm->IsDeprecated(major, minor) )
+      {
+      cmOStringStream error;
+      error << "Error in cmake code at\n"
+        << lff.m_FilePath << ":" << lff.m_Line << ":\n"
+        << rm->GetError();
+      cmSystemTools::Error(error.str().c_str());
+      return false;
+      }
     cmCommand* usedCommand = rm->Clone();
     usedCommand->SetMakefile(this);
     bool keepCommand = false;
@@ -209,8 +226,8 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff)
           {
           cmOStringStream error;
           error << "Error in cmake code at\n"
-                << lff.m_FilePath << ":" << lff.m_Line << ":\n"
-                << usedCommand->GetError();
+            << lff.m_FilePath << ":" << lff.m_Line << ":\n"
+            << usedCommand->GetError();
           cmSystemTools::Error(error.str().c_str());
           result = false;
           }