set_source_files_properties.rst 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. .. note::
  29. The :prop_sf:`GENERATED` source file property may be globally visible.
  30. See its documentation for details.
  31. See Also
  32. ^^^^^^^^
  33. * :command:`define_property`
  34. * :command:`get_source_file_property`
  35. * :ref:`Source File Properties` for the list of properties known
  36. to CMake