瀏覽代碼

Ninja: suppress cmcldeps only for source file signature try_compiles

Peter Kümmel 13 年之前
父節點
當前提交
7b2bf28e18
共有 3 個文件被更改,包括 15 次插入2 次删除
  1. 12 0
      Source/cmMakefile.cxx
  2. 2 0
      Source/cmMakefile.h
  3. 1 2
      Source/cmNinjaTargetGenerator.cxx

+ 12 - 0
Source/cmMakefile.cxx

@@ -46,6 +46,7 @@ public:
   std::stack<cmDefinitions, std::list<cmDefinitions> > VarStack;
   std::stack<std::set<cmStdString> > VarInitStack;
   std::stack<std::set<cmStdString> > VarUsageStack;
+  bool IsSourceFileTryCompile;
 };
 
 // default is not to be building executables
@@ -56,6 +57,7 @@ cmMakefile::cmMakefile(): Internal(new Internals)
   this->Internal->VarStack.push(defs);
   this->Internal->VarInitStack.push(globalKeys);
   this->Internal->VarUsageStack.push(globalKeys);
+  this->Internal->IsSourceFileTryCompile = false;
 
   // Initialize these first since AddDefaultDefinitions calls AddDefinition
   this->WarnUnused = false;
@@ -2912,6 +2914,7 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
                            const std::vector<std::string> *cmakeArgs,
                            std::string *output)
 {
+  this->Internal->IsSourceFileTryCompile = fast;
   // does the binary directory exist ? If not create it...
   if (!cmSystemTools::FileIsDirectory(bindir))
     {
@@ -2937,6 +2940,7 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
       "Internal CMake error, TryCompile bad GlobalGenerator");
     // return to the original directory
     cmSystemTools::ChangeDirectory(cwd.c_str());
+    this->Internal->IsSourceFileTryCompile = false;
     return 1;
     }
   cm.SetGlobalGenerator(gg);
@@ -3009,6 +3013,7 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
       "Internal CMake error, TryCompile configure of cmake failed");
     // return to the original directory
     cmSystemTools::ChangeDirectory(cwd.c_str());
+    this->Internal->IsSourceFileTryCompile = false;
     return 1;
     }
 
@@ -3018,6 +3023,7 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
       "Internal CMake error, TryCompile generation of cmake failed");
     // return to the original directory
     cmSystemTools::ChangeDirectory(cwd.c_str());
+    this->Internal->IsSourceFileTryCompile = false;
     return 1;
     }
 
@@ -3031,9 +3037,15 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
                                                            this);
 
   cmSystemTools::ChangeDirectory(cwd.c_str());
+  this->Internal->IsSourceFileTryCompile = false;
   return ret;
 }
 
+bool cmMakefile::GetIsSourceFileTryCompile() const
+{
+  return this->Internal->IsSourceFileTryCompile;
+}
+
 cmake *cmMakefile::GetCMakeInstance() const
 {
   if ( this->LocalGenerator && this->LocalGenerator->GetGlobalGenerator() )

+ 2 - 0
Source/cmMakefile.h

@@ -128,6 +128,8 @@ public:
                  const std::vector<std::string> *cmakeArgs,
                  std::string *output);
 
+  bool GetIsSourceFileTryCompile() const;
+
   /**
    * Specify the makefile generator. This is platform/compiler
    * dependent, although the interface is through a generic

+ 1 - 2
Source/cmNinjaTargetGenerator.cxx

@@ -355,8 +355,7 @@ cmNinjaTargetGenerator
   if (lang == "C" || lang == "CXX" || lang == "RC")
     {
     clDepsBinary = mf->GetSafeDefinition("CMAKE_CMCLDEPS_EXECUTABLE");
-    if (!clDepsBinary.empty() &&
-        !this->GetGlobalGenerator()->GetCMakeInstance()->GetIsInTryCompile())
+    if (!clDepsBinary.empty() && !mf->GetIsSourceFileTryCompile())
       {
       clShowPrefix = mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDE_PREFIX");
       clBinary = mf->GetDefinition("CMAKE_C_COMPILER") ?