From 2301a025ea1ed9a61cf0028f88b32f726162fbf7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 4 Apr 2006 11:48:19 -0400 Subject: [PATCH] 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. --- Source/cmGlobalGenerator.cxx | 13 ++++++-- Source/cmGlobalGenerator.h | 8 +++++ Source/cmLocalGenerator.cxx | 57 ++++++++++++++++++++++++++++++++++++ Source/cmLocalGenerator.h | 7 ++++- Source/cmTarget.h | 3 ++ 5 files changed, 85 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 6b6427758..9e9bbe422 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/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(); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index c5a5f78a1..3911d9e71 100644 --- a/Source/cmGlobalGenerator.h +++ b/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 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 diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 748bfe59b..9d65c2bf2 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -391,6 +391,63 @@ void cmLocalGenerator::GenerateInstallRules() } } +//---------------------------------------------------------------------------- +void cmLocalGenerator::GenerateTargetManifest(cmTargetManifest& manifest) +{ + // Collect the set of configuration types. + std::vector 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::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, diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 9a1df742b..a7e07403d 100644 --- a/Source/cmLocalGenerator.h +++ b/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() { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 067619a48..736bad587 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -346,4 +346,7 @@ private: typedef std::map cmTargets; +class cmTargetSet: public std::set {}; +class cmTargetManifest: public std::map {}; + #endif