summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-03-07 16:50:41 (GMT)
committerBrad King <brad.king@kitware.com>2012-03-09 20:16:02 (GMT)
commit4b245580913e02ba577d6eb7825866300d364b53 (patch)
treea2b47ef4b515cd77fa20bc981ccf1f973918a066
parent11d9b211266865f0ce4a1005bbb18748c0806bce (diff)
downloadCMake-4b245580913e02ba577d6eb7825866300d364b53.zip
CMake-4b245580913e02ba577d6eb7825866300d364b53.tar.gz
CMake-4b245580913e02ba577d6eb7825866300d364b53.tar.bz2
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.
-rw-r--r--Source/cmGlobalGenerator.cxx47
-rw-r--r--Source/cmGlobalGenerator.h10
2 files changed, 57 insertions, 0 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index a988844..a1f80d9 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 <cmsys/Directory.hxx>
@@ -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 1a0e41a..b94cc6c 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<cmStdString, std::vector<cmLocalGenerator*> >& GetProjectMap()
const {return this->ProjectMap;}
@@ -370,6 +374,12 @@ private:
typedef std::map<cmTarget *, TargetDependSet> TargetDependMap;
TargetDependMap TargetDependencies;
+ // Per-target generator information.
+ typedef std::map<cmTarget*, cmGeneratorTarget*> GeneratorTargetsType;
+ GeneratorTargetsType GeneratorTargets;
+ void CreateGeneratorTargets();
+ void ClearGeneratorTargets();
+
// Cache directory content and target files to be built.
struct DirectoryContent: public std::set<cmStdString>
{