瀏覽代碼

cmExportTryCompileFileGenerator: Create cmGeneratorTargets.

This is not a deprecated behavior, but only requires IMPORTED targets
be made.
Stephen Kelly 10 年之前
父節點
當前提交
570938cbfd

+ 1 - 1
Source/cmCoreTryCompile.cxx

@@ -379,7 +379,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
     if (!targets.empty())
     if (!targets.empty())
       {
       {
       std::string fname = "/" + std::string(targetName) + "Targets.cmake";
       std::string fname = "/" + std::string(targetName) + "Targets.cmake";
-      cmExportTryCompileFileGenerator tcfg;
+      cmExportTryCompileFileGenerator tcfg(gg);
       tcfg.SetExportFile((this->BinaryDirectory + fname).c_str());
       tcfg.SetExportFile((this->BinaryDirectory + fname).c_str());
       tcfg.SetExports(targets);
       tcfg.SetExports(targets);
       tcfg.SetConfig(this->Makefile->GetSafeDefinition(
       tcfg.SetConfig(this->Makefile->GetSafeDefinition(

+ 7 - 0
Source/cmExportTryCompileFileGenerator.cxx

@@ -13,9 +13,16 @@
 #include "cmExportTryCompileFileGenerator.h"
 #include "cmExportTryCompileFileGenerator.h"
 
 
 #include "cmGeneratedFileStream.h"
 #include "cmGeneratedFileStream.h"
+#include "cmGlobalGenerator.h"
 #include "cmGeneratorExpressionDAGChecker.h"
 #include "cmGeneratorExpressionDAGChecker.h"
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
+cmExportTryCompileFileGenerator::cmExportTryCompileFileGenerator(
+    cmGlobalGenerator* gg)
+{
+  gg->CreateGenerationObjects(cmGlobalGenerator::ImportedOnly);
+}
+
 bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os)
 bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os)
 {
 {
   std::set<cmTarget const*> emitted;
   std::set<cmTarget const*> emitted;

+ 2 - 0
Source/cmExportTryCompileFileGenerator.h

@@ -20,6 +20,8 @@ class cmInstallTargetGenerator;
 class cmExportTryCompileFileGenerator: public cmExportFileGenerator
 class cmExportTryCompileFileGenerator: public cmExportFileGenerator
 {
 {
 public:
 public:
+  cmExportTryCompileFileGenerator(cmGlobalGenerator* gg);
+
   /** Set the list of targets to export.  */
   /** Set the list of targets to export.  */
   void SetExports(const std::vector<cmTarget const*> &exports)
   void SetExports(const std::vector<cmTarget const*> &exports)
     { this->Exports = exports; }
     { this->Exports = exports; }

+ 16 - 12
Source/cmGlobalGenerator.cxx

@@ -1170,11 +1170,11 @@ void cmGlobalGenerator::Configure()
 
 
 }
 }
 
 
-void cmGlobalGenerator::CreateGenerationObjects()
+void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes)
 {
 {
   cmDeleteAll(this->GeneratorTargets);
   cmDeleteAll(this->GeneratorTargets);
   this->GeneratorTargets.clear();
   this->GeneratorTargets.clear();
-  this->CreateGeneratorTargets();
+  this->CreateGeneratorTargets(targetTypes);
 }
 }
 
 
 cmExportBuildFileGenerator*
 cmExportBuildFileGenerator*
@@ -1485,18 +1485,22 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
 }
 }
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
-void cmGlobalGenerator::CreateGeneratorTargets(cmLocalGenerator *lg)
+void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes,
+                                               cmLocalGenerator *lg)
 {
 {
   cmGeneratorTargetsType generatorTargets;
   cmGeneratorTargetsType generatorTargets;
   cmMakefile* mf = lg->GetMakefile();
   cmMakefile* mf = lg->GetMakefile();
-  cmTargets& targets = mf->GetTargets();
-  for(cmTargets::iterator ti = targets.begin();
-      ti != targets.end(); ++ti)
+  if (targetTypes == AllTargets)
     {
     {
-    cmTarget* t = &ti->second;
-    cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg);
-    this->GeneratorTargets[t] = gt;
-    generatorTargets[t] = gt;
+    cmTargets& targets = mf->GetTargets();
+    for(cmTargets::iterator ti = targets.begin();
+        ti != targets.end(); ++ti)
+      {
+      cmTarget* t = &ti->second;
+      cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg);
+      this->GeneratorTargets[t] = gt;
+      generatorTargets[t] = gt;
+      }
     }
     }
 
 
   for(std::vector<cmTarget*>::const_iterator
   for(std::vector<cmTarget*>::const_iterator
@@ -1524,12 +1528,12 @@ void cmGlobalGenerator::InitGeneratorTargets()
 }
 }
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
-void cmGlobalGenerator::CreateGeneratorTargets()
+void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes)
 {
 {
   // Construct per-target generator information.
   // Construct per-target generator information.
   for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
   for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
     {
     {
-    this->CreateGeneratorTargets(this->LocalGenerators[i]);
+    this->CreateGeneratorTargets(targetTypes, this->LocalGenerators[i]);
     }
     }
 }
 }
 
 

+ 9 - 3
Source/cmGlobalGenerator.h

@@ -86,7 +86,13 @@ public:
    */
    */
   virtual void Configure();
   virtual void Configure();
 
 
-  void CreateGenerationObjects();
+
+  enum TargetTypes {
+    AllTargets,
+    ImportedOnly
+  };
+
+  void CreateGenerationObjects(TargetTypes targetTypes = AllTargets);
 
 
   /**
   /**
    * Generate the all required files for building this project/tree. This
    * Generate the all required files for building this project/tree. This
@@ -491,9 +497,9 @@ private:
   // Per-target generator information.
   // Per-target generator information.
   cmGeneratorTargetsType GeneratorTargets;
   cmGeneratorTargetsType GeneratorTargets;
   friend class cmake;
   friend class cmake;
-  void CreateGeneratorTargets(cmLocalGenerator* lg);
+  void CreateGeneratorTargets(TargetTypes targetTypes, cmLocalGenerator* lg);
   void InitGeneratorTargets();
   void InitGeneratorTargets();
-  void CreateGeneratorTargets();
+  void CreateGeneratorTargets(TargetTypes targetTypes);
 
 
   void ClearGeneratorMembers();
   void ClearGeneratorMembers();
 
 

+ 1 - 1
Source/cmake.cxx

@@ -483,7 +483,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
     std::string linkPath;
     std::string linkPath;
     std::string flags;
     std::string flags;
     std::string linkFlags;
     std::string linkFlags;
-    gg->CreateGeneratorTargets(lg.get());
+    gg->CreateGeneratorTargets(cmGlobalGenerator::AllTargets, lg.get());
     cmGeneratorTarget *gtgt = gg->GetGeneratorTarget(tgt);
     cmGeneratorTarget *gtgt = gg->GetGeneratorTarget(tgt);
     lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
     lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
                        gtgt, false);
                        gtgt, false);