get_source_file_property.rst 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. get_source_file_property
  2. ------------------------
  3. Get a property for a source file.
  4. .. code-block:: cmake
  5. get_source_file_property(VAR file [<TARGET_DIRECTORY ... | DIRECTORY ...>] property)
  6. Gets a property from a source file. The value of the property is
  7. stored in the variable ``VAR``. If the source property is not found, the
  8. behavior depends on whether it has been defined to be an ``INHERITED`` property
  9. or not (see :command:`define_property`). Non-inherited properties will set
  10. ``VAR`` to "NOTFOUND", whereas inherited properties will search the relevant
  11. parent scope as described for the :command:`define_property` command and
  12. if still unable to find the property, ``VAR`` will be set to an empty string.
  13. The queried source file scope can be changed by specifying one of the
  14. additional options: ``DIRECTORY`` or ``TARGET_DIRECTORY``.
  15. ``DIRECTORY`` takes a path to a processed directory, and the source file property
  16. will be read from that directory scope.
  17. ``TARGET_DIRECTORY`` takes the name of an existing target. The source file
  18. property will be read from this target's directory scope.
  19. Use :command:`set_source_files_properties` to set property values. Source
  20. file properties usually control how the file is built. One property that is
  21. always there is :prop_sf:`LOCATION`.
  22. See also the more general :command:`get_property` command.