From 381e7afd363d64c72b83e69fd6c6cad5fc3eefb4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 17 Oct 2015 13:31:33 +0200 Subject: [PATCH] cmExportSet: Store a cmGeneratorTarget. Set the member at compute time from the stored name. --- Source/cmExportBuildFileGenerator.cxx | 6 +++++- Source/cmExportFileGenerator.cxx | 12 ++++-------- Source/cmExportInstallFileGenerator.cxx | 22 ++++++++++------------ Source/cmExportSet.cxx | 10 ++++++++++ Source/cmExportSet.h | 3 +++ Source/cmInstallCommand.cxx | 9 +++++---- Source/cmInstallExportGenerator.cxx | 1 + Source/cmTargetExport.h | 5 +++-- 8 files changed, 41 insertions(+), 27 deletions(-) diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 72b101f2b..30a8bf230 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -27,6 +27,10 @@ cmExportBuildFileGenerator::cmExportBuildFileGenerator() void cmExportBuildFileGenerator::Compute(cmLocalGenerator* lg) { this->LG = lg; + if (this->ExportSet) + { + this->ExportSet->Compute(lg); + } } //---------------------------------------------------------------------------- @@ -274,7 +278,7 @@ void cmExportBuildFileGenerator tei = this->ExportSet->GetTargetExports()->begin(); tei != this->ExportSet->GetTargetExports()->end(); ++tei) { - targets.push_back((*tei)->GetName()); + targets.push_back((*tei)->TargetName); } return; } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 61276269a..4e8bc868c 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -398,11 +398,11 @@ void cmExportFileGenerator::PopulateSourcesInterface( ImportPropertyMap &properties, std::vector &missingTargets) { - cmTarget *target = tei->Target; + cmGeneratorTarget* gt = tei->Target; assert(preprocessRule == cmGeneratorExpression::InstallInterface); const char *propName = "INTERFACE_SOURCES"; - const char *input = target->GetProperty(propName); + const char *input = gt->GetProperty(propName); if (!input) { @@ -420,11 +420,9 @@ void cmExportFileGenerator::PopulateSourcesInterface( true); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, target, + this->ResolveTargetsInGeneratorExpressions(prepro, gt->Target, missingTargets); - cmGeneratorTarget* gt = target->GetMakefile() - ->GetGlobalGenerator()->GetGeneratorTarget(target); if (!checkInterfaceDirs(prepro, gt, propName)) { return; @@ -440,9 +438,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( ImportPropertyMap &properties, std::vector &missingTargets) { - cmGeneratorTarget *target = tei->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tei->Target); + cmGeneratorTarget *target = tei->Target; assert(preprocessRule == cmGeneratorExpression::InstallInterface); const char *propName = "INTERFACE_INCLUDE_DIRECTORIES"; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 5a514420e..d7ca6d529 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -48,10 +48,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) tei = this->IEGen->GetExportSet()->GetTargetExports()->begin(); tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei) { - expectedTargets += sep + this->Namespace + (*tei)->Target->GetExportName(); + expectedTargets += + sep + this->Namespace + (*tei)->Target->Target->GetExportName(); sep = " "; cmTargetExport * te = *tei; - if(this->ExportedTargets.insert(te->Target).second) + if(this->ExportedTargets.insert(te->Target->Target).second) { allTargets.push_back(te); } @@ -131,7 +132,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) tei = allTargets.begin(); tei != allTargets.end(); ++tei) { - cmTarget* te = (*tei)->Target; + cmGeneratorTarget* gt = (*tei)->Target; + cmTarget* te = gt->Target; requiresConfigFiles = requiresConfigFiles || te->GetType() != cmState::INTERFACE_LIBRARY; @@ -193,13 +195,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); - cmGeneratorTarget *gtgt = te->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(te); - this->PopulateCompatibleInterfaceProperties(gtgt, properties); + this->PopulateCompatibleInterfaceProperties(gt, properties); - this->GenerateInterfaceProperties(te, os, properties); + this->GenerateInterfaceProperties(gt->Target, os, properties); } if (require3_1_0) @@ -362,8 +361,7 @@ cmExportInstallFileGenerator if(!properties.empty()) { // Get the rest of the target details. - cmGeneratorTarget *gtgt = te->Target->GetMakefile() - ->GetGlobalGenerator()->GetGeneratorTarget(te->Target); + cmGeneratorTarget *gtgt = te->Target; this->SetImportDetailProperties(config, suffix, gtgt, properties, missingTargets); @@ -378,8 +376,8 @@ cmExportInstallFileGenerator // properties); // Generate code in the export file. - this->GenerateImportPropertyCode(os, config, te->Target, properties); - this->GenerateImportedFileChecksCode(os, te->Target, properties, + this->GenerateImportPropertyCode(os, config, gtgt->Target, properties); + this->GenerateImportedFileChecksCode(os, gtgt->Target, properties, importedLocations); } } diff --git a/Source/cmExportSet.cxx b/Source/cmExportSet.cxx index 4148fb50b..0059b6400 100644 --- a/Source/cmExportSet.cxx +++ b/Source/cmExportSet.cxx @@ -13,12 +13,22 @@ #include "cmExportSet.h" #include "cmTargetExport.h" #include "cmAlgorithms.h" +#include "cmLocalGenerator.h" cmExportSet::~cmExportSet() { cmDeleteAll(this->TargetExports); } +void cmExportSet::Compute(cmLocalGenerator* lg) +{ + for (std::vector::iterator it = this->TargetExports.begin(); + it != this->TargetExports.end(); ++it) + { + (*it)->Target = lg->FindGeneratorTargetToUse((*it)->TargetName); + } +} + void cmExportSet::AddTargetExport(cmTargetExport* te) { this->TargetExports.push_back(te); diff --git a/Source/cmExportSet.h b/Source/cmExportSet.h index a57aa1204..d780a228c 100644 --- a/Source/cmExportSet.h +++ b/Source/cmExportSet.h @@ -15,6 +15,7 @@ #include "cmSystemTools.h" class cmTargetExport; class cmInstallExportGenerator; +class cmLocalGenerator; /// A set of targets that were installed with the same EXPORT parameter. class cmExportSet @@ -25,6 +26,8 @@ public: /// Destructor ~cmExportSet(); + void Compute(cmLocalGenerator* lg); + void AddTargetExport(cmTargetExport* tgt); void AddInstallation(cmInstallExportGenerator const* installation); diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index c22edf336..6b06fce2a 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -773,7 +773,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) if(!exports.GetString().empty() && !namelinkOnly) { cmTargetExport *te = new cmTargetExport; - te->Target = ⌖ + te->TargetName = target.GetName(); te->ArchiveGenerator = archiveGenerator; te->BundleGenerator = bundleGenerator; te->FrameworkGenerator = frameworkGenerator; @@ -1379,16 +1379,17 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) tei != exportSet->GetTargetExports()->end(); ++tei) { cmTargetExport const* te = *tei; + cmTarget* tgt = this->Makefile->FindTarget(te->TargetName); const bool newCMP0022Behavior = - te->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN - && te->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD; + tgt->GetPolicyStatusCMP0022() != cmPolicies::WARN + && tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD; if(!newCMP0022Behavior) { std::ostringstream e; e << "INSTALL(EXPORT) given keyword \"" << "EXPORT_LINK_INTERFACE_LIBRARIES" << "\", but target \"" - << te->Target->GetName() + << te->TargetName << "\" does not have policy CMP0022 set to NEW."; this->SetError(e.str()); return false; diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index f7c9cc28c..9570ba3d8 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -56,6 +56,7 @@ cmInstallExportGenerator::~cmInstallExportGenerator() void cmInstallExportGenerator::Compute(cmLocalGenerator* lg) { this->LocalGenerator = lg; + this->ExportSet->Compute(lg); } //---------------------------------------------------------------------------- diff --git a/Source/cmTargetExport.h b/Source/cmTargetExport.h index 76658887d..2781337fe 100644 --- a/Source/cmTargetExport.h +++ b/Source/cmTargetExport.h @@ -14,7 +14,7 @@ #include "cmStandardIncludes.h" -class cmTarget; +class cmGeneratorTarget; class cmInstallTargetGenerator; class cmInstallFilesGenerator; @@ -25,7 +25,8 @@ class cmInstallFilesGenerator; class cmTargetExport { public: - cmTarget* Target; ///< The target + std::string TargetName; + cmGeneratorTarget* Target; ///@name Generators ///@{