cmake/Help/command/get_source_file_property.rst

51 lines
1.9 KiB
ReStructuredText
Raw Normal View History

2014-08-03 19:52:23 +02:00
get_source_file_property
------------------------
Get a property for a source file.
2019-11-11 23:01:05 +01:00
.. code-block:: cmake
2014-08-03 19:52:23 +02:00
2020-08-30 11:54:41 +02:00
get_source_file_property(<variable> <file>
[DIRECTORY <dir> | TARGET_DIRECTORY <target>]
<property>)
2014-08-03 19:52:23 +02:00
2024-02-02 17:42:32 +01:00
Gets a property from a source file. The value of the property is stored in
the specified ``<variable>``. If the ``<file>`` is not a source file, or the
source property is not found, ``<variable>`` will be set to ``NOTFOUND``.
If the source 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.
2020-08-30 11:54:41 +02:00
By default, the source file's property will be read from the current source
2021-09-14 00:13:48 +02:00
directory's scope.
2020-08-30 11:54:41 +02:00
2021-09-14 00:13:48 +02:00
.. versionadded:: 3.18
Directory scope can be overridden with one of the following sub-options:
2020-08-30 11:54:41 +02:00
2021-09-14 00:13:48 +02:00
``DIRECTORY <dir>``
The source file property will be read from the ``<dir>`` directory's
scope. CMake must already know about that source directory, either by
having added it through a call to :command:`add_subdirectory` or ``<dir>``
being the top level source directory. Relative paths are treated as
relative to the current source directory.
``TARGET_DIRECTORY <target>``
The source file property will be read from the directory scope in which
``<target>`` was created (``<target>`` must therefore already exist).
2018-08-09 18:06:22 +02:00
Use :command:`set_source_files_properties` to set property values. Source
file properties usually control how the file is built. One property that is
always there is :prop_sf:`LOCATION`.
2014-08-03 19:52:23 +02:00
2021-09-14 00:13:48 +02:00
.. note::
The :prop_sf:`GENERATED` source file property may be globally visible.
See its documentation for details.
2023-05-23 16:38:00 +02:00
See Also
^^^^^^^^
* :command:`define_property`
* the more general :command:`get_property` command
* :command:`set_source_files_properties`