set_source_files_properties.rst 1.6 KB

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