From 4b245580913e02ba577d6eb7825866300d364b53 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 7 Mar 2012 11:50:41 -0500 Subject: [PATCH] Create a cmGeneratorTarget for each cmTarget during generation Construct the instances after the final set of targets is known but before computing inter-target dependencies. This order will allow initialization of cmGeneratorTarget instances to adjust and finalize declared inter-target dependencies. --- Source/cmGlobalGenerator.cxx | 47 ++++++++++++++++++++++++++++++++++++ Source/cmGlobalGenerator.h | 10 ++++++++ 2 files changed, 57 insertions(+) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a98884447..a1f80d934 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -24,6 +24,7 @@ #include "cmExportInstallFileGenerator.h" #include "cmComputeTargetDepends.h" #include "cmGeneratedFileStream.h" +#include "cmGeneratorTarget.h" #include @@ -74,6 +75,7 @@ cmGlobalGenerator::~cmGlobalGenerator() delete this->ExtraGenerator; } + this->ClearGeneratorTargets(); this->ClearExportSets(); } @@ -807,6 +809,7 @@ bool cmGlobalGenerator::IsDependedOn(const char* project, void cmGlobalGenerator::Configure() { this->FirstTimeProgress = 0.0f; + this->ClearGeneratorTargets(); this->ClearExportSets(); // Delete any existing cmLocalGenerators unsigned int i; @@ -947,6 +950,9 @@ void cmGlobalGenerator::Generate() this->LocalGenerators[i]->GenerateTargetManifest(); } + // Create per-target generator information. + this->CreateGeneratorTargets(); + // Compute the inter-target dependencies. if(!this->ComputeTargetDepends()) { @@ -1056,6 +1062,47 @@ void cmGlobalGenerator::CreateAutomocTargets() #endif } +//---------------------------------------------------------------------------- +void cmGlobalGenerator::CreateGeneratorTargets() +{ + // Construct per-target generator information. + for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) + { + cmTargets& targets = + this->LocalGenerators[i]->GetMakefile()->GetTargets(); + for(cmTargets::iterator ti = targets.begin(); + ti != targets.end(); ++ti) + { + cmTarget* t = &ti->second; + this->GeneratorTargets[t] = new cmGeneratorTarget(t); + } + } +} + +//---------------------------------------------------------------------------- +void cmGlobalGenerator::ClearGeneratorTargets() +{ + for(GeneratorTargetsType::iterator i = this->GeneratorTargets.begin(); + i != this->GeneratorTargets.end(); ++i) + { + delete i->second; + } + this->GeneratorTargets.clear(); +} + +//---------------------------------------------------------------------------- +cmGeneratorTarget* cmGlobalGenerator::GetGeneratorTarget(cmTarget* t) const +{ + GeneratorTargetsType::const_iterator ti = this->GeneratorTargets.find(t); + if(ti == this->GeneratorTargets.end()) + { + this->CMakeInstance->IssueMessage( + cmake::INTERNAL_ERROR, "Missing cmGeneratorTarget instance!", + cmListFileBacktrace()); + return 0; + } + return ti->second; +} void cmGlobalGenerator::CheckLocalGenerators() { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 1a0e41a0f..b94cc6c57 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -19,6 +19,7 @@ #include "cmTargetDepend.h" // For cmTargetDependSet #include "cmSystemTools.h" // for cmSystemTools::OutputOption class cmake; +class cmGeneratorTarget; class cmMakefile; class cmLocalGenerator; class cmExternalMakefileProjectGenerator; @@ -251,6 +252,9 @@ public: // via a target_link_libraries or add_dependencies TargetDependSet const& GetTargetDirectDepends(cmTarget & target); + /** Get per-target generator information. */ + cmGeneratorTarget* GetGeneratorTarget(cmTarget*) const; + const std::map >& GetProjectMap() const {return this->ProjectMap;} @@ -370,6 +374,12 @@ private: typedef std::map TargetDependMap; TargetDependMap TargetDependencies; + // Per-target generator information. + typedef std::map GeneratorTargetsType; + GeneratorTargetsType GeneratorTargets; + void CreateGeneratorTargets(); + void ClearGeneratorTargets(); + // Cache directory content and target files to be built. struct DirectoryContent: public std::set {