浏览代码

Improve behaviour of --find-package mode with try_run/try_compile

Instead of failing with an error message which says things have not been
setup correctly, it now says that try_compile/try_run() are not
supported in find_package mode (#12426).

Alex
Alex Neundorf 14 年之前
父节点
当前提交
c886e312bb
共有 2 个文件被更改,包括 16 次插入1 次删除
  1. 8 1
      Source/cmTryCompileCommand.cxx
  2. 8 0
      Source/cmTryRunCommand.cxx

+ 8 - 1
Source/cmTryCompileCommand.cxx

@@ -20,6 +20,14 @@ bool cmTryCompileCommand
     return false;
     }
 
+  if(this->Makefile->GetCMakeInstance()->GetWorkingMode() ==
+                                                      cmake::FIND_PACKAGE_MODE)
+    {
+    cmSystemTools::Error(
+         "The TRY_COMPILE() command is not supported in --find-package mode.");
+    return false;
+    }
+
   this->TryCompileCode(argv);
 
   // if They specified clean then we clean up what we can
@@ -32,4 +40,3 @@ bool cmTryCompileCommand
     }
   return true;
 }
-

+ 8 - 0
Source/cmTryRunCommand.cxx

@@ -22,6 +22,14 @@ bool cmTryRunCommand
     return false;
     }
 
+  if(this->Makefile->GetCMakeInstance()->GetWorkingMode() ==
+                                                      cmake::FIND_PACKAGE_MODE)
+    {
+    cmSystemTools::Error(
+            "The TRY_RUN() command is not supported in --find-package mode.");
+    return false;
+    }
+
   // build an arg list for TryCompile and extract the runArgs,
   std::vector<std::string> tryCompile;