get_property.rst 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. get_property
  2. ------------
  3. Get a property.
  4. .. code-block:: cmake
  5. get_property(<variable>
  6. <GLOBAL |
  7. DIRECTORY [<dir>] |
  8. TARGET <target> |
  9. SOURCE <source> |
  10. INSTALL <file> |
  11. TEST <test> |
  12. CACHE <entry> |
  13. VARIABLE >
  14. PROPERTY <name>
  15. [SET | DEFINED | BRIEF_DOCS | FULL_DOCS])
  16. Gets one property from one object in a scope.
  17. The first argument specifies the variable in which to store the result.
  18. The second argument determines the scope from which to get the property.
  19. It must be one of the following:
  20. ``GLOBAL``
  21. Scope is unique and does not accept a name.
  22. ``DIRECTORY``
  23. Scope defaults to the current directory but another
  24. directory (already processed by CMake) may be named by the
  25. full or relative path ``<dir>``.
  26. ``TARGET``
  27. Scope must name one existing target.
  28. ``SOURCE``
  29. Scope must name one source file.
  30. ``INSTALL``
  31. Scope must name one installed file path.
  32. ``TEST``
  33. Scope must name one existing test.
  34. ``CACHE``
  35. Scope must name one cache entry.
  36. ``VARIABLE``
  37. Scope is unique and does not accept a name.
  38. The required ``PROPERTY`` option is immediately followed by the name of
  39. the property to get. If the property is not set an empty value is
  40. returned, although some properties support inheriting from a parent scope
  41. if defined to behave that way (see :command:`define_property`).
  42. If the ``SET`` option is given the variable is set to a boolean
  43. value indicating whether the property has been set. If the ``DEFINED``
  44. option is given the variable is set to a boolean value indicating
  45. whether the property has been defined such as with the
  46. :command:`define_property` command.
  47. If ``BRIEF_DOCS`` or ``FULL_DOCS`` is given then the variable is set to a
  48. string containing documentation for the requested property. If
  49. documentation is requested for a property that has not been defined
  50. ``NOTFOUND`` is returned.