From d568eefe104e480706a2e6ceb16df4376d4becbf Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Jul 2015 17:52:10 +0200 Subject: cmCustomCommandGenerator: Require cmLocalGenerator in API. --- Source/cmCustomCommandGenerator.cxx | 22 +++++++++++++--------- Source/cmCustomCommandGenerator.h | 6 +++--- Source/cmGeneratorTarget.cxx | 3 ++- Source/cmGlobalXCodeGenerator.cxx | 4 ++-- Source/cmLocalNinjaGenerator.cxx | 2 +- Source/cmLocalUnixMakefileGenerator3.cxx | 6 ++---- Source/cmLocalVisualStudio6Generator.cxx | 4 ++-- Source/cmLocalVisualStudio7Generator.cxx | 4 ++-- Source/cmMakefileTargetGenerator.cxx | 5 +++-- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.cxx | 2 +- Source/cmNinjaUtilityTargetGenerator.cxx | 4 ++-- Source/cmVisualStudio10TargetGenerator.cxx | 4 ++-- 13 files changed, 36 insertions(+), 32 deletions(-) diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index f654eb9..8483a91 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -12,14 +12,15 @@ #include "cmCustomCommandGenerator.h" #include "cmMakefile.h" +#include "cmLocalGenerator.h" #include "cmCustomCommand.h" #include "cmOutputConverter.h" #include "cmGeneratorExpression.h" //---------------------------------------------------------------------------- cmCustomCommandGenerator::cmCustomCommandGenerator( - cmCustomCommand const& cc, const std::string& config, cmMakefile* mf): - CC(cc), Config(config), Makefile(mf), + cmCustomCommand const& cc, const std::string& config, cmLocalGenerator* lg): + CC(cc), Config(config), LG(lg), OldStyle(cc.GetEscapeOldStyle()), MakeVars(cc.GetEscapeAllowMakeVars()), GE(new cmGeneratorExpression(cc.GetBacktrace())), DependsDone(false) { @@ -41,13 +42,15 @@ unsigned int cmCustomCommandGenerator::GetNumberOfCommands() const std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const { std::string const& argv0 = this->CC.GetCommandLines()[c][0]; - cmTarget* target = this->Makefile->FindTargetToUse(argv0); + cmTarget* target = this->LG->GetMakefile()->FindTargetToUse(argv0); if(target && target->GetType() == cmTarget::EXECUTABLE && - (target->IsImported() || !this->Makefile->IsOn("CMAKE_CROSSCOMPILING"))) + (target->IsImported() + || !this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING"))) { return target->GetLocation(this->Config); } - return this->GE->Parse(argv0)->Evaluate(this->Makefile, this->Config); + return this->GE->Parse(argv0)->Evaluate(this->LG->GetMakefile(), + this->Config); } //---------------------------------------------------------------------------- @@ -87,8 +90,9 @@ cmCustomCommandGenerator cmCustomCommandLine const& commandLine = this->CC.GetCommandLines()[c]; for(unsigned int j=1;j < commandLine.size(); ++j) { - std::string arg = this->GE->Parse(commandLine[j])->Evaluate(this->Makefile, - this->Config); + std::string arg = + this->GE->Parse(commandLine[j])->Evaluate(this->LG->GetMakefile(), + this->Config); cmd += " "; if(this->OldStyle) { @@ -96,7 +100,7 @@ cmCustomCommandGenerator } else { - cmOutputConverter converter(this->Makefile->GetStateSnapshot()); + cmOutputConverter converter(this->LG->GetMakefile()->GetStateSnapshot()); cmd += converter.EscapeForShell(arg, this->MakeVars); } } @@ -141,7 +145,7 @@ std::vector const& cmCustomCommandGenerator::GetDepends() const = this->GE->Parse(*i); std::vector result; cmSystemTools::ExpandListArgument( - cge->Evaluate(this->Makefile, this->Config), result); + cge->Evaluate(this->LG->GetMakefile(), this->Config), result); for (std::vector::iterator it = result.begin(); it != result.end(); ++it) { diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h index 7ad95d1..a637fed 100644 --- a/Source/cmCustomCommandGenerator.h +++ b/Source/cmCustomCommandGenerator.h @@ -15,14 +15,14 @@ #include "cmStandardIncludes.h" class cmCustomCommand; -class cmMakefile; +class cmLocalGenerator; class cmGeneratorExpression; class cmCustomCommandGenerator { cmCustomCommand const& CC; std::string Config; - cmMakefile* Makefile; + cmLocalGenerator* LG; bool OldStyle; bool MakeVars; cmGeneratorExpression* GE; @@ -31,7 +31,7 @@ class cmCustomCommandGenerator public: cmCustomCommandGenerator(cmCustomCommand const& cc, const std::string& config, - cmMakefile* mf); + cmLocalGenerator* lg); ~cmCustomCommandGenerator(); cmCustomCommand const& GetCC() const { return this->CC; } unsigned int GetNumberOfCommands() const; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e6f7a43..dc5a2a1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -938,7 +938,8 @@ void cmTargetTraceDependencies::FollowCommandDepends(cmCustomCommand const& cc, const std::string& config, std::set& emitted) { - cmCustomCommandGenerator ccg(cc, config, this->Makefile); + cmCustomCommandGenerator ccg(cc, config, + this->GeneratorTarget->LocalGenerator); const std::vector& depends = ccg.GetDepends(); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 21075bb..6e46bc0 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1668,7 +1668,7 @@ void cmGlobalXCodeGenerator for(std::vector::const_iterator i = commands.begin(); i != commands.end(); ++i) { - cmCustomCommandGenerator ccg(*i, configName, this->CurrentMakefile); + cmCustomCommandGenerator ccg(*i, configName, this->CurrentLocalGenerator); if(ccg.GetNumberOfCommands() > 0) { const std::vector& outputs = ccg.GetOutputs(); @@ -1694,7 +1694,7 @@ void cmGlobalXCodeGenerator for(std::vector::const_iterator i = commands.begin(); i != commands.end(); ++i) { - cmCustomCommandGenerator ccg(*i, configName, this->CurrentMakefile); + cmCustomCommandGenerator ccg(*i, configName, this->CurrentLocalGenerator); if(ccg.GetNumberOfCommands() > 0) { makefileStream << "\n"; diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index a293d06..9889bd4 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -404,7 +404,7 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc)) return; - cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile); + cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this); const std::vector &outputs = ccg.GetOutputs(); const std::vector &byproducts = ccg.GetByproducts(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 077d4d9..de86c6b 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1007,8 +1007,7 @@ cmLocalUnixMakefileGenerator3 for(std::vector::const_iterator i = ccs.begin(); i != ccs.end(); ++i) { - cmCustomCommandGenerator ccg(*i, this->ConfigName, - this->Makefile); + cmCustomCommandGenerator ccg(*i, this->ConfigName, this); this->AppendCustomDepend(depends, ccg); } } @@ -1043,8 +1042,7 @@ cmLocalUnixMakefileGenerator3 for(std::vector::const_iterator i = ccs.begin(); i != ccs.end(); ++i) { - cmCustomCommandGenerator ccg(*i, this->ConfigName, - this->Makefile); + cmCustomCommandGenerator ccg(*i, this->ConfigName, this); this->AppendCustomCommand(commands, ccg, target, true, relative); } } diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index a26a1dd..9263053 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -62,7 +62,7 @@ public: } void Write(cmCustomCommand const& cc) { - cmCustomCommandGenerator ccg(cc, this->Config, this->LG->GetMakefile()); + cmCustomCommandGenerator ccg(cc, this->Config, this->LG); if(this->First) { this->Code += this->Event + "_Cmds="; @@ -625,7 +625,7 @@ cmLocalVisualStudio6Generator for(i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { std::string config = this->GetConfigName(*i); - cmCustomCommandGenerator ccg(command, config, this->Makefile); + cmCustomCommandGenerator ccg(command, config, this); std::string comment = this->ConstructComment(ccg, "Building Custom Rule $(InputPath)"); if(comment == "") diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 0e5e7a5..bf82c87 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -619,7 +619,7 @@ public: } void Write(cmCustomCommand const& cc) { - cmCustomCommandGenerator ccg(cc, this->Config, this->LG->GetMakefile()); + cmCustomCommandGenerator ccg(cc, this->Config, this->LG); if(this->First) { const char* comment = ccg.GetComment(); @@ -1903,7 +1903,7 @@ WriteCustomRule(std::ostream& fout, for (std::vector::const_iterator i = configs.begin(); i != configs.end(); ++i) { - cmCustomCommandGenerator ccg(command, *i, this->Makefile); + cmCustomCommandGenerator ccg(command, *i, this); cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i]; fout << "\t\t\t\tGetCustomCommand(), this->ConfigName, - this->Makefile); + this->LocalGenerator); this->GenerateCustomRuleFile(ccg); if (clean) { @@ -1182,7 +1182,8 @@ cmMakefileTargetGenerator { if(cmCustomCommand* cc = (*source)->GetCustomCommand()) { - cmCustomCommandGenerator ccg(*cc, this->ConfigName, this->Makefile); + cmCustomCommandGenerator ccg(*cc, this->ConfigName, + this->LocalGenerator); const std::vector& outputs = ccg.GetOutputs(); depends.insert(depends.end(), outputs.begin(), outputs.end()); } diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 88da09b..ea2816b 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -608,7 +608,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) { - cmCustomCommandGenerator ccg(*ci, cfgName, mf); + cmCustomCommandGenerator ccg(*ci, cfgName, this->GetLocalGenerator()); localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]); std::vector const& ccByproducts = ccg.GetByproducts(); std::transform(ccByproducts.begin(), ccByproducts.end(), diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 74f262c..1479d0b 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -509,7 +509,7 @@ cmNinjaTargetGenerator { cmCustomCommand const* cc = *cci; cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), - this->GetMakefile()); + this->GetLocalGenerator()); const std::vector& ccoutputs = ccg.GetOutputs(); const std::vector& ccbyproducts= ccg.GetByproducts(); std::transform(ccoutputs.begin(), ccoutputs.end(), diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index c3bf011..58b901a 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -44,7 +44,7 @@ void cmNinjaUtilityTargetGenerator::Generate() for (std::vector::const_iterator ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) { cmCustomCommandGenerator ccg(*ci, this->GetConfigName(), - this->GetMakefile()); + this->GetLocalGenerator()); this->GetLocalGenerator()->AppendCustomCommandDeps(ccg, deps); this->GetLocalGenerator()->AppendCustomCommandLines(ccg, commands); std::vector const& ccByproducts = ccg.GetByproducts(); @@ -65,7 +65,7 @@ void cmNinjaUtilityTargetGenerator::Generate() if(cmCustomCommand* cc = (*source)->GetCustomCommand()) { cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), - this->GetMakefile()); + this->GetLocalGenerator()); this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget()); // Depend on all custom command outputs. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 67d52b8..71785e9 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -890,7 +890,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source, i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { - cmCustomCommandGenerator ccg(command, *i, this->Makefile); + cmCustomCommandGenerator ccg(command, *i, this->LocalGenerator); std::string comment = lg->ConstructComment(ccg); comment = cmVS10EscapeComment(comment); std::string script = @@ -2794,7 +2794,7 @@ void cmVisualStudio10TargetGenerator::WriteEvent( for(std::vector::const_iterator i = commands.begin(); i != commands.end(); ++i) { - cmCustomCommandGenerator ccg(*i, configName, this->Makefile); + cmCustomCommandGenerator ccg(*i, configName, this->LocalGenerator); comment += pre; comment += lg->ConstructComment(ccg); script += pre; -- cgit v0.12 From a8e5d838edcb692ff69c2073cf692d7067f52c67 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Jul 2015 17:55:34 +0200 Subject: cmCPackPropertiesGenerator: Require cmLocalGenerator in API. --- Source/cmCPackPropertiesGenerator.cxx | 10 ++++++---- Source/cmCPackPropertiesGenerator.h | 6 ++++-- Source/cmGlobalGenerator.cxx | 5 +++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Source/cmCPackPropertiesGenerator.cxx b/Source/cmCPackPropertiesGenerator.cxx index 368a0e6..cbcdd81 100644 --- a/Source/cmCPackPropertiesGenerator.cxx +++ b/Source/cmCPackPropertiesGenerator.cxx @@ -1,13 +1,14 @@ #include "cmCPackPropertiesGenerator.h" #include "cmOutputConverter.h" +#include "cmLocalGenerator.h" cmCPackPropertiesGenerator::cmCPackPropertiesGenerator( - cmMakefile* mf, + cmLocalGenerator* lg, cmInstalledFile const& installedFile, std::vector const& configurations): cmScriptGenerator("CPACK_BUILD_CONFIG", configurations), - Makefile(mf), + LG(lg), InstalledFile(installedFile) { this->ActionsPerConfig = true; @@ -17,7 +18,8 @@ void cmCPackPropertiesGenerator::GenerateScriptForConfig(std::ostream& os, const std::string& config, Indent const& indent) { std::string const& expandedFileName = - this->InstalledFile.GetNameExpression().Evaluate(this->Makefile, config); + this->InstalledFile.GetNameExpression().Evaluate(this->LG->GetMakefile(), + config); cmInstalledFile::PropertyMapType const& properties = this->InstalledFile.GetProperties(); @@ -36,7 +38,7 @@ void cmCPackPropertiesGenerator::GenerateScriptForConfig(std::ostream& os, j = property.ValueExpressions.begin(); j != property.ValueExpressions.end(); ++j) { - std::string value = (*j)->Evaluate(this->Makefile, config); + std::string value = (*j)->Evaluate(LG->GetMakefile(), config); os << " " << cmOutputConverter::EscapeForCMake(value); } diff --git a/Source/cmCPackPropertiesGenerator.h b/Source/cmCPackPropertiesGenerator.h index 71e2eaa..eec3df0 100644 --- a/Source/cmCPackPropertiesGenerator.h +++ b/Source/cmCPackPropertiesGenerator.h @@ -15,6 +15,8 @@ #include "cmScriptGenerator.h" #include "cmInstalledFile.h" +class cmLocalGenerator; + /** \class cmCPackPropertiesGenerator * \brief Support class for generating CPackProperties.cmake. * @@ -23,7 +25,7 @@ class cmCPackPropertiesGenerator: public cmScriptGenerator { public: cmCPackPropertiesGenerator( - cmMakefile* mf, + cmLocalGenerator* lg, cmInstalledFile const& installedFile, std::vector const& configurations); @@ -31,7 +33,7 @@ protected: virtual void GenerateScriptForConfig(std::ostream& os, const std::string& config, Indent const& indent); - cmMakefile* Makefile; + cmLocalGenerator* LG; cmInstalledFile const& InstalledFile; }; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 88ac0bc..fcb5998 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -3050,7 +3050,8 @@ bool cmGlobalGenerator::GenerateCPackPropertiesFile() cmake::InstalledFilesMap const& installedFiles = this->CMakeInstance->GetInstalledFiles(); - cmMakefile* mf = this->LocalGenerators[0]->GetMakefile(); + cmLocalGenerator* lg = this->LocalGenerators[0]; + cmMakefile* mf = lg->GetMakefile(); std::vector configs; std::string config = mf->GetConfigurations(configs, false); @@ -3072,7 +3073,7 @@ bool cmGlobalGenerator::GenerateCPackPropertiesFile() cmInstalledFile const& installedFile = i->second; cmCPackPropertiesGenerator cpackPropertiesGenerator( - mf, installedFile, configs); + lg, installedFile, configs); cpackPropertiesGenerator.Generate(file, config, configs); } -- cgit v0.12 From 0e0258c8b9c6cab7c55c90687b30d65a83783c2f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Jul 2015 19:58:20 +0200 Subject: cmGlobalGenerator: Split creation of generator object from initialization. --- Source/cmGlobalGenerator.cxx | 15 ++++++++++++++- Source/cmGlobalGenerator.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index fcb5998..45ef399 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1242,6 +1242,7 @@ void cmGlobalGenerator::Generate() // Create per-target generator information. this->CreateGeneratorTargets(); + this->InitGeneratorTargets(); #ifdef CMAKE_BUILD_WITH_CMAKE for (AutogensType::iterator it = autogens.begin(); it != autogens.end(); @@ -1471,7 +1472,6 @@ void cmGlobalGenerator::CreateGeneratorTargets(cmLocalGenerator *lg) { cmTarget* t = &ti->second; cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); - this->ComputeTargetObjectDirectory(gt); this->GeneratorTargets[t] = gt; generatorTargets[t] = gt; } @@ -1488,6 +1488,19 @@ void cmGlobalGenerator::CreateGeneratorTargets(cmLocalGenerator *lg) } //---------------------------------------------------------------------------- +void cmGlobalGenerator::InitGeneratorTargets() +{ + for(cmGeneratorTargetsType::iterator ti = + this->GeneratorTargets.begin(); ti != this->GeneratorTargets.end(); ++ti) + { + if (!ti->second->Target->IsImported()) + { + this->ComputeTargetObjectDirectory(ti->second); + } + } +} + +//---------------------------------------------------------------------------- void cmGlobalGenerator::CreateGeneratorTargets() { // Construct per-target generator information. diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 398335b..b9a32bf 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -485,6 +485,7 @@ private: cmGeneratorTargetsType GeneratorTargets; friend class cmake; void CreateGeneratorTargets(cmLocalGenerator* lg); + void InitGeneratorTargets(); void CreateGeneratorTargets(); void ClearGeneratorMembers(); -- cgit v0.12 From 57a69f934173eceaaf87e15074baf4e19402a687 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Jul 2015 20:00:27 +0200 Subject: cmGlobalGenerator: Extract method to create generator objects. --- Source/cmGlobalGenerator.cxx | 10 ++++++++-- Source/cmGlobalGenerator.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 45ef399..8550d0d 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1151,6 +1151,13 @@ void cmGlobalGenerator::Configure() } } +void cmGlobalGenerator::CreateGenerationObjects() +{ + cmDeleteAll(this->GeneratorTargets); + this->GeneratorTargets.clear(); + this->CreateGeneratorTargets(); +} + cmExportBuildFileGenerator* cmGlobalGenerator::GetExportedTargetsFile(const std::string &filename) const { @@ -1240,8 +1247,7 @@ void cmGlobalGenerator::Generate() this->LocalGenerators[i]->AddHelperCommands(); } - // Create per-target generator information. - this->CreateGeneratorTargets(); + this->CreateGenerationObjects(); this->InitGeneratorTargets(); #ifdef CMAKE_BUILD_WITH_CMAKE diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index b9a32bf..7d9bb4c 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -86,6 +86,8 @@ public: */ virtual void Configure(); + void CreateGenerationObjects(); + /** * Generate the all required files for building this project/tree. This * basically creates a series of LocalGenerators for each directory and -- cgit v0.12 From 58811998fb63975cc92abab23044630bc11cd26d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Jul 2015 20:42:28 +0200 Subject: cmGlobalGenerator: Add global targets at the end of Configure. Rather than at the start of Generate. --- Source/cmGlobalGenerator.cxx | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 8550d0d..f5ddd10 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1149,6 +1149,25 @@ void cmGlobalGenerator::Configure() } this->CMakeInstance->UpdateProgress(msg.str().c_str(), -1); } + + unsigned int i; + + // Put a copy of each global target in every directory. + cmTargets globalTargets; + this->CreateDefaultGlobalTargets(&globalTargets); + + for (i = 0; i < this->LocalGenerators.size(); ++i) + { + cmMakefile* mf = this->LocalGenerators[i]->GetMakefile(); + cmTargets* targets = &(mf->GetTargets()); + cmTargets::iterator tit; + for ( tit = globalTargets.begin(); tit != globalTargets.end(); ++ tit ) + { + (*targets)[tit->first] = tit->second; + (*targets)[tit->first].SetMakefile(mf); + } + } + } void cmGlobalGenerator::CreateGenerationObjects() @@ -1222,23 +1241,11 @@ void cmGlobalGenerator::Generate() this->CreateQtAutoGeneratorsTargets(autogens); #endif - // For each existing cmLocalGenerator unsigned int i; - // Put a copy of each global target in every directory. - cmTargets globalTargets; - this->CreateDefaultGlobalTargets(&globalTargets); for (i = 0; i < this->LocalGenerators.size(); ++i) { this->LocalGenerators[i]->ComputeObjectMaxPath(); - cmMakefile* mf = this->LocalGenerators[i]->GetMakefile(); - cmTargets* targets = &(mf->GetTargets()); - cmTargets::iterator tit; - for ( tit = globalTargets.begin(); tit != globalTargets.end(); ++ tit ) - { - (*targets)[tit->first] = tit->second; - (*targets)[tit->first].SetMakefile(mf); - } } // Add generator specific helper commands @@ -1384,6 +1391,10 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens) for(cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) { + if (ti->second.GetType() == cmTarget::GLOBAL_TARGET) + { + continue; + } targetNames.push_back(ti->second.GetName()); } for(std::vector::iterator ti = targetNames.begin(); @@ -1432,6 +1443,10 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() ti != targets.end(); ++ti) { cmTarget* t = &ti->second; + if (t->GetType() == cmTarget::GLOBAL_TARGET) + { + continue; + } t->AppendBuildInterfaceIncludes(); -- cgit v0.12 From 72f43fa13ddb544f84891f14619e622baf29ae38 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 26 Jul 2015 10:11:44 +0200 Subject: cmLocalGenerator: Remove CreateCustomTargetsAndCommands method. It loops over cmGeneratorTargets, but at the point it is called, there are no cmGeneratorTargets. This must be dead code. --- Source/cmLocalGenerator.cxx | 42 -------------------------------- Source/cmLocalGenerator.h | 6 ----- Source/cmLocalVisualStudio6Generator.cxx | 8 ------ Source/cmLocalVisualStudio6Generator.h | 1 - Source/cmLocalVisualStudio7Generator.cxx | 9 ------- 5 files changed, 66 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7e4b470..25f33d7 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -626,48 +626,6 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, target.Target->AddSource(targetFullPath); } - -void cmLocalGenerator -::CreateCustomTargetsAndCommands(std::set const& lang) -{ - cmGeneratorTargetsType tgts = this->Makefile->GetGeneratorTargets(); - for(cmGeneratorTargetsType::iterator l = tgts.begin(); - l != tgts.end(); l++) - { - if (l->first->IsImported()) - { - continue; - } - cmGeneratorTarget& target = *l->second; - switch(target.GetType()) - { - case cmTarget::STATIC_LIBRARY: - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: - case cmTarget::EXECUTABLE: - { - std::string llang = target.Target->GetLinkerLanguage(); - if(llang.empty()) - { - cmSystemTools::Error - ("CMake can not determine linker language for target: ", - target.Target->GetName().c_str()); - return; - } - // if the language is not in the set lang then create custom - // commands to build the target - if(lang.count(llang) == 0) - { - this->AddBuildTargetRule(llang, target); - } - } - break; - default: - break; - } - } -} - // List of variables that are replaced when // rules are expanced. These variables are // replaced in the form with GetSafeDefinition(var). diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 2dfe825..fee2420 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -338,12 +338,6 @@ protected: const std::string& lang, cmSourceFile& source, cmGeneratorTarget& target); - // Create Custom Targets and commands for unsupported languages - // The set passed in should contain the languages supported by the - // generator directly. Any targets containing files that are not - // of the types listed will be compiled as custom commands and added - // to a custom target. - void CreateCustomTargetsAndCommands(std::set const&); // Handle old-style install rules stored in the targets. void GenerateTargetInstallRules( diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 9263053..f1c8def 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -82,14 +82,6 @@ private: std::string Event; }; -void cmLocalVisualStudio6Generator::AddHelperCommands() -{ - std::set lang; - lang.insert("C"); - lang.insert("CXX"); - this->CreateCustomTargetsAndCommands(lang); -} - void cmLocalVisualStudio6Generator::AddCMakeListsRules() { cmTargets &tgts = this->Makefile->GetTargets(); diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h index 8f4d521..a44e61d 100644 --- a/Source/cmLocalVisualStudio6Generator.h +++ b/Source/cmLocalVisualStudio6Generator.h @@ -35,7 +35,6 @@ public: virtual ~cmLocalVisualStudio6Generator(); - virtual void AddHelperCommands(); virtual void AddCMakeListsRules(); /** diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index bf82c87..f199a41 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -68,15 +68,6 @@ cmLocalVisualStudio7Generator::~cmLocalVisualStudio7Generator() void cmLocalVisualStudio7Generator::AddHelperCommands() { - std::set lang; - lang.insert("C"); - lang.insert("CXX"); - lang.insert("RC"); - lang.insert("IDL"); - lang.insert("DEF"); - lang.insert("Fortran"); - this->CreateCustomTargetsAndCommands(lang); - // Now create GUIDs for targets cmTargets &tgts = this->Makefile->GetTargets(); -- cgit v0.12 From e4dc83ade5f8b44d44f21d3f90185bf0264e5d9d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 27 Jul 2015 20:57:39 +0200 Subject: cmLocalGenerator: Remove unused AddBuildTargetRule method. --- Source/cmLocalGenerator.cxx | 100 -------------------------------------------- Source/cmLocalGenerator.h | 5 --- 2 files changed, 105 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 25f33d7..cce10ce 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -526,106 +526,6 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, ); } -void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, - cmGeneratorTarget& target) -{ - std::string objs; - std::vector objVector; - std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - // Add all the sources outputs to the depends of the target - std::vector classes; - target.GetSourceFiles(classes, config); - for(std::vector::const_iterator i = classes.begin(); - i != classes.end(); ++i) - { - cmSourceFile* sf = *i; - if(!sf->GetCustomCommand() && - !sf->GetPropertyAsBool("HEADER_FILE_ONLY") && - !sf->GetPropertyAsBool("EXTERNAL_OBJECT")) - { - std::string dir_max; - dir_max += this->StateSnapshot.GetDirectory().GetCurrentBinary(); - dir_max += "/"; - std::string obj = this->GetObjectFileNameWithoutTarget(*sf, dir_max); - if(!obj.empty()) - { - std::string ofname = - this->StateSnapshot.GetDirectory().GetCurrentBinary(); - ofname += "/"; - ofname += obj; - objVector.push_back(ofname); - this->AddCustomCommandToCreateObject(ofname.c_str(), - llang, *(*i), target); - objs += this->Convert(ofname,START_OUTPUT,SHELL); - objs += " "; - } - } - } - std::string createRule = target.GetCreateRuleVariable(llang, config); - bool useWatcomQuote = this->Makefile->IsOn(createRule+"_USE_WATCOM_QUOTE"); - std::string targetName = target.Target->GetFullName(); - // Executable : - // Shared Library: - // Static Library: - // Shared Module: - std::string linkLibs; // should be set - std::string frameworkPath; - std::string linkPath; - std::string flags; // should be set - std::string linkFlags; // should be set - this->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags, - &target, useWatcomQuote); - linkLibs = frameworkPath + linkPath + linkLibs; - cmLocalGenerator::RuleVariables vars; - vars.Language = llang.c_str(); - vars.Objects = objs.c_str(); - vars.ObjectDir = "."; - vars.Target = targetName.c_str(); - vars.LinkLibraries = linkLibs.c_str(); - vars.Flags = flags.c_str(); - vars.LinkFlags = linkFlags.c_str(); - - std::string langFlags; - this->AddLanguageFlags(langFlags, llang, ""); - this->AddArchitectureFlags(langFlags, &target, llang, ""); - vars.LanguageCompileFlags = langFlags.c_str(); - - cmCustomCommandLines commandLines; - std::vector rules; - rules.push_back(this->Makefile->GetRequiredDefinition(createRule)); - std::vector commands; - cmSystemTools::ExpandList(rules, commands); - for(std::vector::iterator i = commands.begin(); - i != commands.end(); ++i) - { - // Expand the full command line string. - this->ExpandRuleVariables(*i, vars); - // Parse the string to get the custom command line. - cmCustomCommandLine commandLine; - std::vector cmd = cmSystemTools::ParseArguments(i->c_str()); - commandLine.insert(commandLine.end(), cmd.begin(), cmd.end()); - - // Store this command line. - commandLines.push_back(commandLine); - } - std::string targetFullPath = target.Target->GetFullPath(); - // Generate a meaningful comment for the command. - std::string comment = "Linking "; - comment += llang; - comment += " target "; - comment += this->Convert(targetFullPath, START_OUTPUT); - this->Makefile->AddCustomCommandToOutput( - targetFullPath, - objVector, - "", - commandLines, - comment.c_str(), - this->StateSnapshot.GetDirectory().GetCurrentBinary() - ); - this->Makefile->GetSource(targetFullPath); - target.Target->AddSource(targetFullPath); -} - // List of variables that are replaced when // rules are expanced. These variables are // replaced in the form with GetSafeDefinition(var). diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index fee2420..429d5fc 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -328,11 +328,6 @@ protected: void InsertRuleLauncher(std::string& s, cmTarget* target, const std::string& prop); - - /** Convert a target to a utility target for unsupported - * languages of a generator */ - void AddBuildTargetRule(const std::string& llang, - cmGeneratorTarget& target); ///! add a custom command to build a .o file that is part of a target void AddCustomCommandToCreateObject(const char* ofname, const std::string& lang, -- cgit v0.12 From bbad6ba53771dc77bfdf74bab7173374084d434c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 27 Jul 2015 20:58:28 +0200 Subject: cmLocalGenerator: Remove unused AddCustomCommandToCreateObject method. --- Source/cmLocalGenerator.cxx | 78 --------------------------------------------- Source/cmLocalGenerator.h | 6 ---- 2 files changed, 84 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index cce10ce..91e37c4 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -448,84 +448,6 @@ cmState::Snapshot cmLocalGenerator::GetStateSnapshot() const return this->StateSnapshot; } -void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, - const std::string& lang, - cmSourceFile& source, - cmGeneratorTarget& target) -{ - std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname)); - objectDir = this->Convert(objectDir,START_OUTPUT,SHELL); - std::string objectFile = this->Convert(ofname,START_OUTPUT,SHELL); - std::string sourceFile = - this->ConvertToOutputFormat(source.GetFullPath(), SHELL); - std::string varString = "CMAKE_"; - varString += lang; - varString += "_COMPILE_OBJECT"; - std::vector rules; - rules.push_back(this->Makefile->GetRequiredDefinition(varString)); - varString = "CMAKE_"; - varString += lang; - varString += "_FLAGS"; - std::string flags; - flags += this->Makefile->GetSafeDefinition(varString); - flags += " "; - { - std::vector includes; - this->GetIncludeDirectories(includes, &target, lang); - flags += this->GetIncludeFlags(includes, &target, lang); - } - flags += this->Makefile->GetDefineFlags(); - - // Construct the command lines. - cmCustomCommandLines commandLines; - std::vector commands; - cmSystemTools::ExpandList(rules, commands); - cmLocalGenerator::RuleVariables vars; - vars.Language = lang.c_str(); - vars.Source = sourceFile.c_str(); - vars.Object = objectFile.c_str(); - vars.ObjectDir = objectDir.c_str(); - vars.Flags = flags.c_str(); - for(std::vector::iterator i = commands.begin(); - i != commands.end(); ++i) - { - // Expand the full command line string. - this->ExpandRuleVariables(*i, vars); - - // Parse the string to get the custom command line. - cmCustomCommandLine commandLine; - std::vector cmd = cmSystemTools::ParseArguments(i->c_str()); - commandLine.insert(commandLine.end(), cmd.begin(), cmd.end()); - - // Store this command line. - commandLines.push_back(commandLine); - } - - // Check for extra object-file dependencies. - std::vector depends; - const char* additionalDeps = source.GetProperty("OBJECT_DEPENDS"); - if(additionalDeps) - { - cmSystemTools::ExpandListArgument(additionalDeps, depends); - } - - // Generate a meaningful comment for the command. - std::string comment = "Building "; - comment += lang; - comment += " object "; - comment += this->Convert(ofname, START_OUTPUT); - - // Add the custom command to build the object file. - this->Makefile->AddCustomCommandToOutput( - ofname, - depends, - source.GetFullPath(), - commandLines, - comment.c_str(), - this->StateSnapshot.GetDirectory().GetCurrentBinary() - ); -} - // List of variables that are replaced when // rules are expanced. These variables are // replaced in the form with GetSafeDefinition(var). diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 429d5fc..2971574 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -328,12 +328,6 @@ protected: void InsertRuleLauncher(std::string& s, cmTarget* target, const std::string& prop); - ///! add a custom command to build a .o file that is part of a target - void AddCustomCommandToCreateObject(const char* ofname, - const std::string& lang, - cmSourceFile& source, - cmGeneratorTarget& target); - // Handle old-style install rules stored in the targets. void GenerateTargetInstallRules( std::ostream& os, const std::string& config, -- cgit v0.12 From 611220f77af9e2c5e174aa7ff9fa8bba982374ef Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Jul 2015 22:51:53 +0200 Subject: cmTarget: Use reliable test for CMP0024 and CMP0026 OLD. Check whether the Makefile is fully configured instead of checking whether generator targets exist. --- Source/cmTarget.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 3d8adae..da57c4c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -723,7 +723,7 @@ void cmTarget::GetSourceFiles(std::vector &files, { assert(this->GetType() != INTERFACE_LIBRARY); - if (this->Makefile->GetGeneratorTargets().empty()) + if (!this->Makefile->IsConfigured()) { // At configure-time, this method can be called as part of getting the // LOCATION property or to export() a file to be include()d. However @@ -5249,7 +5249,7 @@ void cmTarget::GetLanguages(std::set& languages, std::vector objectLibraries; std::vector externalObjects; - if (this->Makefile->GetGeneratorTargets().empty()) + if (!this->Makefile->IsConfigured()) { this->GetObjectLibrariesCMP0026(objectLibraries); } -- cgit v0.12 From de80993a2020e64259f12f608d11d1ace9a719a6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Jul 2015 20:58:55 +0200 Subject: cmGlobalGenerator: Create cmGeneratorTargets earlier. --- Source/cmGlobalGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index f5ddd10..936ef74 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1240,6 +1240,7 @@ void cmGlobalGenerator::Generate() AutogensType autogens; this->CreateQtAutoGeneratorsTargets(autogens); #endif + this->CreateGenerationObjects(); unsigned int i; @@ -1254,7 +1255,6 @@ void cmGlobalGenerator::Generate() this->LocalGenerators[i]->AddHelperCommands(); } - this->CreateGenerationObjects(); this->InitGeneratorTargets(); #ifdef CMAKE_BUILD_WITH_CMAKE -- cgit v0.12 From 496f4cd07d20e91750ec920e05a4aef4e4bdc9ba Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Jul 2015 23:19:36 +0200 Subject: cmGlobalGenerator: Create cmGeneratorTargets before QtAutomoc. Add cmGeneratorTargets as needed in the QtAutomoc processing. --- Source/cmGlobalGenerator.cxx | 6 ++++-- Source/cmGlobalGenerator.h | 5 +++++ Source/cmMakefile.h | 4 ++++ Source/cmQtAutoGenerators.cxx | 7 ++++++- Source/cmQtAutoGenerators.h | 3 ++- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 936ef74..a77a02a 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1234,13 +1234,14 @@ void cmGlobalGenerator::Generate() this->FinalizeTargetCompileInfo(); + this->CreateGenerationObjects(); + #ifdef CMAKE_BUILD_WITH_CMAKE // Iterate through all targets and set up automoc for those which have // the AUTOMOC, AUTOUIC or AUTORCC property set AutogensType autogens; this->CreateQtAutoGeneratorsTargets(autogens); #endif - this->CreateGenerationObjects(); unsigned int i; @@ -1414,7 +1415,8 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens) && !target.IsImported()) { cmQtAutoGenerators autogen; - if(autogen.InitializeAutogenTarget(&target)) + if(autogen.InitializeAutogenTarget(this->LocalGenerators[i], + &target)) { autogens.push_back(std::make_pair(autogen, &target)); } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 7d9bb4c..95b0ef1 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -300,6 +300,11 @@ public: /** Get per-target generator information. */ cmGeneratorTarget* GetGeneratorTarget(cmTarget const*) const; + void AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt) + { + this->GeneratorTargets[t] = gt; + } + const std::map >& GetProjectMap() const {return this->ProjectMap;} diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 2fc4d78..f5cd74d 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -415,6 +415,10 @@ public: { this->GeneratorTargets = targets; } + void AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt) + { + this->GeneratorTargets[t] = gt; + } cmTarget* FindTarget(const std::string& name, bool excludeAliases = false) const; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 58f4bf4..ae21561 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -287,7 +287,8 @@ std::string cmQtAutoGenerators::ListQt4RccInputs(cmSourceFile* sf, return entriesList; } -bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) +bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, + cmTarget* target) { cmMakefile* makefile = target->GetMakefile(); // don't do anything if there is no Qt4 or Qt5Core (which contains moc): @@ -474,6 +475,10 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) /*byproducts=*/rcc_output, depends, commandLines, false, autogenComment.c_str()); + cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); + lg->GetGlobalGenerator()->AddGeneratorTarget(autogenTarget, gt); + makefile->AddGeneratorTarget(autogenTarget, gt); + // Set target folder const char* autogenFolder = makefile->GetState() ->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER"); diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index 4c0fcbc..4f03348 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -18,6 +18,7 @@ class cmGlobalGenerator; class cmMakefile; +class cmLocalGenerator; class cmQtAutoGenerators { @@ -25,7 +26,7 @@ public: cmQtAutoGenerators(); bool Run(const std::string& targetDirectory, const std::string& config); - bool InitializeAutogenTarget(cmTarget* target); + bool InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target); void SetupAutoGenerateTarget(cmTarget const* target); void SetupSourceFiles(cmTarget const* target); -- cgit v0.12 From 5ab3a946518870d0dbd1fe606d1bc89d336769c4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Jul 2015 21:06:37 +0200 Subject: cmTarget: Inline GetLocation into deprecated callers. --- Source/cmTarget.cxx | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index da57c4c..352b2de 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2917,11 +2917,21 @@ const char *cmTarget::GetProperty(const std::string& prop, // For an imported target this is the location of an arbitrary // available configuration. // - // For a non-imported target this is deprecated because it - // cannot take into account the per-configuration name of the - // target because the configuration type may not be known at - // CMake time. - this->Properties.SetProperty(propLOCATION, this->GetLocationForBuild()); + if(this->IsImported()) + { + this->Properties.SetProperty( + propLOCATION, this->ImportedGetFullPath("", false).c_str()); + } + else + { + // For a non-imported target this is deprecated because it + // cannot take into account the per-configuration name of the + // target because the configuration type may not be known at + // CMake time. + this->Properties.SetProperty( + propLOCATION, this->GetLocationForBuild()); + } + } // Support "LOCATION_". @@ -2932,7 +2942,17 @@ const char *cmTarget::GetProperty(const std::string& prop, return 0; } const char* configName = prop.c_str() + 9; - this->Properties.SetProperty(prop, this->GetLocation(configName)); + + if (this->IsImported()) + { + this->Properties.SetProperty( + prop, this->ImportedGetFullPath(configName, false).c_str()); + } + else + { + this->Properties.SetProperty( + prop, this->GetFullPath(configName, false).c_str()); + } } // Support "_LOCATION". else if(cmHasLiteralSuffix(prop, "_LOCATION")) @@ -2944,7 +2964,16 @@ const char *cmTarget::GetProperty(const std::string& prop, { return 0; } - this->Properties.SetProperty(prop, this->GetLocation(configName)); + if (this->IsImported()) + { + this->Properties.SetProperty( + prop, this->ImportedGetFullPath(configName, false).c_str()); + } + else + { + this->Properties.SetProperty( + prop, this->GetFullPath(configName, false).c_str()); + } } } } -- cgit v0.12 From ba2668588213688243174a9cc8d7f034661b2a73 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Jul 2015 21:10:31 +0200 Subject: cmTarget: Create cmGeneratorTargets before reading deprecated LOCATION. The intention is to move generation-semantic cmTarget API to cmGeneratorTarget and then use the latter for generator expressions. This means that each time we read a deprecated LOCATION property, we have to clear and re-populate the container. That must be done each time because the result can change through the configure process, which is why this is deprecated in the first place. --- Source/cmTarget.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 352b2de..295c862 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2950,8 +2950,11 @@ const char *cmTarget::GetProperty(const std::string& prop, } else { + cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator(); + gg->CreateGenerationObjects(); + cmGeneratorTarget* gt = gg->GetGeneratorTarget(this); this->Properties.SetProperty( - prop, this->GetFullPath(configName, false).c_str()); + prop, gt->Target->GetFullPath(configName, false).c_str()); } } // Support "_LOCATION". @@ -2971,8 +2974,11 @@ const char *cmTarget::GetProperty(const std::string& prop, } else { + cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator(); + gg->CreateGenerationObjects(); + cmGeneratorTarget* gt = gg->GetGeneratorTarget(this); this->Properties.SetProperty( - prop, this->GetFullPath(configName, false).c_str()); + prop, gt->Target->GetFullPath(configName, false).c_str()); } } } -- cgit v0.12 From 50b17a6112704ad3897b1ccc87a0061cf7949ee7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 26 Jul 2015 10:24:15 +0200 Subject: cmIncludeCommand: Populate the cmGeneratorTargets in deprecated path. --- Source/cmIncludeCommand.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index b94ad25..8890e2b 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -125,6 +125,7 @@ bool cmIncludeCommand return false; } } + gg->CreateGenerationObjects(); gg->GenerateImportFile(fname_abs); } -- cgit v0.12 From 5b60eaf619baf4dfa2bc1a3f1109ff742a04f532 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 10 Mar 2014 14:42:27 +0100 Subject: cmTarget: Restore the ImportedGetLocation method. It was removed in commit f154475b (cmTarget: Refactor GetLocation API, 2014-03-08), but it is more readable for targets we know are imported. --- Source/cmQtAutoGenerators.cxx | 16 ++++++++++------ Source/cmTarget.cxx | 9 +++++++++ Source/cmTarget.h | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index ae21561..979db91 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -809,7 +809,8 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, autogenTargetName.c_str()); return; } - makefile->AddDefinition("_qt_moc_executable", qt5Moc->GetLocation("")); + makefile->AddDefinition("_qt_moc_executable", + qt5Moc->ImportedGetLocation("")); } else if (strcmp(qtVersion, "4") == 0) { @@ -820,7 +821,8 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, autogenTargetName.c_str()); return; } - makefile->AddDefinition("_qt_moc_executable", qt4Moc->GetLocation("")); + makefile->AddDefinition("_qt_moc_executable", + qt4Moc->ImportedGetLocation("")); } else { @@ -967,7 +969,8 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, } else { - makefile->AddDefinition("_qt_uic_executable", qt5Uic->GetLocation("")); + makefile->AddDefinition("_qt_uic_executable", + qt5Uic->ImportedGetLocation("")); } } else if (strcmp(qtVersion, "4") == 0) @@ -979,7 +982,8 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, targetName.c_str()); return; } - makefile->AddDefinition("_qt_uic_executable", qt4Uic->GetLocation("")); + makefile->AddDefinition("_qt_uic_executable", + qt4Uic->ImportedGetLocation("")); } else { @@ -1171,7 +1175,7 @@ std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) targetName.c_str()); return std::string(); } - return qt5Rcc->GetLocation(""); + return qt5Rcc->ImportedGetLocation(""); } else if (strcmp(qtVersion, "4") == 0) { @@ -1182,7 +1186,7 @@ std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) targetName.c_str()); return std::string(); } - return qt4Rcc->GetLocation(""); + return qt4Rcc->ImportedGetLocation(""); } cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and " diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 295c862..e4cd4f3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2754,6 +2754,15 @@ const char* cmTarget::GetLocation(const std::string& config) const } //---------------------------------------------------------------------------- +const char* cmTarget::ImportedGetLocation(const std::string& config) const +{ + static std::string location; + assert(this->IsImported()); + location = this->ImportedGetFullPath(config, false); + return location.c_str(); +} + +//---------------------------------------------------------------------------- const char* cmTarget::GetLocationForBuild() const { static std::string location; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1920312..a0198e2 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -377,6 +377,7 @@ public: /** Get the location of the target in the build tree for the given configuration. */ const char* GetLocation(const std::string& config) const; + const char* ImportedGetLocation(const std::string& config) const; /** Get the location of the target in the build tree with a placeholder referencing the configuration in the native build system. This -- cgit v0.12 From c7a8e74b8c7ade9efb68b8bd36fd6d741f2dba7e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 25 Jul 2015 21:28:36 +0200 Subject: Always access target location from a cmGeneratorTarget instance. --- Source/cmCustomCommandGenerator.cxx | 7 ++++--- Source/cmExtraCodeBlocksGenerator.cxx | 4 +++- Source/cmGlobalKdevelopGenerator.cxx | 8 ++++---- Source/cmLocalGenerator.cxx | 7 ++++--- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 8483a91..086c9f9 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -42,12 +42,13 @@ unsigned int cmCustomCommandGenerator::GetNumberOfCommands() const std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const { std::string const& argv0 = this->CC.GetCommandLines()[c][0]; - cmTarget* target = this->LG->GetMakefile()->FindTargetToUse(argv0); + cmGeneratorTarget* target = + this->LG->GetMakefile()->FindGeneratorTargetToUse(argv0); if(target && target->GetType() == cmTarget::EXECUTABLE && - (target->IsImported() + (target->Target->IsImported() || !this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING"))) { - return target->GetLocation(this->Config); + return target->Target->GetLocation(this->Config); } return this->GE->Parse(argv0)->Evaluate(this->LG->GetMakefile(), this->Config); diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index a31e832..6d145a2 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -591,7 +591,9 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, } else { - location = target->GetLocation(buildType); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(target); + location = gt->Target->GetLocation(buildType); } fout<<"