mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
cmLocalGenerator: De-duplicate target property link flags lookup
This commit is contained in:
@@ -2705,18 +2705,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
|
||||
this->CurrentLocalGenerator->AppendWarningAsErrorLinkerFlags(
|
||||
extraLinkOptions, gtgt, llang);
|
||||
|
||||
cmValue targetLinkFlags = gtgt->GetProperty("LINK_FLAGS");
|
||||
if (targetLinkFlags) {
|
||||
this->CurrentLocalGenerator->AppendFlags(extraLinkOptions,
|
||||
*targetLinkFlags);
|
||||
}
|
||||
if (!configName.empty()) {
|
||||
std::string linkFlagsVar =
|
||||
cmStrCat("LINK_FLAGS_", cmSystemTools::UpperCase(configName));
|
||||
if (cmValue linkFlags = gtgt->GetProperty(linkFlagsVar)) {
|
||||
this->CurrentLocalGenerator->AppendFlags(extraLinkOptions, *linkFlags);
|
||||
}
|
||||
}
|
||||
this->CurrentLocalGenerator->AddTargetPropertyLinkFlags(extraLinkOptions,
|
||||
gtgt, configName);
|
||||
|
||||
std::vector<std::string> opts;
|
||||
gtgt->GetLinkOptions(opts, configName, llang);
|
||||
// LINK_OPTIONS are escaped.
|
||||
|
||||
+19
-27
@@ -1532,20 +1532,7 @@ void cmLocalGenerator::GetTargetFlags(
|
||||
}
|
||||
|
||||
std::string sharedLibFlags;
|
||||
cmValue targetLinkFlags = target->GetProperty("LINK_FLAGS");
|
||||
if (targetLinkFlags) {
|
||||
sharedLibFlags += *targetLinkFlags;
|
||||
sharedLibFlags += " ";
|
||||
}
|
||||
if (!configUpper.empty()) {
|
||||
targetLinkFlags =
|
||||
target->GetProperty(cmStrCat("LINK_FLAGS_", configUpper));
|
||||
if (targetLinkFlags) {
|
||||
sharedLibFlags += *targetLinkFlags;
|
||||
sharedLibFlags += " ";
|
||||
}
|
||||
}
|
||||
|
||||
this->AddTargetPropertyLinkFlags(sharedLibFlags, target, config);
|
||||
if (!sharedLibFlags.empty()) {
|
||||
this->GetGlobalGenerator()->EncodeLiteral(sharedLibFlags);
|
||||
linkFlags.emplace_back(std::move(sharedLibFlags));
|
||||
@@ -1610,19 +1597,7 @@ void cmLocalGenerator::GetTargetFlags(
|
||||
exeFlags += " ";
|
||||
}
|
||||
|
||||
cmValue targetLinkFlags = target->GetProperty("LINK_FLAGS");
|
||||
if (targetLinkFlags) {
|
||||
exeFlags += *targetLinkFlags;
|
||||
exeFlags += " ";
|
||||
}
|
||||
if (!configUpper.empty()) {
|
||||
targetLinkFlags =
|
||||
target->GetProperty(cmStrCat("LINK_FLAGS_", configUpper));
|
||||
if (targetLinkFlags) {
|
||||
exeFlags += *targetLinkFlags;
|
||||
exeFlags += " ";
|
||||
}
|
||||
}
|
||||
this->AddTargetPropertyLinkFlags(exeFlags, target, config);
|
||||
|
||||
if (!exeFlags.empty()) {
|
||||
this->GetGlobalGenerator()->EncodeLiteral(exeFlags);
|
||||
@@ -3479,6 +3454,23 @@ void cmLocalGenerator::AddTargetTypeLinkerFlags(
|
||||
cmBuildStep::Link, lang, config);
|
||||
}
|
||||
|
||||
void cmLocalGenerator::AddTargetPropertyLinkFlags(
|
||||
std::string& flags, cmGeneratorTarget const* target,
|
||||
std::string const& config)
|
||||
{
|
||||
cmValue targetLinkFlags = target->GetProperty("LINK_FLAGS");
|
||||
if (targetLinkFlags) {
|
||||
this->AppendFlags(flags, *targetLinkFlags);
|
||||
}
|
||||
if (!config.empty()) {
|
||||
cmValue targetLinkFlagsConfig = target->GetProperty(
|
||||
cmStrCat("LINK_FLAGS_", cmSystemTools::UpperCase(config)));
|
||||
if (targetLinkFlagsConfig) {
|
||||
this->AppendFlags(flags, *targetLinkFlagsConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cmLocalGenerator::AppendIPOLinkerFlags(std::string& flags,
|
||||
cmGeneratorTarget* target,
|
||||
std::string const& config,
|
||||
|
||||
@@ -187,6 +187,9 @@ public:
|
||||
cmGeneratorTarget const* target,
|
||||
std::string const& lang,
|
||||
std::string const& config);
|
||||
void AddTargetPropertyLinkFlags(std::string& flags,
|
||||
cmGeneratorTarget const* target,
|
||||
std::string const& config);
|
||||
void AppendIPOLinkerFlags(std::string& flags, cmGeneratorTarget* target,
|
||||
std::string const& config,
|
||||
std::string const& lang);
|
||||
|
||||
@@ -970,18 +970,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
|
||||
this->AddTargetTypeLinkerFlags(extraLinkOptions, target, linkLanguage,
|
||||
configName);
|
||||
|
||||
cmValue targetLinkFlags = target->GetProperty("LINK_FLAGS");
|
||||
if (targetLinkFlags) {
|
||||
extraLinkOptions += ' ';
|
||||
extraLinkOptions += *targetLinkFlags;
|
||||
}
|
||||
std::string configTypeUpper = cmSystemTools::UpperCase(configName);
|
||||
std::string linkFlagsConfig = cmStrCat("LINK_FLAGS_", configTypeUpper);
|
||||
targetLinkFlags = target->GetProperty(linkFlagsConfig);
|
||||
if (targetLinkFlags) {
|
||||
extraLinkOptions += ' ';
|
||||
extraLinkOptions += *targetLinkFlags;
|
||||
}
|
||||
this->AddTargetPropertyLinkFlags(extraLinkOptions, target, configName);
|
||||
|
||||
std::vector<std::string> opts;
|
||||
target->GetLinkOptions(opts, configName,
|
||||
|
||||
@@ -138,13 +138,8 @@ void cmMakefileTargetGenerator::GetDeviceLinkFlags(
|
||||
void cmMakefileTargetGenerator::GetTargetLinkFlags(
|
||||
std::string& flags, std::string const& linkLanguage)
|
||||
{
|
||||
this->LocalGenerator->AppendFlags(
|
||||
flags, this->GeneratorTarget->GetSafeProperty("LINK_FLAGS"));
|
||||
|
||||
std::string const linkFlagsConfig =
|
||||
cmStrCat("LINK_FLAGS_", cmSystemTools::UpperCase(this->GetConfigName()));
|
||||
this->LocalGenerator->AppendFlags(
|
||||
flags, this->GeneratorTarget->GetSafeProperty(linkFlagsConfig));
|
||||
this->LocalGenerator->AddTargetPropertyLinkFlags(
|
||||
flags, this->GeneratorTarget, this->GetConfigName());
|
||||
|
||||
std::vector<std::string> opts;
|
||||
this->GeneratorTarget->GetLinkOptions(opts, this->GetConfigName(),
|
||||
|
||||
@@ -4541,22 +4541,12 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string CONFIG = cmSystemTools::UpperCase(config);
|
||||
|
||||
std::string flags;
|
||||
this->LocalGenerator->AddTargetTypeLinkerFlags(flags, this->GeneratorTarget,
|
||||
linkLanguage, config);
|
||||
|
||||
cmValue targetLinkFlags = this->GeneratorTarget->GetProperty("LINK_FLAGS");
|
||||
if (targetLinkFlags) {
|
||||
flags += ' ';
|
||||
flags += *targetLinkFlags;
|
||||
}
|
||||
std::string flagsProp = cmStrCat("LINK_FLAGS_", CONFIG);
|
||||
if (cmValue flagsConfig = this->GeneratorTarget->GetProperty(flagsProp)) {
|
||||
flags += ' ';
|
||||
flags += *flagsConfig;
|
||||
}
|
||||
this->LocalGenerator->AddTargetPropertyLinkFlags(
|
||||
flags, this->GeneratorTarget, config);
|
||||
|
||||
std::vector<std::string> opts;
|
||||
this->GeneratorTarget->GetLinkOptions(opts, config, linkLanguage);
|
||||
|
||||
Reference in New Issue
Block a user