diff options
author | Brad King <brad.king@kitware.com> | 2022-03-22 13:49:11 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-03-22 15:57:48 (GMT) |
commit | 41a6b4a53ba844ef986b0bc4efe8938b97eea810 (patch) | |
tree | dfb3e49b2b54cb24865ecf15d67cc3d8ba52c55f /Help/prop_tgt/INTERFACE_LINK_LIBRARIES_DIRECT.rst | |
parent | 73337cb383a704664a47fd3fec84c8feaa303995 (diff) | |
download | CMake-41a6b4a53ba844ef986b0bc4efe8938b97eea810.zip CMake-41a6b4a53ba844ef986b0bc4efe8938b97eea810.tar.gz CMake-41a6b4a53ba844ef986b0bc4efe8938b97eea810.tar.bz2 |
INTERFACE_LINK_LIBRARIES_DIRECT: Honor link dependencies through LINK_ONLY
In commit f3ad061858 (Add usage requirements to update direct link
dependencies, 2022-01-12, v3.23.0-rc1~44^2), we evaluated the transitive
closure of `INTERFACE_LINK_LIBRARIES` as a non-linking usage requirement.
That left out `INTERFACE_LINK_LIBRARIES_DIRECT` link dependencies that
appear behind private dependencies of a static library, guarded by the
`$<LINK_ONLY:...>` generator expression. At the time, that decision was
intentional, in order to prevent arbitrary usage requirements from
leaking out of `PRIVATE` dependencies.
Since then, we've revised evaluation of `LINK_LIBRARIES` to distinguish
between collecting link dependencies and other usage requirements. Use
that information when following `INTERFACE_LINK_LIBRARIES` to collect
the matching kind of requirements from `INTERFACE_LINK_LIBRARIES_DIRECT`.
Fixes: #22496
Diffstat (limited to 'Help/prop_tgt/INTERFACE_LINK_LIBRARIES_DIRECT.rst')
-rw-r--r-- | Help/prop_tgt/INTERFACE_LINK_LIBRARIES_DIRECT.rst | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/Help/prop_tgt/INTERFACE_LINK_LIBRARIES_DIRECT.rst b/Help/prop_tgt/INTERFACE_LINK_LIBRARIES_DIRECT.rst index aa8cc2e..b8b73df 100644 --- a/Help/prop_tgt/INTERFACE_LINK_LIBRARIES_DIRECT.rst +++ b/Help/prop_tgt/INTERFACE_LINK_LIBRARIES_DIRECT.rst @@ -56,11 +56,27 @@ on ``X``'s dependents: target_link_libraries(X PUBLIC Y) then ``Y`` is placed in ``X``'s :prop_tgt:`INTERFACE_LINK_LIBRARIES`, - so ``Y``'s usage requirements, including ``INTERFACE_PROPERTY_LINK_DIRECT`` - and ``INTERFACE_PROPERTY_LINK_DIRECT_EXCLUDE``, are propagated - to ``X``'s dependents. + so ``Y``'s usage requirements, including ``INTERFACE_PROPERTY_LINK_DIRECT``, + ``INTERFACE_PROPERTY_LINK_DIRECT_EXCLUDE``, and the usage requirements + declared by the direct link dependencies they add, are propagated to + ``X``'s dependents. -* If ``X`` links ``Y`` privately: +* If ``X`` is a static library or object library, and links ``Y`` privately: + + .. code-block:: cmake + + target_link_libraries(X PRIVATE Y) + + then ``$<LINK_ONLY:Y>`` is placed in ``X``'s + :prop_tgt:`INTERFACE_LINK_LIBRARIES`. ``Y``'s linking requirements, + including ``INTERFACE_PROPERTY_LINK_DIRECT``, + ``INTERFACE_PROPERTY_LINK_DIRECT_EXCLUDE``, and the transitive link + dependencies declared by the direct link dependencies they add, are + propagated to ``X``'s dependents. However, ``Y``'s non-linking + usage requirements are blocked by the :genex:`LINK_ONLY` generator + expression, and are not propagated to ``X``'s dependents. + +* If ``X`` is a shared library or executable, and links ``Y`` privately: .. code-block:: cmake @@ -68,13 +84,10 @@ on ``X``'s dependents: then ``Y`` is not placed in ``X``'s :prop_tgt:`INTERFACE_LINK_LIBRARIES`, so ``Y``'s usage requirements, even ``INTERFACE_PROPERTY_LINK_DIRECT`` - and ``INTERFACE_PROPERTY_LINK_DIRECT_EXCLUDE``, are not propagated - to ``X``'s dependents. - (If ``X`` is a static library or object library, then ``$<LINK_ONLY:Y>`` - is placed in ``X``'s :prop_tgt:`INTERFACE_LINK_LIBRARIES`, but the - :genex:`LINK_ONLY` generator expression block ``Y``'s usage requirements.) + and ``INTERFACE_PROPERTY_LINK_DIRECT_EXCLUDE``, are not propagated to + ``X``'s dependents. -* In either case, the content of ``X``'s :prop_tgt:`INTERFACE_LINK_LIBRARIES` +* In all cases, the content of ``X``'s :prop_tgt:`INTERFACE_LINK_LIBRARIES` is not affected by ``Y``'s ``INTERFACE_PROPERTY_LINK_DIRECT`` or ``INTERFACE_PROPERTY_LINK_DIRECT_EXCLUDE``. @@ -184,7 +197,7 @@ be an intermediate library: .. code-block:: cmake add_library(app_impl STATIC app_impl.cpp) - target_link_libraries(app_impl PUBLIC Foo) + target_link_libraries(app_impl PRIVATE Foo) add_executable(app main.cpp) target_link_libraries(app PRIVATE app_impl) |