diff options
author | Brad King <brad.king@kitware.com> | 2024-05-09 18:50:41 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-05-21 13:22:52 (GMT) |
commit | c16acd35b36245575744e3c31a581c62880481a5 (patch) | |
tree | f200c561fb54278d52447d5e52ce13c5bc53dcac /Help/manual | |
parent | b9ee79b8a13abb957a176ff0b5eab1e5d33efc50 (diff) | |
download | CMake-c16acd35b36245575744e3c31a581c62880481a5.zip CMake-c16acd35b36245575744e3c31a581c62880481a5.tar.gz CMake-c16acd35b36245575744e3c31a581c62880481a5.tar.bz2 |
GenEx: Add support for custom transitive link properties
Teach the `$<TARGET_PROPERTY:...>` generator expression to check for a
new `TRANSITIVE_LINK_PROPERTIES` property in the target's link
closure to enable transitive evaluation of named properties through
the link closure, including entries guarded by `$<LINK_ONLY:...>`.
Fixes: #20416
Diffstat (limited to 'Help/manual')
-rw-r--r-- | Help/manual/cmake-buildsystem.7.rst | 14 | ||||
-rw-r--r-- | Help/manual/cmake-generator-expressions.7.rst | 17 | ||||
-rw-r--r-- | Help/manual/cmake-properties.7.rst | 1 |
3 files changed, 29 insertions, 3 deletions
diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst index 4dc2306..eb25a4a 100644 --- a/Help/manual/cmake-buildsystem.7.rst +++ b/Help/manual/cmake-buildsystem.7.rst @@ -614,7 +614,8 @@ The :genex:`TARGET_PROPERTY` generator expression evaluates the above `usage requirement <Target Usage Requirements_>`_ properties as builtin transitive properties. It also supports custom transitive properties defined by the :prop_tgt:`TRANSITIVE_COMPILE_PROPERTIES` -property on the target and its link dependencies. +and :prop_tgt:`TRANSITIVE_LINK_PROPERTIES` properties on the target +and its link dependencies. For example: @@ -623,21 +624,26 @@ For example: add_library(example INTERFACE) set_target_properties(example PROPERTIES TRANSITIVE_COMPILE_PROPERTIES "CUSTOM_C" + TRANSITIVE_LINK_PROPERTIES "CUSTOM_L" INTERFACE_CUSTOM_C "EXAMPLE_CUSTOM_C" + INTERFACE_CUSTOM_L "EXAMPLE_CUSTOM_L" ) add_library(mylib STATIC mylib.c) target_link_libraries(mylib PRIVATE example) set_target_properties(mylib PROPERTIES CUSTOM_C "MYLIB_PRIVATE_CUSTOM_C" + CUSTOM_L "MYLIB_PRIVATE_CUSTOM_L" INTERFACE_CUSTOM_C "MYLIB_IFACE_CUSTOM_C" + INTERFACE_CUSTOM_L "MYLIB_IFACE_CUSTOM_L" ) add_executable(myexe myexe.c) target_link_libraries(myexe PRIVATE mylib) set_target_properties(myexe PROPERTIES CUSTOM_C "MYEXE_CUSTOM_C" + CUSTOM_L "MYEXE_CUSTOM_L" ) add_custom_target(print ALL VERBATIM @@ -645,8 +651,14 @@ For example: # Prints "MYLIB_PRIVATE_CUSTOM_C;EXAMPLE_CUSTOM_C" "$<TARGET_PROPERTY:mylib,CUSTOM_C>" + # Prints "MYLIB_PRIVATE_CUSTOM_L;EXAMPLE_CUSTOM_L" + "$<TARGET_PROPERTY:mylib,CUSTOM_L>" + # Prints "MYEXE_CUSTOM_C" "$<TARGET_PROPERTY:myexe,CUSTOM_C>" + + # Prints "MYEXE_CUSTOM_L;MYLIB_IFACE_CUSTOM_L;EXAMPLE_CUSTOM_L" + "$<TARGET_PROPERTY:myexe,CUSTOM_L>" ) .. _`Compatible Interface Properties`: diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index d0d751b..bc32452 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -1818,7 +1818,7 @@ The expressions have special evaluation rules for some properties: * Evaluation of :genex:`$<TARGET_PROPERTY:tgt,PROP>` for some property ``PROP``, named without an ``INTERFACE_`` prefix, checks the :prop_tgt:`TRANSITIVE_COMPILE_PROPERTIES` - property on target ``tgt``, + and :prop_tgt:`TRANSITIVE_LINK_PROPERTIES` properties on target ``tgt``, on targets named by its :prop_tgt:`LINK_LIBRARIES`, and on the transitive closure of targets named by the linked targets' :prop_tgt:`INTERFACE_LINK_LIBRARIES`. @@ -1834,10 +1834,15 @@ The expressions have special evaluation rules for some properties: the closure of the linked targets' :prop_tgt:`INTERFACE_LINK_LIBRARIES`, excluding entries guarded by the :genex:`LINK_ONLY` generator expression. + * If ``PROP`` is named by :prop_tgt:`TRANSITIVE_LINK_PROPERTIES`, + evaluation of the corresponding ``INTERFACE_PROP`` is transitive over + the closure of the linked targets' :prop_tgt:`INTERFACE_LINK_LIBRARIES`, + including entries guarded by the :genex:`LINK_ONLY` generator expression. + * Evaluation of :genex:`$<TARGET_PROPERTY:tgt,INTERFACE_PROP>` for some property ``INTERFACE_PROP``, named with an ``INTERFACE_`` prefix, checks the :prop_tgt:`TRANSITIVE_COMPILE_PROPERTIES` - property on target ``tgt``, + and :prop_tgt:`TRANSITIVE_LINK_PROPERTIES` properties on target ``tgt``, and on the transitive closure of targets named by its :prop_tgt:`INTERFACE_LINK_LIBRARIES`. @@ -1853,6 +1858,14 @@ The expressions have special evaluation rules for some properties: the closure of the target's :prop_tgt:`INTERFACE_LINK_LIBRARIES`, excluding entries guarded by the :genex:`LINK_ONLY` generator expression. + * If ``PROP`` is named by :prop_tgt:`TRANSITIVE_LINK_PROPERTIES`, + evaluation of the corresponding ``INTERFACE_PROP`` is transitive over + the closure of the target's :prop_tgt:`INTERFACE_LINK_LIBRARIES`, + including entries guarded by the :genex:`LINK_ONLY` generator expression. + + If a ``PROP`` is named by both :prop_tgt:`TRANSITIVE_COMPILE_PROPERTIES` + and :prop_tgt:`TRANSITIVE_LINK_PROPERTIES`, the latter takes precedence. + :ref:`Compatible Interface Properties` These evaluate as a single value combined from the target itself, from targets named by the target's :prop_tgt:`LINK_LIBRARIES`, and diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 48e1d54..549ec53 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -402,6 +402,7 @@ Properties on Targets /prop_tgt/SYSTEM /prop_tgt/TEST_LAUNCHER /prop_tgt/TRANSITIVE_COMPILE_PROPERTIES + /prop_tgt/TRANSITIVE_LINK_PROPERTIES /prop_tgt/TYPE /prop_tgt/UNITY_BUILD /prop_tgt/UNITY_BUILD_BATCH_SIZE |