From 8c65b7042e0e7bca3dc5c0cda8975fd2e9c6dc51 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 11 Apr 2022 11:06:28 -0400 Subject: cmExportFileGenerator: Simplify collection of targets missing from export set Store the list of missing target names in a member instead of threading an explicit reference to it through the call stack. --- Source/cmExportBuildAndroidMKGenerator.cxx | 3 +- Source/cmExportBuildAndroidMKGenerator.h | 4 +- Source/cmExportBuildFileGenerator.cxx | 43 ++++++------- Source/cmExportBuildFileGenerator.h | 6 +- Source/cmExportFileGenerator.cxx | 92 +++++++++++++--------------- Source/cmExportFileGenerator.h | 49 ++++++--------- Source/cmExportInstallAndroidMKGenerator.cxx | 5 +- Source/cmExportInstallAndroidMKGenerator.h | 7 +-- Source/cmExportInstallFileGenerator.cxx | 50 +++++++-------- Source/cmExportInstallFileGenerator.h | 9 +-- Source/cmExportTryCompileFileGenerator.h | 6 +- 11 files changed, 117 insertions(+), 157 deletions(-) diff --git a/Source/cmExportBuildAndroidMKGenerator.cxx b/Source/cmExportBuildAndroidMKGenerator.cxx index 1441925..5d0b208 100644 --- a/Source/cmExportBuildAndroidMKGenerator.cxx +++ b/Source/cmExportBuildAndroidMKGenerator.cxx @@ -4,6 +4,7 @@ #include #include +#include #include @@ -60,7 +61,7 @@ void cmExportBuildAndroidMKGenerator::GenerateImportPropertyCode( } void cmExportBuildAndroidMKGenerator::GenerateMissingTargetsCheckCode( - std::ostream&, const std::vector&) + std::ostream&) { } diff --git a/Source/cmExportBuildAndroidMKGenerator.h b/Source/cmExportBuildAndroidMKGenerator.h index 250564f..410d4c3 100644 --- a/Source/cmExportBuildAndroidMKGenerator.h +++ b/Source/cmExportBuildAndroidMKGenerator.h @@ -6,7 +6,6 @@ #include #include -#include #include "cmExportBuildFileGenerator.h" #include "cmExportFileGenerator.h" @@ -56,8 +55,7 @@ protected: std::ostream& os, const std::string& config, cmGeneratorTarget const* target, ImportPropertyMap const& properties) override; - void GenerateMissingTargetsCheckCode( - std::ostream& os, const std::vector& missingTargets) override; + void GenerateMissingTargetsCheckCode(std::ostream& os) override; void GenerateInterfaceProperties( cmGeneratorTarget const* target, std::ostream& os, const ImportPropertyMap& properties) override; diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index a47f1e5..f22c716 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -76,8 +76,6 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) this->GenerateExpectedTargetsCode(os, expectedTargets); } - std::vector missingTargets; - // Create all the imported targets. for (cmGeneratorTarget* gte : this->Exports) { this->GenerateImportTargetCode(os, gte, this->GetExportTargetType(gte)); @@ -88,34 +86,34 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_INCLUDE_DIRECTORIES", gte, cmGeneratorExpression::BuildInterface, - properties, missingTargets); + properties); this->PopulateInterfaceProperty("INTERFACE_SOURCES", gte, cmGeneratorExpression::BuildInterface, - properties, missingTargets); + properties); this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", gte, cmGeneratorExpression::BuildInterface, - properties, missingTargets); + properties); this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", gte, cmGeneratorExpression::BuildInterface, - properties, missingTargets); + properties); this->PopulateInterfaceProperty("INTERFACE_PRECOMPILE_HEADERS", gte, cmGeneratorExpression::BuildInterface, - properties, missingTargets); + properties); this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", gte, cmGeneratorExpression::BuildInterface, - properties, missingTargets); + properties); this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", gte, cmGeneratorExpression::BuildInterface, - properties, missingTargets); + properties); this->PopulateInterfaceProperty("INTERFACE_LINK_OPTIONS", gte, cmGeneratorExpression::BuildInterface, - properties, missingTargets); + properties); this->PopulateInterfaceProperty("INTERFACE_LINK_DIRECTORIES", gte, cmGeneratorExpression::BuildInterface, - properties, missingTargets); + properties); this->PopulateInterfaceProperty("INTERFACE_LINK_DEPENDS", gte, cmGeneratorExpression::BuildInterface, - properties, missingTargets); + properties); this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", gte, properties); @@ -132,8 +130,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) gte->GetPolicyStatusCMP0022() != cmPolicies::OLD; if (newCMP0022Behavior) { this->PopulateInterfaceLinkLibrariesProperty( - gte, cmGeneratorExpression::BuildInterface, properties, - missingTargets); + gte, cmGeneratorExpression::BuildInterface, properties); } this->PopulateCompatibleInterfaceProperties(gte, properties); @@ -144,17 +141,16 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) // Generate import file content for each configuration. for (std::string const& c : this->Configurations) { - this->GenerateImportConfig(os, c, missingTargets); + this->GenerateImportConfig(os, c); } - this->GenerateMissingTargetsCheckCode(os, missingTargets); + this->GenerateMissingTargetsCheckCode(os); return true; } void cmExportBuildFileGenerator::GenerateImportTargetsConfig( - std::ostream& os, const std::string& config, std::string const& suffix, - std::vector& missingTargets) + std::ostream& os, const std::string& config, std::string const& suffix) { for (cmGeneratorTarget* target : this->Exports) { // Collect import properties for this target. @@ -167,11 +163,10 @@ void cmExportBuildFileGenerator::GenerateImportTargetsConfig( // Get the rest of the target details. if (this->GetExportTargetType(target) != cmStateEnums::INTERFACE_LIBRARY) { - this->SetImportDetailProperties(config, suffix, target, properties, - missingTargets); + this->SetImportDetailProperties(config, suffix, target, properties); this->SetImportLinkInterface(config, suffix, cmGeneratorExpression::BuildInterface, - target, properties, missingTargets); + target, properties); } // TODO: PUBLIC_HEADER_LOCATION @@ -259,8 +254,8 @@ void cmExportBuildFileGenerator::SetImportLocationProperty( } void cmExportBuildFileGenerator::HandleMissingTarget( - std::string& link_libs, std::vector& missingTargets, - cmGeneratorTarget const* depender, cmGeneratorTarget* dependee) + std::string& link_libs, cmGeneratorTarget const* depender, + cmGeneratorTarget* dependee) { // The target is not in the export. if (!this->AppendMode) { @@ -275,7 +270,7 @@ void cmExportBuildFileGenerator::HandleMissingTarget( missingTarget += dependee->GetExportName(); link_libs += missingTarget; - missingTargets.push_back(std::move(missingTarget)); + this->MissingTargets.emplace_back(std::move(missingTarget)); return; } // We are not appending, so all exported targets should be diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index a7985c7..3db8719 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -55,13 +55,11 @@ public: protected: // Implement virtual methods from the superclass. bool GenerateMainFile(std::ostream& os) override; - void GenerateImportTargetsConfig( - std::ostream& os, const std::string& config, std::string const& suffix, - std::vector& missingTargets) override; + void GenerateImportTargetsConfig(std::ostream& os, const std::string& config, + std::string const& suffix) override; cmStateEnums::TargetType GetExportTargetType( cmGeneratorTarget const* target) const; void HandleMissingTarget(std::string& link_libs, - std::vector& missingTargets, cmGeneratorTarget const* depender, cmGeneratorTarget* dependee) override; diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index dc94e76..6d6df71 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -106,9 +106,8 @@ bool cmExportFileGenerator::GenerateImportFile() return result; } -void cmExportFileGenerator::GenerateImportConfig( - std::ostream& os, const std::string& config, - std::vector& missingTargets) +void cmExportFileGenerator::GenerateImportConfig(std::ostream& os, + const std::string& config) { // Construct the property configuration suffix. std::string suffix = "_"; @@ -119,7 +118,7 @@ void cmExportFileGenerator::GenerateImportConfig( } // Generate the per-config target information. - this->GenerateImportTargetsConfig(os, config, suffix, missingTargets); + this->GenerateImportTargetsConfig(os, config, suffix); } void cmExportFileGenerator::PopulateInterfaceProperty( @@ -136,7 +135,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty( const std::string& propName, const std::string& outputName, cmGeneratorTarget const* target, cmGeneratorExpression::PreprocessContext preprocessRule, - ImportPropertyMap& properties, std::vector& missingTargets) + ImportPropertyMap& properties) { cmValue input = target->GetProperty(propName); if (input) { @@ -149,8 +148,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty( std::string prepro = cmGeneratorExpression::Preprocess(*input, preprocessRule); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, target, - missingTargets); + this->ResolveTargetsInGeneratorExpressions(prepro, target); properties[outputName] = prepro; } } @@ -170,7 +168,7 @@ void cmExportFileGenerator::GenerateRequiredCMakeVersion( bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty( cmGeneratorTarget const* target, cmGeneratorExpression::PreprocessContext preprocessRule, - ImportPropertyMap& properties, std::vector& missingTargets) + ImportPropertyMap& properties) { if (!target->IsLinkable()) { return false; @@ -185,8 +183,8 @@ bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty( std::string prepro = cmGeneratorExpression::Preprocess(*input, preprocessRule); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions( - prepro, target, missingTargets, ReplaceFreeTargets); + this->ResolveTargetsInGeneratorExpressions(prepro, target, + ReplaceFreeTargets); properties[linkIfaceProp] = prepro; hadINTERFACE_LINK_LIBRARIES = true; } @@ -343,7 +341,7 @@ static void prefixItems(std::string& exportDirs) void cmExportFileGenerator::PopulateSourcesInterface( cmGeneratorTarget const* gt, cmGeneratorExpression::PreprocessContext preprocessRule, - ImportPropertyMap& properties, std::vector& missingTargets) + ImportPropertyMap& properties) { assert(preprocessRule == cmGeneratorExpression::InstallInterface); @@ -362,7 +360,7 @@ void cmExportFileGenerator::PopulateSourcesInterface( std::string prepro = cmGeneratorExpression::Preprocess(*input, preprocessRule, true); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets); + this->ResolveTargetsInGeneratorExpressions(prepro, gt); if (!checkInterfaceDirs(prepro, gt, propName)) { return; @@ -374,8 +372,7 @@ void cmExportFileGenerator::PopulateSourcesInterface( void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( cmGeneratorTarget const* target, cmGeneratorExpression::PreprocessContext preprocessRule, - ImportPropertyMap& properties, std::vector& missingTargets, - cmTargetExport const& te) + ImportPropertyMap& properties, cmTargetExport const& te) { assert(preprocessRule == cmGeneratorExpression::InstallInterface); @@ -422,7 +419,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( std::string prepro = cmGeneratorExpression::Preprocess(includes, preprocessRule, true); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets); + this->ResolveTargetsInGeneratorExpressions(prepro, target); if (!checkInterfaceDirs(prepro, target, propName)) { return; @@ -434,7 +431,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( void cmExportFileGenerator::PopulateLinkDependsInterface( cmGeneratorTarget const* gt, cmGeneratorExpression::PreprocessContext preprocessRule, - ImportPropertyMap& properties, std::vector& missingTargets) + ImportPropertyMap& properties) { assert(preprocessRule == cmGeneratorExpression::InstallInterface); @@ -453,7 +450,7 @@ void cmExportFileGenerator::PopulateLinkDependsInterface( std::string prepro = cmGeneratorExpression::Preprocess(*input, preprocessRule, true); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets); + this->ResolveTargetsInGeneratorExpressions(prepro, gt); if (!checkInterfaceDirs(prepro, gt, propName)) { return; @@ -465,7 +462,7 @@ void cmExportFileGenerator::PopulateLinkDependsInterface( void cmExportFileGenerator::PopulateLinkDirectoriesInterface( cmGeneratorTarget const* gt, cmGeneratorExpression::PreprocessContext preprocessRule, - ImportPropertyMap& properties, std::vector& missingTargets) + ImportPropertyMap& properties) { assert(preprocessRule == cmGeneratorExpression::InstallInterface); @@ -484,7 +481,7 @@ void cmExportFileGenerator::PopulateLinkDirectoriesInterface( std::string prepro = cmGeneratorExpression::Preprocess(*input, preprocessRule, true); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets); + this->ResolveTargetsInGeneratorExpressions(prepro, gt); if (!checkInterfaceDirs(prepro, gt, propName)) { return; @@ -496,10 +493,10 @@ void cmExportFileGenerator::PopulateLinkDirectoriesInterface( void cmExportFileGenerator::PopulateInterfaceProperty( const std::string& propName, cmGeneratorTarget const* target, cmGeneratorExpression::PreprocessContext preprocessRule, - ImportPropertyMap& properties, std::vector& missingTargets) + ImportPropertyMap& properties) { this->PopulateInterfaceProperty(propName, propName, target, preprocessRule, - properties, missingTargets); + properties); } static void getPropertyContents(cmGeneratorTarget const* tgt, @@ -604,9 +601,9 @@ void cmExportFileGenerator::GenerateInterfaceProperties( } } -bool cmExportFileGenerator::AddTargetNamespace( - std::string& input, cmGeneratorTarget const* target, - cmLocalGenerator const* lg, std::vector& missingTargets) +bool cmExportFileGenerator::AddTargetNamespace(std::string& input, + cmGeneratorTarget const* target, + cmLocalGenerator const* lg) { cmGeneratorTarget::TargetOrString resolved = target->ResolveTargetReference(input, lg); @@ -625,7 +622,7 @@ bool cmExportFileGenerator::AddTargetNamespace( input = this->Namespace + tgt->GetExportName(); } else { std::string namespacedTarget; - this->HandleMissingTarget(namespacedTarget, missingTargets, target, tgt); + this->HandleMissingTarget(namespacedTarget, target, tgt); if (!namespacedTarget.empty()) { input = namespacedTarget; } else { @@ -637,12 +634,11 @@ bool cmExportFileGenerator::AddTargetNamespace( void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( std::string& input, cmGeneratorTarget const* target, - std::vector& missingTargets, FreeTargetsReplace replace) + FreeTargetsReplace replace) { cmLocalGenerator const* lg = target->GetLocalGenerator(); if (replace == NoReplaceFreeTargets) { - this->ResolveTargetsInGeneratorExpression(input, target, lg, - missingTargets); + this->ResolveTargetsInGeneratorExpression(input, target, lg); return; } std::vector parts; @@ -655,10 +651,9 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( continue; } if (cmGeneratorExpression::Find(li) == std::string::npos) { - this->AddTargetNamespace(li, target, lg, missingTargets); + this->AddTargetNamespace(li, target, lg); } else { - this->ResolveTargetsInGeneratorExpression(li, target, lg, - missingTargets); + this->ResolveTargetsInGeneratorExpression(li, target, lg); } input += sep + li; sep = ";"; @@ -667,7 +662,7 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( void cmExportFileGenerator::ResolveTargetsInGeneratorExpression( std::string& input, cmGeneratorTarget const* target, - cmLocalGenerator const* lg, std::vector& missingTargets) + cmLocalGenerator const* lg) { std::string::size_type pos = 0; std::string::size_type lastPos = pos; @@ -691,7 +686,7 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpression( std::string targetName = input.substr(nameStartPos, commaPos - nameStartPos); - if (this->AddTargetNamespace(targetName, target, lg, missingTargets)) { + if (this->AddTargetNamespace(targetName, target, lg)) { input.replace(nameStartPos, commaPos - nameStartPos, targetName); } lastPos = nameStartPos + targetName.size() + 1; @@ -713,7 +708,7 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpression( "literal."; break; } - if (!this->AddTargetNamespace(targetName, target, lg, missingTargets)) { + if (!this->AddTargetNamespace(targetName, target, lg)) { errorString = "$ requires its parameter to be a " "reachable target."; break; @@ -734,7 +729,7 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpression( } std::string libName = input.substr(nameStartPos, endPos - nameStartPos); if (cmGeneratorExpression::IsValidTargetName(libName) && - this->AddTargetNamespace(libName, target, lg, missingTargets)) { + this->AddTargetNamespace(libName, target, lg)) { input.replace(nameStartPos, endPos - nameStartPos, libName); } lastPos = nameStartPos + libName.size() + 1; @@ -756,8 +751,7 @@ void cmExportFileGenerator::ReplaceInstallPrefix(std::string& /*unused*/) void cmExportFileGenerator::SetImportLinkInterface( const std::string& config, std::string const& suffix, cmGeneratorExpression::PreprocessContext preprocessRule, - cmGeneratorTarget const* target, ImportPropertyMap& properties, - std::vector& missingTargets) + cmGeneratorTarget const* target, ImportPropertyMap& properties) { // Add the transitive link dependencies for this configuration. cmLinkInterface const* iface = target->GetLinkInterface(config, target); @@ -769,7 +763,7 @@ void cmExportFileGenerator::SetImportLinkInterface( // Policy CMP0022 must not be NEW. this->SetImportLinkProperty( suffix, target, "IMPORTED_LINK_INTERFACE_LIBRARIES", iface->Libraries, - properties, missingTargets, ImportLinkPropertyTargetNames::Yes); + properties, ImportLinkPropertyTargetNames::Yes); return; } @@ -808,7 +802,7 @@ void cmExportFileGenerator::SetImportLinkInterface( std::string prepro = cmGeneratorExpression::Preprocess(*propContent, preprocessRule); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets, + this->ResolveTargetsInGeneratorExpressions(prepro, target, ReplaceFreeTargets); properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro; } @@ -816,8 +810,7 @@ void cmExportFileGenerator::SetImportLinkInterface( void cmExportFileGenerator::SetImportDetailProperties( const std::string& config, std::string const& suffix, - cmGeneratorTarget* target, ImportPropertyMap& properties, - std::vector& missingTargets) + cmGeneratorTarget* target, ImportPropertyMap& properties) { // Get the makefile in which to lookup target information. cmMakefile* mf = target->Makefile; @@ -848,12 +841,11 @@ void cmExportFileGenerator::SetImportDetailProperties( target->GetLinkInterface(config, target)) { this->SetImportLinkProperty( suffix, target, "IMPORTED_LINK_INTERFACE_LANGUAGES", iface->Languages, - properties, missingTargets, ImportLinkPropertyTargetNames::No); + properties, ImportLinkPropertyTargetNames::No); - std::vector dummy; this->SetImportLinkProperty( suffix, target, "IMPORTED_LINK_DEPENDENT_LIBRARIES", iface->SharedDeps, - properties, dummy, ImportLinkPropertyTargetNames::Yes); + properties, ImportLinkPropertyTargetNames::Yes); if (iface->Multiplicity > 0) { std::string prop = cmStrCat("IMPORTED_LINK_INTERFACE_MULTIPLICITY", suffix); @@ -894,8 +886,7 @@ template void cmExportFileGenerator::SetImportLinkProperty( std::string const& suffix, cmGeneratorTarget const* target, const std::string& propName, std::vector const& entries, - ImportPropertyMap& properties, std::vector& missingTargets, - ImportLinkPropertyTargetNames targetNames) + ImportPropertyMap& properties, ImportLinkPropertyTargetNames targetNames) { // Skip the property if there are no entries. if (entries.empty()) { @@ -914,7 +905,7 @@ void cmExportFileGenerator::SetImportLinkProperty( if (targetNames == ImportLinkPropertyTargetNames::Yes) { std::string temp = asString(l); - this->AddTargetNamespace(temp, target, lg, missingTargets); + this->AddTargetNamespace(temp, target, lg); link_entries += temp; } else { link_entries += asString(l); @@ -1124,10 +1115,9 @@ void cmExportFileGenerator::GenerateImportPropertyCode( << "\n"; } -void cmExportFileGenerator::GenerateMissingTargetsCheckCode( - std::ostream& os, const std::vector& missingTargets) +void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os) { - if (missingTargets.empty()) { + if (this->MissingTargets.empty()) { /* clang-format off */ os << "# This file does not depend on other imported targets which have\n" "# been exported from the same project but in a separate " @@ -1142,7 +1132,7 @@ void cmExportFileGenerator::GenerateMissingTargetsCheckCode( "foreach(_target "; /* clang-format on */ std::set emitted; - for (std::string const& missingTarget : missingTargets) { + for (std::string const& missingTarget : this->MissingTargets) { if (emitted.insert(missingTarget).second) { os << "\"" << missingTarget << "\" "; } diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index bde6f1b..d27a555 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -66,8 +66,7 @@ protected: // Generate per-configuration target information to the given output // stream. - void GenerateImportConfig(std::ostream& os, const std::string& config, - std::vector& missingTargets); + void GenerateImportConfig(std::ostream& os, const std::string& config); // Methods to implement export file code generation. virtual void GeneratePolicyHeaderCode(std::ostream& os); @@ -88,8 +87,7 @@ protected: ImportPropertyMap const& properties, const std::set& importedLocations); virtual void GenerateImportedFileCheckLoop(std::ostream& os); - virtual void GenerateMissingTargetsCheckCode( - std::ostream& os, const std::vector& missingTargets); + virtual void GenerateMissingTargetsCheckCode(std::ostream& os); virtual void GenerateExpectedTargetsCode(std::ostream& os, const std::string& expectedTargets); @@ -99,8 +97,7 @@ protected: void SetImportDetailProperties(const std::string& config, std::string const& suffix, cmGeneratorTarget* target, - ImportPropertyMap& properties, - std::vector& missingTargets); + ImportPropertyMap& properties); enum class ImportLinkPropertyTargetNames { @@ -113,31 +110,28 @@ protected: const std::string& propName, std::vector const& entries, ImportPropertyMap& properties, - std::vector& missingTargets, ImportLinkPropertyTargetNames targetNames); /** Each subclass knows how to generate its kind of export file. */ virtual bool GenerateMainFile(std::ostream& os) = 0; /** Each subclass knows where the target files are located. */ - virtual void GenerateImportTargetsConfig( - std::ostream& os, const std::string& config, std::string const& suffix, - std::vector& missingTargets) = 0; + virtual void GenerateImportTargetsConfig(std::ostream& os, + const std::string& config, + std::string const& suffix) = 0; /** Each subclass knows how to deal with a target that is missing from an * export set. */ virtual void HandleMissingTarget(std::string& link_libs, - std::vector& missingTargets, cmGeneratorTarget const* depender, cmGeneratorTarget* dependee) = 0; void PopulateInterfaceProperty(const std::string&, cmGeneratorTarget const* target, cmGeneratorExpression::PreprocessContext, - ImportPropertyMap& properties, - std::vector& missingTargets); + ImportPropertyMap& properties); bool PopulateInterfaceLinkLibrariesProperty( cmGeneratorTarget const* target, cmGeneratorExpression::PreprocessContext, - ImportPropertyMap& properties, std::vector& missingTargets); + ImportPropertyMap& properties); void PopulateInterfaceProperty(const std::string& propName, cmGeneratorTarget const* target, ImportPropertyMap& properties); @@ -149,26 +143,24 @@ protected: void PopulateIncludeDirectoriesInterface( cmGeneratorTarget const* target, cmGeneratorExpression::PreprocessContext preprocessRule, - ImportPropertyMap& properties, std::vector& missingTargets, - cmTargetExport const& te); + ImportPropertyMap& properties, cmTargetExport const& te); void PopulateSourcesInterface( cmGeneratorTarget const* target, cmGeneratorExpression::PreprocessContext preprocessRule, - ImportPropertyMap& properties, std::vector& missingTargets); + ImportPropertyMap& properties); void PopulateLinkDirectoriesInterface( cmGeneratorTarget const* target, cmGeneratorExpression::PreprocessContext preprocessRule, - ImportPropertyMap& properties, std::vector& missingTargets); + ImportPropertyMap& properties); void PopulateLinkDependsInterface( cmGeneratorTarget const* target, cmGeneratorExpression::PreprocessContext preprocessRule, - ImportPropertyMap& properties, std::vector& missingTargets); + ImportPropertyMap& properties); void SetImportLinkInterface( const std::string& config, std::string const& suffix, cmGeneratorExpression::PreprocessContext preprocessRule, - cmGeneratorTarget const* target, ImportPropertyMap& properties, - std::vector& missingTargets); + cmGeneratorTarget const* target, ImportPropertyMap& properties); enum FreeTargetsReplace { @@ -178,7 +170,6 @@ protected: void ResolveTargetsInGeneratorExpressions( std::string& input, cmGeneratorTarget const* target, - std::vector& missingTargets, FreeTargetsReplace replace = NoReplaceFreeTargets); virtual void GenerateRequiredCMakeVersion(std::ostream& os, @@ -216,20 +207,20 @@ protected: // The set of targets included in the export. std::set ExportedTargets; + std::vector MissingTargets; + private: void PopulateInterfaceProperty(const std::string&, const std::string&, cmGeneratorTarget const* target, cmGeneratorExpression::PreprocessContext, - ImportPropertyMap& properties, - std::vector& missingTargets); + ImportPropertyMap& properties); bool AddTargetNamespace(std::string& input, cmGeneratorTarget const* target, - cmLocalGenerator const* lg, - std::vector& missingTargets); + cmLocalGenerator const* lg); - void ResolveTargetsInGeneratorExpression( - std::string& input, cmGeneratorTarget const* target, - cmLocalGenerator const* lg, std::vector& missingTargets); + void ResolveTargetsInGeneratorExpression(std::string& input, + cmGeneratorTarget const* target, + cmLocalGenerator const* lg); virtual void ReplaceInstallPrefix(std::string& input); diff --git a/Source/cmExportInstallAndroidMKGenerator.cxx b/Source/cmExportInstallAndroidMKGenerator.cxx index 80f776e..4e4f8a1 100644 --- a/Source/cmExportInstallAndroidMKGenerator.cxx +++ b/Source/cmExportInstallAndroidMKGenerator.cxx @@ -5,6 +5,7 @@ #include #include #include +#include #include "cmExportBuildAndroidMKGenerator.h" #include "cmExportSet.h" @@ -86,7 +87,7 @@ void cmExportInstallAndroidMKGenerator::GenerateImportPropertyCode( } void cmExportInstallAndroidMKGenerator::GenerateMissingTargetsCheckCode( - std::ostream&, const std::vector&) + std::ostream&) { } @@ -132,7 +133,7 @@ void cmExportInstallAndroidMKGenerator::GenerateImportedFileChecksCode( } bool cmExportInstallAndroidMKGenerator::GenerateImportFileConfig( - const std::string&, std::vector&) + const std::string&) { return true; } diff --git a/Source/cmExportInstallAndroidMKGenerator.h b/Source/cmExportInstallAndroidMKGenerator.h index 40978e0..c05751a 100644 --- a/Source/cmExportInstallAndroidMKGenerator.h +++ b/Source/cmExportInstallAndroidMKGenerator.h @@ -7,7 +7,6 @@ #include #include #include -#include #include "cmExportFileGenerator.h" #include "cmExportInstallFileGenerator.h" @@ -50,8 +49,7 @@ protected: std::ostream& os, const std::string& config, cmGeneratorTarget const* target, ImportPropertyMap const& properties) override; - void GenerateMissingTargetsCheckCode( - std::ostream& os, const std::vector& missingTargets) override; + void GenerateMissingTargetsCheckCode(std::ostream& os) override; void GenerateInterfaceProperties( cmGeneratorTarget const* target, std::ostream& os, const ImportPropertyMap& properties) override; @@ -65,6 +63,5 @@ protected: std::ostream& os, cmGeneratorTarget* target, ImportPropertyMap const& properties, const std::set& importedLocations) override; - bool GenerateImportFileConfig(const std::string& config, - std::vector&) override; + bool GenerateImportFileConfig(const std::string& config) override; }; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index f232440..0c41946 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -71,8 +71,6 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) // Compute the relative import prefix for the file this->GenerateImportPrefix(os); - std::vector missingTargets; - bool require2_8_12 = false; bool require3_0_0 = false; bool require3_1_0 = false; @@ -90,35 +88,34 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) ImportPropertyMap properties; this->PopulateIncludeDirectoriesInterface( - gt, cmGeneratorExpression::InstallInterface, properties, missingTargets, - *te); + gt, cmGeneratorExpression::InstallInterface, properties, *te); this->PopulateSourcesInterface(gt, cmGeneratorExpression::InstallInterface, - properties, missingTargets); + properties); this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", gt, cmGeneratorExpression::InstallInterface, - properties, missingTargets); + properties); this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", gt, cmGeneratorExpression::InstallInterface, - properties, missingTargets); + properties); this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", gt, cmGeneratorExpression::InstallInterface, - properties, missingTargets); + properties); this->PopulateInterfaceProperty("INTERFACE_PRECOMPILE_HEADERS", gt, cmGeneratorExpression::InstallInterface, - properties, missingTargets); + properties); this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", gt, cmGeneratorExpression::InstallInterface, - properties, missingTargets); + properties); this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", gt, cmGeneratorExpression::InstallInterface, - properties, missingTargets); + properties); this->PopulateInterfaceProperty("INTERFACE_LINK_OPTIONS", gt, cmGeneratorExpression::InstallInterface, - properties, missingTargets); + properties); this->PopulateLinkDirectoriesInterface( - gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); + gt, cmGeneratorExpression::InstallInterface, properties); this->PopulateLinkDependsInterface( - gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); + gt, cmGeneratorExpression::InstallInterface, properties); std::string errorMessage; if (!this->PopulateExportProperties(gt, properties, errorMessage)) { @@ -131,8 +128,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) gt->GetPolicyStatusCMP0022() != cmPolicies::OLD; if (newCMP0022Behavior) { if (this->PopulateInterfaceLinkLibrariesProperty( - gt, cmGeneratorExpression::InstallInterface, properties, - missingTargets) && + gt, cmGeneratorExpression::InstallInterface, properties) && !this->ExportOld) { require2_8_12 = true; } @@ -174,13 +170,13 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) // Don't do this if we only export INTERFACE_LIBRARY targets. if (requiresConfigFiles) { for (std::string const& c : this->Configurations) { - if (!this->GenerateImportFileConfig(c, missingTargets)) { + if (!this->GenerateImportFileConfig(c)) { result = false; } } } - this->GenerateMissingTargetsCheckCode(os, missingTargets); + this->GenerateMissingTargetsCheckCode(os); return result; } @@ -273,7 +269,7 @@ void cmExportInstallFileGenerator::ReplaceInstallPrefix(std::string& input) } bool cmExportInstallFileGenerator::GenerateImportFileConfig( - const std::string& config, std::vector& missingTargets) + const std::string& config) { // Skip configurations not enabled for this export. if (!this->IEGen->InstallsForConfig(config)) { @@ -305,7 +301,7 @@ bool cmExportInstallFileGenerator::GenerateImportFileConfig( this->GenerateImportHeaderCode(os, config); // Generate the per-config target information. - this->GenerateImportConfig(os, config, missingTargets); + this->GenerateImportConfig(os, config); // End with the import file footer. this->GenerateImportFooterCode(os); @@ -317,8 +313,7 @@ bool cmExportInstallFileGenerator::GenerateImportFileConfig( } void cmExportInstallFileGenerator::GenerateImportTargetsConfig( - std::ostream& os, const std::string& config, std::string const& suffix, - std::vector& missingTargets) + std::ostream& os, const std::string& config, std::string const& suffix) { // Add each target in the set to the export. for (std::unique_ptr const& te : @@ -350,12 +345,11 @@ void cmExportInstallFileGenerator::GenerateImportTargetsConfig( if (!properties.empty()) { // Get the rest of the target details. cmGeneratorTarget* gtgt = te->Target; - this->SetImportDetailProperties(config, suffix, gtgt, properties, - missingTargets); + this->SetImportDetailProperties(config, suffix, gtgt, properties); this->SetImportLinkInterface(config, suffix, cmGeneratorExpression::InstallInterface, - gtgt, properties, missingTargets); + gtgt, properties); // TODO: PUBLIC_HEADER_LOCATION // This should wait until the build feature propagation stuff @@ -454,8 +448,8 @@ cmStateEnums::TargetType cmExportInstallFileGenerator::GetExportTargetType( } void cmExportInstallFileGenerator::HandleMissingTarget( - std::string& link_libs, std::vector& missingTargets, - cmGeneratorTarget const* depender, cmGeneratorTarget* dependee) + std::string& link_libs, cmGeneratorTarget const* depender, + cmGeneratorTarget* dependee) { const std::string name = dependee->GetName(); cmGlobalGenerator* gg = dependee->GetLocalGenerator()->GetGlobalGenerator(); @@ -466,7 +460,7 @@ void cmExportInstallFileGenerator::HandleMissingTarget( missingTarget += dependee->GetExportName(); link_libs += missingTarget; - missingTargets.push_back(std::move(missingTarget)); + this->MissingTargets.emplace_back(std::move(missingTarget)); } else { // All exported targets should be known here and should be unique. // This is probably user-error. diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index 9374c6b..86fb505 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -57,13 +57,11 @@ public: protected: // Implement virtual methods from the superclass. bool GenerateMainFile(std::ostream& os) override; - void GenerateImportTargetsConfig( - std::ostream& os, const std::string& config, std::string const& suffix, - std::vector& missingTargets) override; + void GenerateImportTargetsConfig(std::ostream& os, const std::string& config, + std::string const& suffix) override; cmStateEnums::TargetType GetExportTargetType( cmTargetExport const* targetExport) const; void HandleMissingTarget(std::string& link_libs, - std::vector& missingTargets, cmGeneratorTarget const* depender, cmGeneratorTarget* dependee) override; @@ -85,8 +83,7 @@ protected: virtual void CleanupTemporaryVariables(std::ostream&); /** Generate a per-configuration file for the targets. */ - virtual bool GenerateImportFileConfig( - const std::string& config, std::vector& missingTargets); + virtual bool GenerateImportFileConfig(const std::string& config); /** Fill in properties indicating installed file locations. */ void SetImportLocationProperty(const std::string& config, diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 8a1fd7e..1dd8a20 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -33,12 +33,10 @@ protected: bool GenerateMainFile(std::ostream& os) override; void GenerateImportTargetsConfig(std::ostream&, const std::string&, - std::string const&, - std::vector&) override + std::string const&) override { } - void HandleMissingTarget(std::string&, std::vector&, - cmGeneratorTarget const*, + void HandleMissingTarget(std::string&, cmGeneratorTarget const*, cmGeneratorTarget*) override { } -- cgit v0.12