mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
LINK_LIBRARIES: Evaluate separately for linking and usage requirements
We evaluate `LINK_LIBRARIES` and `INTERFACE_LINK_LIBRARIES` for two purposes: * Constructing the link line. * Collecting usage requirements. We evaluate `INTERFACE_LINK_LIBRARIES` separately for each purpose in order to support the `$<LINK_ONLY:...>` generator expression used to express private link dependencies of a static library. Previously we only evaluated `LINK_LIBRARIES` for linking, and used that result for collecting usage requirements too. Therefore `$<LINK_ONLY:...>` does not work in `LINK_LIBRARIES`. With the introduction of `INTERFACE_LINK_LIBRARIES_DIRECT`, evaluation of `LINK_LIBRARIES` now needs to distinguish these two cases in order to honor link dependencies encountered through `$<LINK_ONLY:...>` without also exposing other usage requirements through private dependencies of a static library. Revise internal infrastructure to distinguish the two cases when evaluating `LINK_LIBRARIES`. Make the information available in code paths for `INTERFACE_LINK_LIBRARIES_DIRECT` and `LINK_ONLY`. Defer actually using the information to later commits. Issue: #22496
This commit is contained in:
@@ -1415,7 +1415,8 @@ static std::string getLinkedTargetsContent(
|
||||
{
|
||||
std::string result;
|
||||
if (cmLinkImplementationLibraries const* impl =
|
||||
target->GetLinkImplementationLibraries(context->Config)) {
|
||||
target->GetLinkImplementationLibraries(
|
||||
context->Config, cmGeneratorTarget::LinkInterfaceFor::Usage)) {
|
||||
for (cmLinkImplItem const& lib : impl->Libraries) {
|
||||
if (lib.Target) {
|
||||
// Pretend $<TARGET_PROPERTY:lib.Target,prop> appeared in our
|
||||
|
||||
Reference in New Issue
Block a user