Ninja,Makefile: Move builtin linker flags to <LINK_FLAGS> placeholder

Previously we used separate placeholders for builtin linker flags:

* CMAKE_<LANG>_LINK_FLAGS for EXECUTABLEs
* CMAKE_SHARED_LIBRARY_CREATE_<LANG>_FLAGS for SHARED libraries
* CMAKE_SHARED_MODULE_CREATE_<LANG>_FLAGS for MODULE libraries

These correspond to variables set by our compiler information modules.
Teach the generators to look up these variables and add them to the
existing `<LINK_FLAGS>` placeholder instead.  Substitute the empty
string for the old placeholders.

Issue: #21934
This commit is contained in:
Brad King
2025-06-09 15:46:22 -04:00
parent 6b618c6079
commit 951e4d3f62
4 changed files with 72 additions and 45 deletions

View File

@@ -371,6 +371,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
std::string linkFlags;
// Add flags to create an executable.
this->LocalGenerator->AppendTargetCreationLinkFlags(
linkFlags, this->GeneratorTarget, linkLanguage);
this->LocalGenerator->AddConfigVariableFlags(
linkFlags, "CMAKE_EXE_LINKER_FLAGS", this->GeneratorTarget,
cmBuildStep::Link, linkLanguage, this->GetConfigName());