Merge topic 'alias-transparency'

17094eb572 ALIAS: Add test for generator expressions with ALIAS targets
5f8cc64695 ALIAS: Add support for add_dependencies for ALIAS targets
79e421b053 ALIAS: Add support for target_* commands
3b327695aa ALIASED_TARGET: Make property read-only
a121419908 ALIAS: Add support for set_property and set_target_properties commands

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12207
This commit is contained in:
Brad King
2026-07-09 14:05:51 +00:00
committed by Kitware Robot
55 changed files with 279 additions and 88 deletions

View File

@@ -35,6 +35,10 @@ transitively in its place since the target itself does not build.
The command may be called with no dependencies.
Previously, at least one dependency was required.
.. versionchanged:: 4.5
If ``<target>`` is an :ref:`Alias Target <Alias Targets>`, dependencies are
added to the target which the alias references.
See Also
^^^^^^^^

View File

@@ -112,11 +112,14 @@ Alias Executables
``ALIAS`` targets can be used as targets to read properties
from, executables for custom commands and custom targets. They can also be
tested for existence with the regular :command:`if(TARGET)` subcommand.
The ``<name>`` may not be used to modify properties of ``<target>``, that
is, it may not be used as the operand of :command:`set_property`,
:command:`set_target_properties`, :command:`target_link_libraries` etc.
An ``ALIAS`` target may not be installed or exported.
.. versionchanged:: 4.5
The ``<name>`` may be used as the operand of :command:`set_property`,
:command:`set_target_properties`, :command:`target_link_libraries`, etc. to
modify properties of ``<target>``. CMake 4.4 and earlier did not allow the
``<name>`` to modify properties of ``<target>``.
See Also
^^^^^^^^

View File

@@ -317,12 +317,15 @@ Alias Libraries
``ALIAS`` targets can be used as linkable targets and as targets to
read properties from. They can also be tested for existence with the
regular :command:`if(TARGET)` subcommand. The ``<name>`` may not be used
to modify properties of ``<target>``, that is, it may not be used as the
operand of :command:`set_property`, :command:`set_target_properties`,
:command:`target_link_libraries` etc. An ``ALIAS`` target may not be
regular :command:`if(TARGET)` subcommand. An ``ALIAS`` target may not be
installed or exported.
.. versionchanged:: 4.5
The ``<name>`` may be used as the operand of :command:`set_property`,
:command:`set_target_properties`, :command:`target_link_libraries`, etc. to
modify properties of ``<target>``. CMake 4.4 and earlier did not allow the
``<name>`` to modify properties of ``<target>``.
See Also
^^^^^^^^

View File

@@ -40,7 +40,9 @@ It must be one of the following:
Scope may name zero or more existing targets.
See also the :command:`set_target_properties` command.
:ref:`Alias Targets` do not support setting target properties.
.. versionchanged:: 4.5
If ``<target>`` is an :ref:`Alias Target <Alias Targets>`, properties are
set on the target which the alias references.
``FILE_SET``
.. versionadded:: 4.3

View File

@@ -15,7 +15,9 @@ set next. You can use any prop value pair you want and extract it
later with the :command:`get_property` or :command:`get_target_property`
command.
:ref:`Alias Targets` do not support setting target properties.
.. versionchanged:: 4.5
If ``<targets>`` contains :ref:`Alias Targets`, properties are set on the
corresponding target referenced by each alias.
See Also
^^^^^^^^

View File

@@ -11,8 +11,11 @@ Add compile definitions to a target.
Specifies compile definitions to use when compiling a given ``<target>``. The
named ``<target>`` must have been created by a command such as
:command:`add_executable` or :command:`add_library` and must not be an
:ref:`ALIAS target <Alias Targets>`.
:command:`add_executable` or :command:`add_library`.
.. versionchanged:: 4.5
If ``<target>`` is an :ref:`Alias Target <Alias Targets>`, the command
operates on the target which the alias references.
The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
specify the :ref:`scope <Target Command Scope>` of the following arguments.

View File

@@ -29,8 +29,11 @@ Repeated calls for the same ``<target>`` append items.
Allow setting ``INTERFACE`` items on :ref:`IMPORTED targets <Imported Targets>`.
The named ``<target>`` must have been created by a command such as
:command:`add_executable` or :command:`add_library` and must not be an
:ref:`ALIAS target <Alias Targets>`.
:command:`add_executable` or :command:`add_library`.
.. versionchanged:: 4.5
If ``<target>`` is an :ref:`Alias Target <Alias Targets>`, the command
operates on the target which the alias references.
.. |command_name| replace:: ``target_compile_features``
.. |more_see_also| replace:: See the :manual:`cmake-compile-features(7)`

View File

