cmLocalGenerator: De-duplicate static linker flags lookup

Be sure to obey CMP0181 by not applying `LINKER:` expansion etc. to
the flags in this variable, unlike shared library, module library, and
executable targets.
This commit is contained in:
Tyler Yankee
2026-01-27 13:57:51 -05:00
parent bc1847c70b
commit 5ecee0db7b

View File

@@ -1405,24 +1405,18 @@ std::vector<BT<std::string>> cmLocalGenerator::GetStaticLibraryFlags(
std::string const& config, std::string const& linkLanguage,
cmGeneratorTarget* target)
{
std::string const configUpper = cmSystemTools::UpperCase(config);
std::vector<BT<std::string>> flags;
if (linkLanguage != "Swift" && !this->IsSplitSwiftBuild()) {
std::string staticLibFlags;
this->AppendFlags(
staticLibFlags,
this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS"));
if (!configUpper.empty()) {
std::string name = "CMAKE_STATIC_LINKER_FLAGS_" + configUpper;
this->AppendFlags(staticLibFlags,
this->Makefile->GetSafeDefinition(name));
}
this->AddConfigVariableFlags(staticLibFlags, "CMAKE_STATIC_LINKER_FLAGS",
config);
if (!staticLibFlags.empty()) {
flags.emplace_back(std::move(staticLibFlags));
}
}
std::string staticLibFlags;
std::string const configUpper = cmSystemTools::UpperCase(config);
this->AppendFlags(staticLibFlags,
target->GetSafeProperty("STATIC_LIBRARY_FLAGS"));
if (!configUpper.empty()) {