Browse Source

ENH: Added global TargetManifest computation between Configure and Generate steps. This allows generators to know what other targets will exist on disk when the build completes.

Brad King 19 years ago
parent
commit
2301a025ea

+ 11 - 2
Source/cmGlobalGenerator.cxx

@@ -701,8 +701,6 @@ void cmGlobalGenerator::Generate()
         }
       }
     }
-  
-  // Generate project files
   for (i = 0; i < this->LocalGenerators.size(); ++i)
     {
     cmTargets* targets = &(this->LocalGenerators[i]->GetMakefile()->GetTargets());
@@ -711,6 +709,17 @@ void cmGlobalGenerator::Generate()
       {
       (*targets)[tit->first] = tit->second;
       }
+    }
+
+  // Compute the manifest of main targets generated.
+  for (i = 0; i < this->LocalGenerators.size(); ++i)
+    {
+    this->LocalGenerators[i]->GenerateTargetManifest(this->TargetManifest);
+    }
+
+  // Generate project files
+  for (i = 0; i < this->LocalGenerators.size(); ++i)
+    {
     this->LocalGenerators[i]->Generate();
     this->LocalGenerators[i]->GenerateInstallRules();
     this->LocalGenerators[i]->GenerateTestFiles();

+ 8 - 0
Source/cmGlobalGenerator.h

@@ -171,6 +171,10 @@ public:
                                         const char* suffix,
                                         std::string& dir);
 
+  /** Get the manifest of all targets that will be built for each
+      configuration.  This is valid during generation only.  */
+  cmTargetManifest const& GetTargetManifest() { return this->TargetManifest; }
+
 protected:
   // Fill the ProjectMap, this must be called after LocalGenerators 
   // has been populated.
@@ -205,6 +209,10 @@ protected:
   // Set of named installation components requested by the project.
   std::set<cmStdString> InstallComponents;
 
+  // Manifest of all targets that will be built for each configuration.
+  // This is computed just before local generators generate.
+  cmTargetManifest TargetManifest;
+
 private:
   // If you add a new map here, make sure it is copied
   // in EnableLanguagesFromGenerator 

+ 57 - 0
Source/cmLocalGenerator.cxx

@@ -391,6 +391,63 @@ void cmLocalGenerator::GenerateInstallRules()
     }
 }
 
+//----------------------------------------------------------------------------
+void cmLocalGenerator::GenerateTargetManifest(cmTargetManifest& manifest)
+{
+  // Collect the set of configuration types.
+  std::vector<std::string> configNames;
+  if(const char* configurationTypes =
+     this->Makefile->GetDefinition("CMAKE_CONFIGURATION_TYPES"))
+    {
+    cmSystemTools::ExpandListArgument(configurationTypes, configNames);
+    }
+  else if(const char* buildType =
+          this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"))
+    {
+    if(*buildType)
+      {
+      configNames.push_back(buildType);
+      }
+    }
+
+  // Add our targets to the manifest for each configuration.
+  cmTargets& targets = this->Makefile->GetTargets();
+  for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
+    {
+    cmTarget& target = t->second;
+    cmTarget::TargetType type = target.GetType();
+    if(type == cmTarget::STATIC_LIBRARY ||
+       type == cmTarget::SHARED_LIBRARY ||
+       type == cmTarget::MODULE_LIBRARY ||
+       type == cmTarget::EXECUTABLE)
+      {
+      if(configNames.empty())
+        {
+        manifest[""].insert(target.GetFullPath(0, false));
+        if(type == cmTarget::SHARED_LIBRARY &&
+           this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
+          {
+          manifest[""].insert(target.GetFullPath(0, true));
+          }
+        }
+      else
+        {
+        for(std::vector<std::string>::iterator ci = configNames.begin();
+            ci != configNames.end(); ++ci)
+          {
+          const char* config = ci->c_str();
+          manifest[config].insert(target.GetFullPath(config, false));
+          if(type == cmTarget::SHARED_LIBRARY &&
+             this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
+            {
+            manifest[config].insert(target.GetFullPath(config, true));
+            }
+          }
+        }
+      }
+    }
+}
+
 void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, 
                                                       const char* lang, 
                                                       cmSourceFile& source,

+ 6 - 1
Source/cmLocalGenerator.h

@@ -22,6 +22,7 @@
 class cmMakefile;
 class cmGlobalGenerator;
 class cmTarget;
+class cmTargetManifest;
 class cmSourceFile;
 
 
@@ -63,7 +64,11 @@ public:
    * Generate the test files for tests.
    */
   virtual void GenerateTestFiles();
-  
+
+  /**
+   * Generate a manifest of target files that will be built.
+   */
+  virtual void GenerateTargetManifest(cmTargetManifest&);
 
   ///! Get the makefile for this generator
   cmMakefile *GetMakefile() {

+ 3 - 0
Source/cmTarget.h

@@ -346,4 +346,7 @@ private:
 
 typedef std::map<cmStdString,cmTarget> cmTargets;
 
+class cmTargetSet: public std::set<cmStdString> {};
+class cmTargetManifest: public std::map<cmStdString, cmTargetSet> {};
+
 #endif