Help: Use direct refs to genexes instead of `$<GENEX-NAME>
`
This commit is contained in:
parent
8c6274326d
commit
c86ec79d07
@ -7,8 +7,6 @@ Host And Device Specific Link Options
|
||||
:prop_tgt:`CUDA_RESOLVE_DEVICE_SYMBOLS` properties and policy :policy:`CMP0105`,
|
||||
the raw options will be delivered to the host and device link steps (wrapped in
|
||||
``-Xcompiler`` or equivalent for device link). Options wrapped with
|
||||
``$<DEVICE_LINK:...>``
|
||||
:manual:`generator expression <cmake-generator-expressions(7)>` will be used
|
||||
only for the device link step. Options wrapped with ``$<HOST_LINK:...>``
|
||||
:manual:`generator expression <cmake-generator-expressions(7)>` will be used
|
||||
only for the host link step.
|
||||
:genex:`$<DEVICE_LINK:...>` generator expression will be used
|
||||
only for the device link step. Options wrapped with :genex:`$<HOST_LINK:...>`
|
||||
generator expression will be used only for the host link step.
|
||||
|
@ -85,8 +85,8 @@ Creates an :ref:`Object Library <Object Libraries>`. An object library
|
||||
compiles source files but does not archive or link their object files into a
|
||||
library. Instead other targets created by :command:`add_library` or
|
||||
:command:`add_executable` may reference the objects using an expression of the
|
||||
form ``$<TARGET_OBJECTS:objlib>`` as a source, where ``objlib`` is the
|
||||
object library name. For example:
|
||||
form :genex:`$\<TARGET_OBJECTS:objlib\> <TARGET_OBJECTS>` as a source, where
|
||||
``objlib`` is the object library name. For example:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
@ -101,7 +101,7 @@ They may contain custom commands generating such sources, but not
|
||||
``PRE_BUILD``, ``PRE_LINK``, or ``POST_BUILD`` commands. Some native build
|
||||
systems (such as Xcode) may not like targets that have only object files, so
|
||||
consider adding at least one real source file to any target that references
|
||||
``$<TARGET_OBJECTS:objlib>``.
|
||||
:genex:`$\<TARGET_OBJECTS:objlib\> <TARGET_OBJECTS>`.
|
||||
|
||||
.. versionadded:: 3.12
|
||||
Object libraries can be linked to with :command:`target_link_libraries`.
|
||||
|
@ -526,10 +526,10 @@ from the input content to produce the output content. The options are:
|
||||
|
||||
``OUTPUT <output-file>``
|
||||
Specify the output file name to generate. Use generator expressions
|
||||
such as ``$<CONFIG>`` to specify a configuration-specific output file
|
||||
name. Multiple configurations may generate the same output file only
|
||||
if the generated content is identical. Otherwise, the ``<output-file>``
|
||||
must evaluate to an unique name for each configuration.
|
||||
such as :genex:`$<CONFIG>` to specify a configuration-specific
|
||||
output file name. Multiple configurations may generate the same output
|
||||
file only if the generated content is identical. Otherwise, the
|
||||
``<output-file>`` must evaluate to an unique name for each configuration.
|
||||
|
||||
.. versionchanged:: 3.10
|
||||
A relative path (after evaluating generator expressions) is treated
|
||||
@ -540,8 +540,9 @@ from the input content to produce the output content. The options are:
|
||||
.. versionadded:: 3.19
|
||||
|
||||
Specify which target to use when evaluating generator expressions that
|
||||
require a target for evaluation (e.g. ``$<COMPILE_FEATURES:...>``,
|
||||
``$<TARGET_PROPERTY:prop>``).
|
||||
require a target for evaluation (e.g.
|
||||
:genex:`$<COMPILE_FEATURES:...>`,
|
||||
:genex:`$<TARGET_PROPERTY:prop>`).
|
||||
|
||||
``NO_SOURCE_PERMISSIONS``
|
||||
.. versionadded:: 3.20
|
||||
|
@ -379,7 +379,7 @@ top level:
|
||||
:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` target property of the
|
||||
``<targets>`` when exported by the `install(EXPORT)`_ command. If a
|
||||
relative path is specified, it is treated as relative to the
|
||||
``$<INSTALL_PREFIX>``.
|
||||
:genex:`$<INSTALL_PREFIX>`.
|
||||
|
||||
``RUNTIME_DEPENDENCY_SET``
|
||||
.. versionadded:: 3.21
|
||||
|
@ -80,7 +80,7 @@ only one language (e.g. ``CXX`` and not ``C``). In this case, header
|
||||
file names that are not explicitly in double quotes or angle brackets
|
||||
must be specified by absolute path. Also, when specifying angle brackets
|
||||
inside a generator expression, be sure to encode the closing ``>`` as
|
||||
``$<ANGLE-R>``. For example:
|
||||
:genex:`$<ANGLE-R>`. For example:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
|
@ -106,14 +106,14 @@ If either ``OUTPUT`` or ``BYPRODUCTS`` names a path that is common to
|
||||
more than one configuration (e.g. it does not use any generator expressions),
|
||||
all arguments are evaluated in the command config by default.
|
||||
If all ``OUTPUT`` and ``BYPRODUCTS`` paths are unique to each configuration
|
||||
(e.g. by using the ``$<CONFIG>`` generator expression), the first argument of
|
||||
(e.g. by using the :genex:`$<CONFIG>` generator expression), the first argument of
|
||||
``COMMAND`` is still evaluated in the command config by default, while all
|
||||
subsequent arguments, as well as the arguments to ``DEPENDS`` and
|
||||
``WORKING_DIRECTORY``, are evaluated in the output config. These defaults can
|
||||
be overridden with the ``$<OUTPUT_CONFIG:...>`` and ``$<COMMAND_CONFIG:...>``
|
||||
be overridden with the :genex:`$<OUTPUT_CONFIG:...>` and :genex:`$<COMMAND_CONFIG:...>`
|
||||
generator-expressions. Note that if a target is specified by its name in
|
||||
``DEPENDS``, or as the first argument of ``COMMAND``, it is always evaluated
|
||||
in the command config, even if it is wrapped in ``$<OUTPUT_CONFIG:...>``
|
||||
in the command config, even if it is wrapped in :genex:`$<OUTPUT_CONFIG:...>`
|
||||
(because its plain name is not a generator expression).
|
||||
|
||||
As an example, consider the following:
|
||||
|
@ -563,8 +563,7 @@ include directories should be specified as relative paths to the
|
||||
$<INSTALL_INTERFACE:include/TgtName>
|
||||
)
|
||||
|
||||
The ``$<INSTALL_PREFIX>``
|
||||
:manual:`generator expression <cmake-generator-expressions(7)>` may be used as
|
||||
The :genex:`$<INSTALL_PREFIX>` generator expression may be used as
|
||||
a placeholder for the install prefix without resulting in a non-relocatable
|
||||
package. This is necessary if complex generator expressions are used:
|
||||
|
||||
|
@ -119,7 +119,7 @@ Object Libraries
|
||||
The ``OBJECT`` library type defines a non-archival collection of object files
|
||||
resulting from compiling the given source files. The object files collection
|
||||
may be used as source inputs to other targets by using the syntax
|
||||
``$<TARGET_OBJECTS:name>``. This is a
|
||||
:genex:`$<TARGET_OBJECTS:name>`. This is a
|
||||
:manual:`generator expression <cmake-generator-expressions(7)>` that can be
|
||||
used to supply the ``OBJECT`` library content to other targets:
|
||||
|
||||
@ -854,7 +854,7 @@ the generator used. For example:
|
||||
|
||||
In the presence of :prop_tgt:`IMPORTED` targets, the content of
|
||||
:prop_tgt:`MAP_IMPORTED_CONFIG_DEBUG <MAP_IMPORTED_CONFIG_<CONFIG>>` is also
|
||||
accounted for by the above ``$<CONFIG:Debug>`` expression.
|
||||
accounted for by the above :genex:`$<CONFIG:Debug>` expression.
|
||||
|
||||
|
||||
Case Sensitivity
|
||||
@ -862,7 +862,7 @@ Case Sensitivity
|
||||
|
||||
:variable:`CMAKE_BUILD_TYPE` and :variable:`CMAKE_CONFIGURATION_TYPES` are
|
||||
just like other variables in that any string comparisons made with their
|
||||
values will be case-sensitive. The ``$<CONFIG>`` generator expression also
|
||||
values will be case-sensitive. The :genex:`$<CONFIG>` generator expression also
|
||||
preserves the casing of the configuration as set by the user or CMake defaults.
|
||||
For example:
|
||||
|
||||
@ -887,7 +887,7 @@ For example:
|
||||
|
||||
In contrast, CMake treats the configuration type case-insensitively when
|
||||
using it internally in places that modify behavior based on the configuration.
|
||||
For example, the ``$<CONFIG:Debug>`` generator expression will evaluate to 1
|
||||
For example, the :genex:`$<CONFIG:Debug>` generator expression will evaluate to 1
|
||||
for a configuration of not only ``Debug``, but also ``DEBUG``, ``debug`` or
|
||||
even ``DeBuG``. Therefore, you can specify configuration types in
|
||||
:variable:`CMAKE_BUILD_TYPE` and :variable:`CMAKE_CONFIGURATION_TYPES` with
|
||||
|
@ -9,8 +9,8 @@ libraries need to use the :prop_tgt:`STATIC_LIBRARY_OPTIONS` target property.
|
||||
|
||||
These options are used for both normal linking and device linking
|
||||
(see policy :policy:`CMP0105`). To control link options for normal and device
|
||||
link steps, ``$<HOST_LINK>`` and ``$<DEVICE_LINK>``
|
||||
:manual:`generator expressions <cmake-generator-expressions(7)>` can be used.
|
||||
link steps, :genex:`$<HOST_LINK>` and ::genex:`$<DEVICE_LINK>` generator
|
||||
expressions can be used.
|
||||
|
||||
This property holds a :ref:`semicolon-separated list <CMake Language Lists>` of
|
||||
options specified so far for its target. Use the :command:`target_link_options`
|
||||
|
@ -243,46 +243,42 @@ Modules
|
||||
Generator Expressions
|
||||
---------------------
|
||||
|
||||
* The :manual:`generator expressions <cmake-generator-expressions(7)>`
|
||||
``C_COMPILER_ID``, ``CXX_COMPILER_ID``, ``CUDA_COMPILER_ID``,
|
||||
``Fortran_COMPILER_ID``, ``COMPILE_LANGUAGE``, ``COMPILE_LANG_AND_ID``, and
|
||||
``PLATFORM_ID`` learned to support matching one value from a comma-separated
|
||||
list.
|
||||
* The generator expressions :genex:`$<C_COMPILER_ID>`,
|
||||
:genex:`$<CXX_COMPILER_ID>`, :genex:`$<CUDA_COMPILER_ID>`,
|
||||
:genex:`$<Fortran_COMPILER_ID>`, :genex:`$<COMPILE_LANGUAGE>`,
|
||||
:genex:`$<COMPILE_LANG_AND_ID>`, and :genex:`$<PLATFORM_ID>` learned to
|
||||
support matching one value from a comma-separated list.
|
||||
|
||||
* The ``$<CUDA_COMPILER_ID:...>`` and ``$<CUDA_COMPILER_VERSION:...>``
|
||||
:manual:`generator expressions <cmake-generator-expressions(7)>` were added.
|
||||
* The :genex:`$<CUDA_COMPILER_ID:...>` and :genex:`$<CUDA_COMPILER_VERSION:...>`
|
||||
generator expressions were added.
|
||||
|
||||
* The ``$<COMPILE_LANG_AND_ID:...>`` generator expression was introduced to
|
||||
* The :genex:`$<COMPILE_LANG_AND_ID:...>` generator expression was introduced to
|
||||
allow specification of compile options for target files based on the
|
||||
:variable:`CMAKE_<LANG>_COMPILER_ID` and :prop_sf:`LANGUAGE` of
|
||||
each source file.
|
||||
|
||||
* A ``$<FILTER:list,INCLUDE|EXCLUDE,regex>``
|
||||
:manual:`generator expression <cmake-generator-expressions(7)>`
|
||||
has been added.
|
||||
* A :genex:`$<FILTER:list,INCLUDE|EXCLUDE,regex>` generator expression has
|
||||
been added.
|
||||
|
||||
* A ``$<REMOVE_DUPLICATES:list>``
|
||||
:manual:`generator expression <cmake-generator-expressions(7)>`
|
||||
has been added.
|
||||
* A :genex:`$<REMOVE_DUPLICATES:list>` generator expression has been added.
|
||||
|
||||
* The ``$<SHELL_PATH:...>`` :manual:`generator expression
|
||||
<cmake-generator-expressions(7)>` gained support for a list of paths.
|
||||
* The :genex:`$<SHELL_PATH:...>` generator expression gained support for a
|
||||
list of paths.
|
||||
|
||||
* New ``$<TARGET_FILE*>`` :manual:`generator expressions
|
||||
<cmake-generator-expressions(7)>` were added to retrieve the prefix, base
|
||||
name, and suffix of the file names of various artifacts:
|
||||
|
||||
* ``$<TARGET_FILE_PREFIX:...>``
|
||||
* ``$<TARGET_FILE_BASE_NAME:...>``
|
||||
* ``$<TARGET_FILE_SUFFIX:...>``
|
||||
* ``$<TARGET_LINKER_FILE_PREFIX:...>``
|
||||
* ``$<TARGET_LINKER_FILE_BASE_NAME:...>``
|
||||
* ``$<TARGET_LINKER_FILE_SUFFIX:...>``
|
||||
* ``$<TARGET_PDB_FILE_BASE_NAME:...>``
|
||||
* :genex:`$<TARGET_FILE_PREFIX:...>`
|
||||
* :genex:`$<TARGET_FILE_BASE_NAME:...>`
|
||||
* :genex:`$<TARGET_FILE_SUFFIX:...>`
|
||||
* :genex:`$<TARGET_LINKER_FILE_PREFIX:...>`
|
||||
* :genex:`$<TARGET_LINKER_FILE_BASE_NAME:...>`
|
||||
* :genex:`$<TARGET_LINKER_FILE_SUFFIX:...>`
|
||||
* :genex:`$<TARGET_PDB_FILE_BASE_NAME:...>`
|
||||
|
||||
* The ``$<TARGET_OBJECTS:...>`` :manual:`generator expression
|
||||
<cmake-generator-expressions(7)>` is now supported on ``SHARED``,
|
||||
``STATIC``, ``MODULE`` libraries and executables.
|
||||
* The :genex:`$<TARGET_OBJECTS:...>` generator expression is now supported
|
||||
on ``SHARED``, ``STATIC``, ``MODULE`` libraries and executables.
|
||||
|
||||
CTest
|
||||
-----
|
||||
|
@ -140,7 +140,7 @@ Properties
|
||||
|
||||
* The :prop_tgt:`INSTALL_NAME_DIR` target property now supports
|
||||
:manual:`generator expressions <cmake-generator-expressions(7)>`.
|
||||
In particular, the ``$<INSTALL_PREFIX>`` generator expression can
|
||||
In particular, the :genex:`$<INSTALL_PREFIX>` generator expression can
|
||||
be used to set the directory relative to the install-time prefix.
|
||||
|
||||
* Target properties :prop_tgt:`MACHO_COMPATIBILITY_VERSION` and
|
||||
|
@ -211,12 +211,11 @@ Modules
|
||||
Generator Expressions
|
||||
---------------------
|
||||
|
||||
* The ``$<DEVICE_LINK:...>`` and ``$<HOST_LINK:...>``
|
||||
:manual:`generator expressions <cmake-generator-expressions(7)>` were added
|
||||
to manage device and host link steps.
|
||||
* The :genex:`$<DEVICE_LINK:...>` and :genex:`$<HOST_LINK:...>`
|
||||
generator expressions were added to manage device and host link steps.
|
||||
|
||||
* The ``$<LINK_LANGUAGE:...>`` and ``$<LINK_LANG_AND_ID:...>``
|
||||
:manual:`generator expressions <cmake-generator-expressions(7)>` were added.
|
||||
* The :genex:`$<LINK_LANGUAGE:...>` and :genex:`$<LINK_LANG_AND_ID:...>`
|
||||
generator expressions were added.
|
||||
|
||||
CTest
|
||||
-----
|
||||
|
@ -86,8 +86,8 @@ Commands
|
||||
in their ``OUTPUT`` and ``BYPRODUCTS`` options.
|
||||
|
||||
Their ``COMMAND``, ``WORKING_DIRECTORY``, and ``DEPENDS`` options gained
|
||||
support for new generator expressions ``$<COMMAND_CONFIG:...>`` and
|
||||
``$<OUTPUT_CONFIG:...>`` that control cross-config handling when using
|
||||
support for new generator expressions :genex:`$<COMMAND_CONFIG:...>` and
|
||||
:genex:`$<OUTPUT_CONFIG:...>` that control cross-config handling when using
|
||||
the :generator:`Ninja Multi-Config` generator.
|
||||
|
||||
* The :command:`add_custom_command` command gained ``DEPFILE`` support on
|
||||
|
@ -274,8 +274,8 @@ Other Changes
|
||||
* tries to detect invalid architectures and issue an error.
|
||||
|
||||
* ``CUDA`` with Clang now implements policy :policy:`CMP0105` and
|
||||
the ``$<DEVICE_LINK:...>`` and ``$<HOST_LINK:...>``
|
||||
:manual:`generator expressions <cmake-generator-expressions(7)>`.
|
||||
the :genex:`$<DEVICE_LINK:...>` and :genex:`$<HOST_LINK:...>`
|
||||
generator expressions.
|
||||
|
||||
* The :command:`define_property` command's ``BRIEF_DOCS`` and ``FULL_DOCS``
|
||||
arguments are now optional.
|
||||
|
@ -256,11 +256,11 @@ Other
|
||||
:command:`file(GENERATE)` commands.
|
||||
|
||||
* Two new informational generator expressions to retrieve Apple Bundle
|
||||
directories have been added. The first one ``$<TARGET_BUNDLE_DIR:tgt>``
|
||||
directories have been added. The first one :genex:`$<TARGET_BUNDLE_DIR:tgt>`
|
||||
outputs the full path to the Bundle directory, the other one
|
||||
``$<TARGET_BUNDLE_CONTENT_DIR:tgt>`` outputs the full path to the
|
||||
:genex:`$<TARGET_BUNDLE_CONTENT_DIR:tgt>` outputs the full path to the
|
||||
``Contents`` directory of macOS Bundles and App Bundles. For all other
|
||||
bundle types and SDKs it is identical with ``$<TARGET_BUNDLE_DIR:tgt>``.
|
||||
bundle types and SDKs it is identical with :genex:`$<TARGET_BUNDLE_DIR:tgt>`.
|
||||
The new expressions are helpful to query Bundle locations independent of
|
||||
the different Bundle types and layouts on macOS and iOS.
|
||||
|
||||
|
@ -49,14 +49,14 @@
|
||||
* ``[/path/to/]FwName.framework/Versions/*/FwName[suffix]``
|
||||
|
||||
Note that CMake recognizes and automatically handles framework targets,
|
||||
even without using the ``$<LINK_LIBRARY:FRAMEWORK,...>`` expression.
|
||||
even without using the :genex:`$<LINK_LIBRARY:FRAMEWORK,...>` expression.
|
||||
The generator expression can still be used with a CMake target if the
|
||||
project wants to be explicit about it, but it is not required to do so.
|
||||
The linker command line may have some differences between using the
|
||||
generator expression or not, but the final result should be the same.
|
||||
On the other hand, if a file path is given, CMake will recognize some paths
|
||||
automatically, but not all cases. The project may want to use
|
||||
``$<LINK_LIBRARY:FRAMEWORK,...>`` for file paths so that the expected
|
||||
:genex:`$<LINK_LIBRARY:FRAMEWORK,...>` for file paths so that the expected
|
||||
behavior is clear.
|
||||
|
||||
.. versionadded:: 3.25
|
||||
|
Loading…
Reference in New Issue
Block a user