diff options
author | Brad King <brad.king@kitware.com> | 2024-04-22 19:17:20 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-04-29 21:40:03 (GMT) |
commit | ddb9442f487808b74ed3429832a74385a1214582 (patch) | |
tree | 56743b6a8b3be07dbf72dfc7a5114a23230a80d1 /Help | |
parent | 862b8e28adbbab55c666a2d6eb3eecf0bf452bab (diff) | |
download | CMake-ddb9442f487808b74ed3429832a74385a1214582.zip CMake-ddb9442f487808b74ed3429832a74385a1214582.tar.gz CMake-ddb9442f487808b74ed3429832a74385a1214582.tar.bz2 |
GenEx: Fix TARGET_PROPERTY evaluation of transitive link properties
In commit bbba701899 (Link properties: must be transitive over private
dependency on static library, 2019-12-06, v3.17.0-rc1~323^2) and
commit af9d4f24ae (Link properties: must be transitive over private
dependency on static library, 2019-12-11, v3.17.0-rc1~305^2) we
neglected to implement CMP0099 NEW behavior for `TARGET_PROPERTY`
evaluation. Add policy CMP0166 to fix this.
Diffstat (limited to 'Help')
-rw-r--r-- | Help/manual/cmake-generator-expressions.7.rst | 17 | ||||
-rw-r--r-- | Help/manual/cmake-policies.7.rst | 1 | ||||
-rw-r--r-- | Help/policy/CMP0099.rst | 6 | ||||
-rw-r--r-- | Help/policy/CMP0166.rst | 40 | ||||
-rw-r--r-- | Help/release/dev/genex-link-properties.rst | 8 |
5 files changed, 68 insertions, 4 deletions
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 38fa6f9..31f0573 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -1282,7 +1282,7 @@ Compile Context .. versionadded:: 3.27 Content of ``...``, when collecting - :ref:`usage requirements <Target Usage Requirements>`, + :ref:`transitive build properties <Transitive Build Properties>`, otherwise it is the empty string. This is intended for use in an :prop_tgt:`INTERFACE_LINK_LIBRARIES` and :prop_tgt:`LINK_LIBRARIES` target properties, typically populated via the :command:`target_link_libraries` command. @@ -1670,8 +1670,8 @@ Link Context .. versionadded:: 3.1 - Content of ``...``, except while collecting - :ref:`usage requirements <Target Usage Requirements>`, + Content of ``...``, except while collecting usage requirements from + :ref:`transitive build properties <Transitive Build Properties>`, in which case it is the empty string. This is intended for use in an :prop_tgt:`INTERFACE_LINK_LIBRARIES` target property, typically populated via the :command:`target_link_libraries` command, to specify private link @@ -1788,7 +1788,16 @@ The expressions have special evaluation rules for some properties: of the value on the target itself with the values of the same properties on targets named by the target's :prop_tgt:`INTERFACE_LINK_LIBRARIES`. Evaluation is transitive over the closure of the target's - :prop_tgt:`INTERFACE_LINK_LIBRARIES`. + :prop_tgt:`INTERFACE_LINK_LIBRARIES`: + + * For :ref:`Transitive Build Properties`, the transitive closure + *excludes* entries of :prop_tgt:`INTERFACE_LINK_LIBRARIES` guarded + by the :genex:`LINK_ONLY` generator expression. + + * For :ref:`Transitive Link Properties`, the transitive closure is + *includes* entries of :prop_tgt:`INTERFACE_LINK_LIBRARIES` guarded + by the :genex:`LINK_ONLY` generator expression. + See policy :policy:`CMP0166`. Evaluation of :prop_tgt:`INTERFACE_LINK_LIBRARIES` itself is not transitive. diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index dd202a2..826790d 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -57,6 +57,7 @@ Policies Introduced by CMake 3.30 .. toctree:: :maxdepth: 1 + CMP0166: TARGET_PROPERTY evaluates link properties transitively over private dependencies of static libraries. </policy/CMP0166> CMP0165: enable_language() must not be called before project(). </policy/CMP0165> CMP0164: add_library() rejects SHARED libraries when not supported by the platform. </policy/CMP0164> CMP0163: The GENERATED source file property is now visible in all directories. </policy/CMP0163> diff --git a/Help/policy/CMP0099.rst b/Help/policy/CMP0099.rst index e836cf3..0a2b786 100644 --- a/Help/policy/CMP0099.rst +++ b/Help/policy/CMP0099.rst @@ -21,6 +21,12 @@ The ``OLD`` behavior for this policy is to not propagate interface link properties. The ``NEW`` behavior of this policy is to propagate interface link properties. +.. versionadded:: 3.30 + + Policy :policy:`CMP0166` makes :genex:`TARGET_PROPERTY` evaluation of + these three transitive link properties follow private dependencies of + static libraries too. + .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.17 .. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn .. include:: STANDARD_ADVICE.txt diff --git a/Help/policy/CMP0166.rst b/Help/policy/CMP0166.rst new file mode 100644 index 0000000..5c67880 --- /dev/null +++ b/Help/policy/CMP0166.rst @@ -0,0 +1,40 @@ +CMP0166 +------- + +.. versionadded:: 3.30 + +:genex:`TARGET_PROPERTY` evaluates link properties transitively over private +dependencies of static libraries. + +In CMake 3.29 and below, the :genex:`TARGET_PROPERTY` generator expression +evaluates properties :prop_tgt:`INTERFACE_LINK_OPTIONS`, +:prop_tgt:`INTERFACE_LINK_DIRECTORIES`, and :prop_tgt:`INTERFACE_LINK_DEPENDS` +as if they were :ref:`Transitive Build Properties` rather than +:ref:`Transitive Link Properties`, even when policy :policy:`CMP0099` is +set to ``NEW``. Private dependencies of static libraries, which appear in +their :prop_tgt:`INTERFACE_LINK_LIBRARIES` guarded by :genex:`LINK_ONLY` +generator expressions, are not followed. This is inconsistent with +evaluation of the same target properties during buildsystem generation. + +CMake 3.30 and above prefer that :genex:`TARGET_PROPERTY` evaluates +properties :prop_tgt:`INTERFACE_LINK_OPTIONS`, +:prop_tgt:`INTERFACE_LINK_DIRECTORIES`, and :prop_tgt:`INTERFACE_LINK_DEPENDS` +as :ref:`Transitive Link Properties` such that private dependencies of static +libraries, which appear in their :prop_tgt:`INTERFACE_LINK_LIBRARIES` guarded +by :genex:`LINK_ONLY` generator expressions, are followed. +This policy provides compatibility for projects that have not been updated +to expect the new behavior. + +The ``OLD`` behavior for this policy is for :genex:`TARGET_PROPERTY` to +evaluate properties :prop_tgt:`INTERFACE_LINK_OPTIONS`, +:prop_tgt:`INTERFACE_LINK_DIRECTORIES`, and :prop_tgt:`INTERFACE_LINK_DEPENDS` +as if they were :ref:`Transitive Build Properties` by not following private +dependencies of static libraries. The ``NEW`` behavior for this policy is +to evaluate them as :ref:`Transitive Link Properties` by following private +dependencies of static libraries. + +.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.30 +.. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn +.. include:: STANDARD_ADVICE.txt + +.. include:: DEPRECATED.txt diff --git a/Help/release/dev/genex-link-properties.rst b/Help/release/dev/genex-link-properties.rst new file mode 100644 index 0000000..e1e84e0 --- /dev/null +++ b/Help/release/dev/genex-link-properties.rst @@ -0,0 +1,8 @@ +genex-link-properties +--------------------- + +* The :genex:`TARGET_PROPERTY` generator expression now evaluates target + properties :prop_tgt:`INTERFACE_LINK_OPTIONS`, + :prop_tgt:`INTERFACE_LINK_DIRECTORIES`, and + :prop_tgt:`INTERFACE_LINK_DEPENDS` correctly by following private + dependencies of static libraries. See policy :policy:`CMP0166`. |