From 2293d43d00ddcff86c70f0b06014223f3b01e36c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 16 Sep 2015 05:21:07 +0200 Subject: cmLocalGenerator: Store cmGeneratorTargets. Relieve cmMakefile of this responsibility. --- Source/cmCustomCommandGenerator.cxx | 2 +- Source/cmExportBuildFileGenerator.cxx | 2 +- Source/cmExtraEclipseCDT4Generator.cxx | 3 +-- Source/cmGeneratorExpressionNode.cxx | 4 ++-- Source/cmGeneratorTarget.cxx | 3 ++- Source/cmGlobalGenerator.cxx | 2 +- Source/cmGlobalGhsMultiGenerator.cxx | 2 +- Source/cmGlobalKdevelopGenerator.cxx | 3 +-- Source/cmGlobalUnixMakefileGenerator3.cxx | 6 +++--- Source/cmGlobalVisualStudio8Generator.cxx | 2 +- Source/cmGlobalVisualStudioGenerator.cxx | 4 ++-- Source/cmGlobalXCodeGenerator.cxx | 4 ++-- Source/cmLocalGenerator.cxx | 24 +++++++++++++++++++++--- Source/cmLocalGenerator.h | 14 ++++++++++++++ Source/cmLocalGhsMultiGenerator.cxx | 2 +- Source/cmLocalNinjaGenerator.cxx | 2 +- Source/cmLocalUnixMakefileGenerator3.cxx | 6 +++--- Source/cmMakefile.cxx | 17 ----------------- Source/cmMakefile.h | 14 -------------- Source/cmQtAutoGeneratorInitializer.cxx | 2 +- Source/cmTestGenerator.cxx | 2 +- 21 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 7f02afe..618f09f 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -43,7 +43,7 @@ std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const { std::string const& argv0 = this->CC.GetCommandLines()[c][0]; cmGeneratorTarget* target = - this->LG->GetMakefile()->FindGeneratorTargetToUse(argv0); + this->LG->FindGeneratorTargetToUse(argv0); if(target && target->GetType() == cmTarget::EXECUTABLE && (target->Target->IsImported() || !this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING"))) diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 560cfc5..6c3cccd 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -42,7 +42,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) tei = targets.begin(); tei != targets.end(); ++tei) { - cmGeneratorTarget *te = this->LG->GetMakefile() + cmGeneratorTarget *te = this->LG ->FindGeneratorTargetToUse(*tei); expectedTargets += sep + this->Namespace + te->Target->GetExportName(); sep = " "; diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index fdfa35e..b7aeb02 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -965,8 +965,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) { - cmGeneratorTargetsType targets = (*it)->GetMakefile() - ->GetGeneratorTargets(); + cmGeneratorTargetsType targets = (*it)->GetGeneratorTargets(); for (cmGeneratorTargetsType::iterator l = targets.begin(); l != targets.end(); ++l) { diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 2797d10..fe83b08 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1275,7 +1275,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode std::string tgtName = parameters.front(); cmGeneratorTarget* gt = - context->LG->GetMakefile()->FindGeneratorTargetToUse(tgtName); + context->LG->FindGeneratorTargetToUse(tgtName); if (!gt) { std::ostringstream e; @@ -1739,7 +1739,7 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode return std::string(); } cmGeneratorTarget* target = - context->LG->GetMakefile()->FindGeneratorTargetToUse(name); + context->LG->FindGeneratorTargetToUse(name); if(!target) { ::reportError(context, content->GetOriginalExpression(), diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6033efe..6bebc2b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -2305,7 +2305,8 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) // Check for a target with this name. if(cmGeneratorTarget* t - = this->Makefile->FindGeneratorTargetToUse(util)) + = this->GeneratorTarget-> + GetLocalGenerator()->FindGeneratorTargetToUse(util)) { // If we find the target and the dep was given as a full path, // then make sure it was not a full path to something else, and diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 9ac0019..e8be2d6 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1578,7 +1578,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, this->GeneratorTargets[*j] = gt; generatorTargets[*j] = gt; } - mf->SetGeneratorTargets(generatorTargets); + lg->SetGeneratorTargets(generatorTargets); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 87cf58f..45a1509 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -287,7 +287,7 @@ void cmGlobalGhsMultiGenerator::Generate() { cmLocalGhsMultiGenerator *lg = static_cast(this->LocalGenerators[i]); - cmGeneratorTargetsType tgts = lg->GetMakefile()->GetGeneratorTargets(); + cmGeneratorTargetsType tgts = lg->GetGeneratorTargets(); this->UpdateBuildFiles(&tgts); } } diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index f955ef7..ed36634 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -68,8 +68,7 @@ void cmGlobalKdevelopGenerator::Generate() for (std::vector::const_iterator lg=lgs.begin(); lg!=lgs.end(); lg++) { - cmMakefile* makefile=(*lg)->GetMakefile(); - cmGeneratorTargetsType const& targets = makefile->GetGeneratorTargets(); + cmGeneratorTargetsType const& targets = (*lg)->GetGeneratorTargets(); for (cmGeneratorTargetsType::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 218e702..f9740e5 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -461,7 +461,7 @@ cmGlobalUnixMakefileGenerator3 // The directory-level rule should depend on the target-level rules // for all targets in the directory. std::vector depends; - cmGeneratorTargetsType targets = lg->GetMakefile()->GetGeneratorTargets(); + cmGeneratorTargetsType targets = lg->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator l = targets.begin(); l != targets.end(); ++l) { @@ -627,7 +627,7 @@ cmGlobalUnixMakefileGenerator3 lg = static_cast (this->LocalGenerators[i]); // for each target Generate the rule files for each target. - cmGeneratorTargetsType targets = lg->GetMakefile()->GetGeneratorTargets(); + cmGeneratorTargetsType targets = lg->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { @@ -728,7 +728,7 @@ cmGlobalUnixMakefileGenerator3 depends.push_back("cmake_check_build_system"); // for each target Generate the rule files for each target. - cmGeneratorTargetsType targets = lg->GetMakefile()->GetGeneratorTargets(); + cmGeneratorTargetsType targets = lg->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 0bdb008..8cb7d24 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -256,7 +256,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() noCommandLines); cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); - mf->AddGeneratorTarget(tgt, gt); + lg->AddGeneratorTarget(tgt, gt); // Organize in the "predefined targets" folder: // diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 6a25ed0..fa9c606 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -87,7 +87,7 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() "Build all projects"); cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); - allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt); + gen[0]->AddGeneratorTarget(allBuild, gt); #if 0 // Can't activate this code because we want ALL_BUILD @@ -108,7 +108,7 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() i != gen.end(); ++i) { cmGeneratorTargetsType targets = - (*i)->GetMakefile()->GetGeneratorTargets(); + (*i)->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index bc67833..6291796 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -459,7 +459,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, "echo", "Build all projects"); cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); - mf->AddGeneratorTarget(allbuild, allBuildGt); + root->AddGeneratorTarget(allbuild, allBuildGt); // Refer to the main build configuration file for easy editing. std::string listfile = root->GetCurrentSourceDirectory(); @@ -494,7 +494,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, "make", "-f", file.c_str()); cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); - mf->AddGeneratorTarget(check, checkGt); + root->AddGeneratorTarget(check, checkGt); } // now make the allbuild depend on all the non-utility targets diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index f19d551..3691b41 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -132,7 +132,7 @@ void cmLocalGenerator::TraceDependencies() this->GlobalGenerator->CreateEvaluationSourceFiles(*ci); } // Generate the rule files for each target. - cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + cmGeneratorTargetsType targets = this->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { @@ -448,6 +448,13 @@ void cmLocalGenerator::GenerateInstallRules() } } + +void cmLocalGenerator::AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt) +{ + this->GeneratorTargets[t] = gt; + this->GetGlobalGenerator()->AddGeneratorTarget(t, gt); +} + //---------------------------------------------------------------------------- void cmLocalGenerator::ComputeTargetManifest() { @@ -460,7 +467,7 @@ void cmLocalGenerator::ComputeTargetManifest() } // Add our targets to the manifest for each configuration. - cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + cmGeneratorTargetsType targets = this->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { @@ -1767,6 +1774,17 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, } //---------------------------------------------------------------------------- +cmGeneratorTarget* +cmLocalGenerator::FindGeneratorTargetToUse(const std::string& name) const +{ + if (cmTarget *t = this->Makefile->FindTargetToUse(name)) + { + return this->GetGlobalGenerator()->GetGeneratorTarget(t); + } + return 0; +} + +//---------------------------------------------------------------------------- bool cmLocalGenerator::GetRealDependency(const std::string& inName, const std::string& config, std::string& dep) @@ -1792,7 +1810,7 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName, // Look for a CMake target with the given name. if(cmGeneratorTarget* target = - this->Makefile->FindGeneratorTargetToUse(name)) + this->FindGeneratorTargetToUse(name)) { // make sure it is not just a coincidence that the target name // found is part of the inName diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 758709a..97e3f88 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -112,6 +112,19 @@ public: bool forResponseFile = false, const std::string& config = ""); + const cmGeneratorTargetsType &GetGeneratorTargets() const + { + return this->GeneratorTargets; + } + + void SetGeneratorTargets(const cmGeneratorTargetsType &targets) + { + this->GeneratorTargets = targets; + } + void AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt); + + cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const; + /** * Encode a list of preprocessor definitions for the compiler * command line. @@ -354,6 +367,7 @@ protected: std::set ObjectMaxPathViolations; std::set WarnCMP0063; + cmGeneratorTargetsType GeneratorTargets; bool EmitUniversalBinaryFlags; diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx index bac989f..721f239 100644 --- a/Source/cmLocalGhsMultiGenerator.cxx +++ b/Source/cmLocalGhsMultiGenerator.cxx @@ -26,7 +26,7 @@ cmLocalGhsMultiGenerator::~cmLocalGhsMultiGenerator() {} void cmLocalGhsMultiGenerator::Generate() { - cmGeneratorTargetsType tgts = this->GetMakefile()->GetGeneratorTargets(); + cmGeneratorTargetsType tgts = this->GetGeneratorTargets(); for (cmGeneratorTargetsType::iterator l = tgts.begin(); l != tgts.end(); ++l) diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 6319f0e..8d71469 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -73,7 +73,7 @@ void cmLocalNinjaGenerator::Generate() } } - cmGeneratorTargetsType targets = this->GetMakefile()->GetGeneratorTargets(); + cmGeneratorTargetsType targets = this->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index bf5afc1..91c7acd 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -113,7 +113,7 @@ void cmLocalUnixMakefileGenerator3::Generate() this->Makefile->IsOn("CMAKE_SKIP_ASSEMBLY_SOURCE_RULES"); // Generate the rule files for each target. - cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + cmGeneratorTargetsType targets = this->GetGeneratorTargets(); cmGlobalUnixMakefileGenerator3* gg = static_cast(this->GlobalGenerator); for(cmGeneratorTargetsType::iterator t = targets.begin(); @@ -175,7 +175,7 @@ void cmLocalUnixMakefileGenerator3:: GetLocalObjectFiles(std::map &localObjectFiles) { std::set emitted; - cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + cmGeneratorTargetsType targets = this->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator ti = targets.begin(); ti != targets.end(); ++ti) { @@ -418,7 +418,7 @@ void cmLocalUnixMakefileGenerator3 // for each target we just provide a rule to cd up to the top and do a make // on the target - cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + cmGeneratorTargetsType targets = this->GetGeneratorTargets(); std::string localName; for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f2f7ee7..8ac6358 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1812,12 +1812,6 @@ const char* cmMakefile::GetCurrentBinaryDirectory() const return this->StateSnapshot.GetDirectory().GetCurrentBinary(); } -void cmMakefile::AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt) -{ - this->GeneratorTargets[t] = gt; - this->GetGlobalGenerator()->AddGeneratorTarget(t, gt); -} - //---------------------------------------------------------------------------- void cmMakefile::AddIncludeDirectories(const std::vector &incs, bool before) @@ -4321,17 +4315,6 @@ bool cmMakefile::IsAlias(const std::string& name) const } //---------------------------------------------------------------------------- -cmGeneratorTarget* -cmMakefile::FindGeneratorTargetToUse(const std::string& name) const -{ - if (cmTarget *t = this->FindTargetToUse(name)) - { - return this->GetGlobalGenerator()->GetGeneratorTarget(t); - } - return 0; -} - -//---------------------------------------------------------------------------- bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, bool isCustom) const { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 46fdc94..8fe0bda 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -17,7 +17,6 @@ #include "cmSystemTools.h" #include "cmTarget.h" #include "cmNewLineStyle.h" -#include "cmGeneratorTarget.h" #include "cmExpandedCommandArgument.h" #include "cmake.h" #include "cmState.h" @@ -393,17 +392,6 @@ public: return this->ImportedTargetsOwned; } - const cmGeneratorTargetsType &GetGeneratorTargets() const - { - return this->GeneratorTargets; - } - - void SetGeneratorTargets(const cmGeneratorTargetsType &targets) - { - this->GeneratorTargets = targets; - } - void AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt); - cmTarget* FindTarget(const std::string& name, bool excludeAliases = false) const; @@ -412,7 +400,6 @@ public: cmTarget* FindTargetToUse(const std::string& name, bool excludeAliases = false) const; bool IsAlias(const std::string& name) const; - cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const; /** * Mark include directories as system directories. @@ -816,7 +803,6 @@ protected: typedef std::map TargetMap; #endif TargetMap AliasTargets; - cmGeneratorTargetsType GeneratorTargets; std::vector SourceFiles; // Tests diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 6e3f65f..f9875b3 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -886,7 +886,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( commandLines, false, autogenComment.c_str()); cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); - makefile->AddGeneratorTarget(autogenTarget, gt); + lg->AddGeneratorTarget(autogenTarget, gt); // Set target folder const char* autogenFolder = makefile->GetState() diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 7dec50b..85fb405 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -89,7 +89,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // be translated. std::string exe = command[0]; cmGeneratorTarget* target = - this->LG->GetMakefile()->FindGeneratorTargetToUse(exe); + this->LG->FindGeneratorTargetToUse(exe); if(target && target->GetType() == cmTarget::EXECUTABLE) { // Use the target file on disk. -- cgit v0.12