diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2023-09-27 13:22:55 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2023-10-13 09:52:35 (GMT) |
commit | 96a953b1ed7e41260aa0869bad0ff14c788cf57e (patch) | |
tree | d9bedd8494b073f3795e4ed80f01b22a2b5a9093 /Source/cmRulePlaceholderExpander.cxx | |
parent | ee5f31ba727e392e1ebc9f5be54c74ac1868d029 (diff) | |
download | CMake-96a953b1ed7e41260aa0869bad0ff14c788cf57e.zip CMake-96a953b1ed7e41260aa0869bad0ff14c788cf57e.tar.gz CMake-96a953b1ed7e41260aa0869bad0ff14c788cf57e.tar.bz2 |
Add options to specify linker tool
Offer the capability, through variable `CMAKE_LINKER_TYPE`, as well as
the target property `LINKER_TYPE` to specify which linker must be used.
The implementation of this capability is specified by variables specific
to the language and linker type: `CMAKE_<LANG>_USING_LINKER_<TYPE>`.
Some definitions are provided as part of `CMake`.
For example, to select the `LLVM` linker rather than the standard one,
the type `LLD` should be specified through the variable `CMAKE_LINKER_TYPE`.
And, on `Apple`, `Linux` and some environments on `Windows`, the variable
`CMAKE_<LANG>_USING_LINKER_LLD` has value `-fuse-ld=lld`. And for `Windows`
environments based on `MSVC`, where the linker is used directly, the tool
`lld-link.exe` will be used rather than `link.exe`.
Fixes: #19174, #24254, #24990
Diffstat (limited to 'Source/cmRulePlaceholderExpander.cxx')
-rw-r--r-- | Source/cmRulePlaceholderExpander.cxx | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx index 638bb42..a8c81d0 100644 --- a/Source/cmRulePlaceholderExpander.cxx +++ b/Source/cmRulePlaceholderExpander.cxx @@ -27,6 +27,19 @@ std::string cmRulePlaceholderExpander::ExpandVariable( return this->ReplaceValues->LinkFlags; } } + if (this->ReplaceValues->Linker) { + if (variable == "CMAKE_LINKER") { + auto result = this->OutputConverter->ConvertToOutputForExisting( + this->ReplaceValues->Linker); + if (this->ReplaceValues->Launcher) { + // Add launcher as part of expansion so that it always appears + // immediately before the command itself, regardless of whether the + // overall rule template contains other content at the front. + result = cmStrCat(this->ReplaceValues->Launcher, " ", result); + } + return result; + } + } if (this->ReplaceValues->Manifests) { if (variable == "MANIFESTS") { return this->ReplaceValues->Manifests; @@ -325,17 +338,7 @@ std::string cmRulePlaceholderExpander::ExpandVariable( auto mapIt = this->VariableMappings.find(variable); if (mapIt != this->VariableMappings.end()) { if (variable.find("_FLAG") == std::string::npos) { - std::string ret = - this->OutputConverter->ConvertToOutputForExisting(mapIt->second); - - if (this->ReplaceValues->Launcher && variable == "CMAKE_LINKER") { - // Add launcher as part of expansion so that it always appears - // immediately before the command itself, regardless of whether the - // overall rule template contains other content at the front. - ret = cmStrCat(this->ReplaceValues->Launcher, " ", ret); - } - - return ret; + return this->OutputConverter->ConvertToOutputForExisting(mapIt->second); } return mapIt->second; } |