• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1set_source_files_properties
2---------------------------
3
4Source files can have properties that affect how they are built.
5
6.. code-block:: cmake
7
8  set_source_files_properties(<files> ...
9                              [DIRECTORY <dirs> ...]
10                              [TARGET_DIRECTORY <targets> ...]
11                              PROPERTIES <prop1> <value1>
12                              [<prop2> <value2>] ...)
13
14Sets properties associated with source files using a key/value paired
15list.
16
17.. versionadded:: 3.18
18  By default, source file properties are only visible to targets added in the
19  same directory (``CMakeLists.txt``).  Visibility can be set in other directory
20  scopes using one or both of the following options:
21
22``DIRECTORY <dirs>...``
23  The source file properties will be set in each of the ``<dirs>``
24  directories' scopes.  CMake must already know about each of these
25  source directories, either by having added them through a call to
26  :command:`add_subdirectory` or it being the top level source directory.
27  Relative paths are treated as relative to the current source directory.
28
29``TARGET_DIRECTORY <targets>...``
30  The source file properties will be set in each of the directory scopes
31  where any of the specified ``<targets>`` were created (the ``<targets>``
32  must therefore already exist).
33
34Use :command:`get_source_file_property` to get property values.
35See also the :command:`set_property(SOURCE)` command.
36
37See :ref:`Source File Properties` for the list of properties known
38to CMake.
39
40.. note::
41
42  The :prop_sf:`GENERATED` source file property may be globally visible.
43  See its documentation for details.
44