get_source_file_property.rst 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. get_source_file_property
  2. ------------------------
  3. Get a property for a source file.
  4. .. code-block:: cmake
  5. get_source_file_property(<variable> <file>
  6. [DIRECTORY <dir> | TARGET_DIRECTORY <target>]
  7. <property>)
  8. Gets a property from a source file. The value of the property is stored in
  9. the specified ``<variable>``. If the ``<file>`` is not a source file, or the
  10. source property is not found, ``<variable>`` will be set to ``NOTFOUND``.
  11. If the source property was defined to be an ``INHERITED`` property (see
  12. :command:`define_property`), the search will include the relevant parent
  13. scopes, as described for the :command:`define_property` command.
  14. By default, the source file's property will be read from the current source
  15. directory's scope.
  16. .. versionadded:: 3.18
  17. Directory scope can be overridden with one of the following sub-options:
  18. ``DIRECTORY <dir>``
  19. The source file property will be read from the ``<dir>`` directory's
  20. scope. CMake must already know about that source directory, either by
  21. having added it through a call to :command:`add_subdirectory` or ``<dir>``
  22. being the top level source directory. Relative paths are treated as
  23. relative to the current source directory.
  24. ``TARGET_DIRECTORY <target>``
  25. The source file property will be read from the directory scope in which
  26. ``<target>`` was created (``<target>`` must therefore already exist).
  27. Use :command:`set_source_files_properties` to set property values. Source
  28. file properties usually control how the file is built. One property that is
  29. always there is :prop_sf:`LOCATION`.
  30. .. note::
  31. The :prop_sf:`GENERATED` source file property may be globally visible.
  32. See its documentation for details.
  33. See Also
  34. ^^^^^^^^
  35. * :command:`define_property`
  36. * the more general :command:`get_property` command
  37. * :command:`set_source_files_properties`