CMake/Help/command/get_target_property.rst
Craig Scott 8086badba4
Help: Fix wrong return values for unset inherited properties
Since ff6234509e (Help: Clarify behavior of INHERITED properties, 2018-03-21),
the docs for some get_..._property() commands incorrectly describe
the behavior for inherited properties. When a property is not set, even
in a parent scope, the returned result from the get_..._property()
command is the same whether the property is inherited or not.
The docs incorrectly stated that an empty string would be returned
for inherited properties in such cases.
2024-01-05 17:40:16 +11:00

30 lines
1.0 KiB
ReStructuredText

get_target_property
-------------------
Get a property from a target.
.. code-block:: cmake
get_target_property(<variable> <target> <property>)
Get a property from a target. The value of the property is stored in the
specified ``<variable>``. If the target property is not found, ``<variable>``
will be set to ``<variable>-NOTFOUND``. If the target property was defined to
be an ``INHERITED`` property (see :command:`define_property`), the search will
include the relevant parent scopes, as described for the
:command:`define_property` command.
Use :command:`set_target_properties` to set target property values.
Properties are usually used to control how a target is built, but some
query the target instead. This command can get properties for any
target so far created. The targets do not need to be in the current
``CMakeLists.txt`` file.
See Also
^^^^^^^^
* :command:`define_property`
* the more general :command:`get_property` command
* :command:`set_target_properties`
* :ref:`Target Properties` for the list of properties known to CMake