diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2023-04-19 14:01:10 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2023-05-03 15:08:07 (GMT) |
commit | 375e6fdbbe398921de321216125765ba1917a325 (patch) | |
tree | 43d934f18f4d28a82d5264a0d0fb0301bc0bf7d9 /Source/cmLocalGenerator.cxx | |
parent | 24a3e5cda049138ca178216e0d7b02262e4035ed (diff) | |
download | CMake-375e6fdbbe398921de321216125765ba1917a325.zip CMake-375e6fdbbe398921de321216125765ba1917a325.tar.gz CMake-375e6fdbbe398921de321216125765ba1917a325.tar.bz2 |
Link step: use linker dependency linker file
Based on work done by @ben.boeckel (!8051)
Fixes: #22217
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 64f0246..b02fa62 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1586,6 +1586,8 @@ void cmLocalGenerator::GetTargetFlags( this->AppendPositionIndependentLinkerFlags(extraLinkFlags, target, config, linkLanguage); this->AppendIPOLinkerFlags(extraLinkFlags, target, config, linkLanguage); + this->AppendDependencyInfoLinkerFlags(extraLinkFlags, target, config, + linkLanguage); this->AppendModuleDefinitionFlag(extraLinkFlags, target, linkLineComputer, config); @@ -3202,6 +3204,42 @@ void cmLocalGenerator::AppendPositionIndependentLinkerFlags( } } +void cmLocalGenerator::AppendDependencyInfoLinkerFlags( + std::string& flags, cmGeneratorTarget* target, const std::string& config, + const std::string& linkLanguage) +{ + if (!this->GetGlobalGenerator()->SupportsLinkerDependencyFile() || + !target->HasLinkDependencyFile(config)) { + return; + } + + auto depFlag = *this->Makefile->GetDefinition( + cmStrCat("CMAKE_", linkLanguage, "_LINKER_DEPFILE_FLAGS")); + if (depFlag.empty()) { + return; + } + + auto depFile = this->ConvertToOutputFormat( + this->MaybeRelativeToWorkDir(this->GetLinkDependencyFile(target, config)), + cmOutputConverter::SHELL); + std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander( + this->CreateRulePlaceholderExpander()); + cmRulePlaceholderExpander::RuleVariables linkDepsVariables; + linkDepsVariables.DependencyFile = depFile.c_str(); + rulePlaceholderExpander->ExpandRuleVariables(this, depFlag, + linkDepsVariables); + auto depFlags = cmExpandListWithBacktrace(depFlag); + target->ResolveLinkerWrapper(depFlags, linkLanguage); + + this->AppendFlags(flags, depFlags); +} + +std::string cmLocalGenerator::GetLinkDependencyFile( + cmGeneratorTarget* /*target*/, const std::string& /*config*/) const +{ + return "link.d"; +} + void cmLocalGenerator::AppendModuleDefinitionFlag( std::string& flags, cmGeneratorTarget const* target, cmLinkLineComputer* linkLineComputer, std::string const& config) |