@@ -13,7 +13,11 @@ Adds options to the :prop_tgt:`COMPILE_OPTIONS` or
:prop_tgt:`INTERFACE_COMPILE_OPTIONS` target properties. These options
are used when compiling the given ``<target>``, which must have been
created by a command such as :command:`add_executable` or
:command:`add_library` and must not be an :ref:`ALIAS target <Alias Targets>`.
:command:`add_library`.
.. versionchanged:: 4.5
If ``<target>`` is an :ref:`Alias Target <Alias Targets>`, the command
operates on the target which the alias references.
.. note::

View File

@@ -11,8 +11,11 @@ Add include directories to a target.
Specifies include directories to use when compiling a given target.
The named ``<target>`` must have been created by a command such
as :command:`add_executable` or :command:`add_library` and must not be an
:ref:`ALIAS target <Alias Targets>`.
as :command:`add_executable` or :command:`add_library`.
.. versionchanged:: 4.5
If ``<target>`` is an :ref:`Alias Target <Alias Targets>`, the command
operates on the target which the alias references.
By using ``AFTER`` or ``BEFORE`` explicitly, you can select between appending
and prepending, independent of the default.

View File

@@ -17,8 +17,11 @@ with the latter being interpreted as relative to the current source
directory. These items will be added to the link command.
The named ``<target>`` must have been created by a command such as
:command:`add_executable` or :command:`add_library` and must not be an
:ref:`ALIAS target <Alias Targets>`.
:command:`add_executable` or :command:`add_library`.
.. versionchanged:: 4.5
If ``<target>`` is an :ref:`Alias Target <Alias Targets>`, the command
operates on the target which the alias references.
The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
specify the :ref:`scope <Target Command Scope>` of the items that follow

View File

@@ -21,16 +21,19 @@ All of them have the general form
target_link_libraries(<target> ... <item>... ...)
The named ``<target>`` must have been created by a command such as
:command:`add_executable` or :command:`add_library` and must not be an
:ref:`ALIAS target <Alias Targets>`. If policy :policy:`CMP0079` is not
set to ``NEW`` then the target must have been created in the current
directory. Repeated calls for the same ``<target>`` append items in
the order called.
:command:`add_executable` or :command:`add_library`. If policy
:policy:`CMP0079` is not set to ``NEW``, then the target must have been
created in the current directory. Repeated calls for the same ``<target>``
append items in the order called.
.. versionadded:: 3.13
The ``<target>`` doesn't have to be defined in the same directory as the
``target_link_libraries`` call.
.. versionchanged:: 4.5
If ``<target>`` is an :ref:`Alias Target <Alias Targets>`, the command
operates on the target which the alias references.
Each ``<item>`` may be:
* **A library target name**: The generated link line will have the

View File

@@ -13,8 +13,11 @@ library target.
[{INTERFACE|PUBLIC|PRIVATE} <item>...]...)
The named ``<target>`` must have been created by a command such as
:command:`add_executable` or :command:`add_library` and must not be an
:ref:`ALIAS target <Alias Targets>`.
:command:`add_executable` or :command:`add_library`.
.. versionchanged:: 4.5
If ``<target>`` is an :ref:`Alias Target <Alias Targets>`, the command
operates on the target which the alias references.
This command can be used to add any link options, but alternative commands
exist to add libraries (:command:`target_link_libraries` or

View File

@@ -21,8 +21,11 @@ Main Form
The command adds header files to the :prop_tgt:`PRECOMPILE_HEADERS` and/or
:prop_tgt:`INTERFACE_PRECOMPILE_HEADERS` target properties of ``<target>``.
The named ``<target>`` must have been created by a command such as
:command:`add_executable` or :command:`add_library` and must not be an
:ref:`ALIAS target <Alias Targets>`.
:command:`add_executable` or :command:`add_library`.
.. versionchanged:: 4.5
If ``<target>`` is an :ref:`Alias Target <Alias Targets>`, the command
operates on the target which the alias references.
The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
specify the :ref:`scope <Target Command Scope>` of the following arguments.

View File

@@ -14,13 +14,16 @@ Add sources to a target.
Specifies sources to use when building a target and/or its dependents.
The named ``<target>`` must have been created by a command such as
:command:`add_executable` or :command:`add_library` or
:command:`add_custom_target` and must not be an
:ref:`ALIAS target <Alias Targets>`. The ``<items>`` may use
:command:`add_custom_target`. The ``<items>`` may use
:manual:`generator expressions <cmake-generator-expressions(7)>`.
.. versionadded:: 3.20
``<target>`` can be a custom target.
.. versionchanged:: 4.5
If ``<target>`` is an :ref:`Alias Target <Alias Targets>`, the command
operates on the target which the alias references.
The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
specify the :ref:`scope <Target Command Scope>` of the source file paths
(``<items>``) that follow them. ``PRIVATE`` and ``PUBLIC`` items will