diff options
author | Brad King <brad.king@kitware.com> | 2022-02-09 14:28:05 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-02-09 14:28:20 (GMT) |
commit | e40cea3fe99dc79b1ce8bc8330f662ec3a36dc8e (patch) | |
tree | 444d13efd4e6a4844c57a209c4392102250a0969 /Help/manual | |
parent | 3d5466d5e95869380b38e40f8431a19e8a6d458e (diff) | |
parent | 2a6b0415d71db893b6d8edd1c5058d42eb40fca6 (diff) | |
download | CMake-e40cea3fe99dc79b1ce8bc8330f662ec3a36dc8e.zip CMake-e40cea3fe99dc79b1ce8bc8330f662ec3a36dc8e.tar.gz CMake-e40cea3fe99dc79b1ce8bc8330f662ec3a36dc8e.tar.bz2 |
Merge topic 'genex-LINK_LIBRARY-to-decorate-library'
2a6b0415d7 $<LINK_LIBRARY>: Add LINK_LIBRARY_OVERRIDE target property
42965799b4 Genex: Add $<LINK_LIBRARY:...>
78dd7d5292 cmRulePlaceholderExpander: add base class for placeholder expansion reuse
4b55828a9f cmExpandListWithBacktrace: add handling of empty elements.
28d7432468 cmComputeLinkInformation: use cmComputeLinkDepends::LinkEntry
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6769
Diffstat (limited to 'Help/manual')
-rw-r--r-- | Help/manual/cmake-generator-expressions.7.rst | 77 | ||||
-rw-r--r-- | Help/manual/cmake-properties.7.rst | 2 | ||||
-rw-r--r-- | Help/manual/cmake-variables.7.rst | 4 |
3 files changed, 83 insertions, 0 deletions
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index df13dd0..7c34671 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -1113,6 +1113,83 @@ Output-Related Expressions property, perhaps via the :command:`target_link_libraries` command, to specify private link dependencies without other usage requirements. +.. genex:: $<LINK_LIBRARY:feature,library-list> + + .. versionadded:: 3.24 + + Manage how libraries are specified during the link step. + This expression may be used to specify how to link libraries in a target. + For example: + + .. code-block:: cmake + + add_library(lib1 STATIC ...) + add_library(lib2 ...) + target_link_libraries(lib2 PRIVATE $<LINK_LIBRARY:whole_archive,lib1>) + + This specify to use the ``lib1`` target with feature ``whole_archive`` for + linking target ``lib2``. The feature must have be defined by + :variable:`CMAKE_<LANG>_LINK_USING_<FEATURE>` variable or, if + :variable:`CMAKE_<LANG>_LINK_USING_<FEATURE>_SUPPORTED` is false, + by :variable:`CMAKE_LINK_USING_<FEATURE>` variable. + + .. note:: + + The evaluation of this generator expression will use, for the following + variables, the values defined at the level of the creation of the target: + + * :variable:`CMAKE_<LANG>_LINK_USING_<FEATURE>_SUPPORTED` + * :variable:`CMAKE_<LANG>_LINK_USING_<FEATURE>` + * :variable:`CMAKE_LINK_USING_<FEATURE>_SUPPORTED` + * :variable:`CMAKE_LINK_USING_<FEATURE>` + + This expression can only be used to specify link libraries (i.e. part of + :command:`link_libraries` or :command:`target_link_libraries` commands and + :prop_tgt:`LINK_LIBRARIES` or :prop_tgt:`INTERFACE_LINK_LIBRARIES` target + properties). + + .. note:: + + If this expression appears in the :prop_tgt:`INTERFACE_LINK_LIBRARIES` + property of a target, it will be included in the imported target generated + by :command:`install(EXPORT)` command. It is the responsibility of the + environment consuming this import to define the link feature used by this + expression. + + The ``library-list`` argument can hold CMake targets or external libraries. + Any ``CMake`` target of type :ref:`OBJECT <Object Libraries>` or + :ref:`INTERFACE <Interface Libraries>` will be ignored by this expression and + will be handled in the standard way. + + Each target or external library involved in the link step must have only one + kind of feature (the absence of feature is also incompatible with any + feature). For example: + + .. code-block:: cmake + + add_library(lib1 ...) + + add_library(lib2 ...) + target_link_libraries(lib2 PUBLIC $<LINK_LIBRARY:feature1,lib1>) + + add_library(lib3 ...) + target_link_libraries(lib3 PRIVATE lib1 lib2) + # an error will be raised here because lib1 has two different features + + To resolve such incompatibilities, the :prop_tgt:`LINK_LIBRARY_OVERRIDE` + and :prop_tgt:`LINK_LIBRARY_OVERRIDE_<LIBRARY>` target properties can be + used. + + .. note:: + + This expression does not guarantee that the list of specified libraries + will be kept grouped. So, constructs like ``start-group`` and + ``end-group``, as supported by ``GNU ld``, cannot be used. + + ``CMake`` pre-defines some features of general interest: + + .. include:: ../variable/LINK_LIBRARY_PREDEFINED_FEATURES.txt + .. genex:: $<INSTALL_INTERFACE:...> Content of ``...`` when the property is exported using :command:`install(EXPORT)`, diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 566eeae..65f9248 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -308,6 +308,8 @@ Properties on Targets /prop_tgt/LINK_INTERFACE_MULTIPLICITY_CONFIG /prop_tgt/LINK_LIBRARIES /prop_tgt/LINK_LIBRARIES_ONLY_TARGETS + /prop_tgt/LINK_LIBRARY_OVERRIDE + /prop_tgt/LINK_LIBRARY_OVERRIDE_LIBRARY /prop_tgt/LINK_OPTIONS /prop_tgt/LINK_SEARCH_END_STATIC /prop_tgt/LINK_SEARCH_START_STATIC diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 59566b5..86e4d4c 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -440,6 +440,8 @@ Variables that Control the Build /variable/CMAKE_LANG_LINKER_LAUNCHER /variable/CMAKE_LANG_LINK_LIBRARY_FILE_FLAG /variable/CMAKE_LANG_LINK_LIBRARY_FLAG + /variable/CMAKE_LANG_LINK_USING_FEATURE + /variable/CMAKE_LANG_LINK_USING_FEATURE_SUPPORTED /variable/CMAKE_LANG_LINK_WHAT_YOU_USE_FLAG /variable/CMAKE_LANG_VISIBILITY_PRESET /variable/CMAKE_LIBRARY_OUTPUT_DIRECTORY @@ -450,6 +452,8 @@ Variables that Control the Build /variable/CMAKE_LINK_INTERFACE_LIBRARIES /variable/CMAKE_LINK_LIBRARY_FILE_FLAG /variable/CMAKE_LINK_LIBRARY_FLAG + /variable/CMAKE_LINK_USING_FEATURE + /variable/CMAKE_LINK_USING_FEATURE_SUPPORTED /variable/CMAKE_LINK_WHAT_YOU_USE /variable/CMAKE_LINK_WHAT_YOU_USE_CHECK /variable/CMAKE_MACOSX_BUNDLE |