From 4f009d2121ac5f46e21786c7d60eb11e2e33c05d Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 28 Jan 2023 10:55:55 -0500 Subject: cmTarget: refactor LINK_DIRECTORIES usage requirements --- Source/cmTarget.cxx | 49 ++++++++++++++----------------------------------- 1 file changed, 14 insertions(+), 35 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9f539f9..1055a9a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -305,7 +305,6 @@ public: std::map> LanguageStandardProperties; std::map> InstallIncludeDirectoriesEntries; - std::vector> LinkDirectoriesEntries; std::vector> LinkImplementationPropertyEntries; std::vector> LinkInterfacePropertyEntries; std::vector> LinkInterfaceDirectPropertyEntries; @@ -322,6 +321,7 @@ public: UsageRequirementProperty PrecompileHeaders; UsageRequirementProperty Sources; UsageRequirementProperty LinkOptions; + UsageRequirementProperty LinkDirectories; FileSetType HeadersFileSets; FileSetType CxxModulesFileSets; @@ -365,6 +365,7 @@ cmTargetInternals::cmTargetInternals() , PrecompileHeaders("PRECOMPILE_HEADERS"_s) , Sources("SOURCES"_s, UsageRequirementProperty::AppendEmpty::Yes) , LinkOptions("LINK_OPTIONS"_s) + , LinkDirectories("LINK_DIRECTORIES"_s) , HeadersFileSets("HEADERS"_s, "HEADER_DIRS"_s, "HEADER_SET"_s, "HEADER_DIRS_"_s, "HEADER_SET_"_s, "Header"_s, "The default header set"_s, "Header set"_s, @@ -852,9 +853,8 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->impl->Makefile->GetCompileOptionsEntries()); this->impl->LinkOptions.CopyFromDirectory( this->impl->Makefile->GetLinkOptionsEntries()); - - cm::append(this->impl->LinkDirectoriesEntries, - this->impl->Makefile->GetLinkDirectoriesEntries()); + this->impl->LinkDirectories.CopyFromDirectory( + this->impl->Makefile->GetLinkDirectoriesEntries()); } if (this->impl->TargetType == cmStateEnums::EXECUTABLE) { @@ -1493,7 +1493,7 @@ cmBTStringRange cmTarget::GetLinkOptionsEntries() const cmBTStringRange cmTarget::GetLinkDirectoriesEntries() const { - return cmMakeRange(this->impl->LinkDirectoriesEntries); + return cmMakeRange(this->impl->LinkDirectories.Entries); } cmBTStringRange cmTarget::GetLinkImplementationEntries() const @@ -1646,7 +1646,7 @@ void cmTarget::StoreProperty(const std::string& prop, ValueType value) &this->impl->IncludeDirectories, &this->impl->CompileOptions, &this->impl->CompileFeatures, &this->impl->CompileDefinitions, &this->impl->PrecompileHeaders, &this->impl->Sources, - &this->impl->LinkOptions, + &this->impl->LinkOptions, &this->impl->LinkDirectories, }; for (auto* usageRequirement : usageRequirements) { @@ -1669,13 +1669,7 @@ void cmTarget::StoreProperty(const std::string& prop, ValueType value) } } - if (prop == propLINK_DIRECTORIES) { - this->impl->LinkDirectoriesEntries.clear(); - if (value) { - cmListFileBacktrace lfbt = this->impl->Makefile->GetBacktrace(); - this->impl->LinkDirectoriesEntries.emplace_back(value, lfbt); - } - } else if (prop == propLINK_LIBRARIES) { + if (prop == propLINK_LIBRARIES) { this->impl->LinkImplementationPropertyEntries.clear(); if (value) { cmListFileBacktrace lfbt = this->impl->Makefile->GetBacktrace(); @@ -1819,7 +1813,7 @@ void cmTarget::AppendProperty(const std::string& prop, &this->impl->IncludeDirectories, &this->impl->CompileOptions, &this->impl->CompileFeatures, &this->impl->CompileDefinitions, &this->impl->PrecompileHeaders, &this->impl->Sources, - &this->impl->LinkOptions, + &this->impl->LinkOptions, &this->impl->LinkDirectories, }; for (auto* usageRequirement : usageRequirements) { @@ -1842,12 +1836,7 @@ void cmTarget::AppendProperty(const std::string& prop, } } - if (prop == "LINK_DIRECTORIES") { - if (!value.empty()) { - cmListFileBacktrace lfbt = this->impl->GetBacktrace(bt); - this->impl->LinkDirectoriesEntries.emplace_back(value, lfbt); - } - } else if (prop == "LINK_LIBRARIES") { + if (prop == "LINK_LIBRARIES") { if (!value.empty()) { cmListFileBacktrace lfbt = this->impl->GetBacktrace(bt); this->impl->LinkImplementationPropertyEntries.emplace_back(value, lfbt); @@ -2142,10 +2131,10 @@ void cmTarget::InsertLinkOption(BT const& entry, bool before) void cmTarget::InsertLinkDirectory(BT const& entry, bool before) { - auto position = before ? this->impl->LinkDirectoriesEntries.begin() - : this->impl->LinkDirectoriesEntries.end(); - - this->impl->LinkDirectoriesEntries.insert(position, entry); + this->impl->LinkDirectories.WriteDirect( + entry, + before ? UsageRequirementProperty::Action::Prepend + : UsageRequirementProperty::Action::Append); } void cmTarget::InsertPrecompileHeader(BT const& entry) @@ -2301,7 +2290,7 @@ cmValue cmTarget::GetProperty(const std::string& prop) const &this->impl->IncludeDirectories, &this->impl->CompileOptions, &this->impl->CompileFeatures, &this->impl->CompileDefinitions, &this->impl->PrecompileHeaders, &this->impl->Sources, - &this->impl->LinkOptions, + &this->impl->LinkOptions, &this->impl->LinkDirectories, }; for (auto const* usageRequirement : usageRequirements) { @@ -2352,16 +2341,6 @@ cmValue cmTarget::GetProperty(const std::string& prop) const if (prop == propTYPE) { return cmValue(cmState::GetTargetTypeName(this->GetType())); } - if (prop == propLINK_DIRECTORIES) { - if (this->impl->LinkDirectoriesEntries.empty()) { - return nullptr; - } - - static std::string output; - output = cmJoin(this->impl->LinkDirectoriesEntries, ";"); - - return cmValue(output); - } if (prop == propMANUALLY_ADDED_DEPENDENCIES) { if (this->impl->Utilities.empty()) { return nullptr; -- cgit v0.12