set_property.rst 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. set_property
  2. ------------
  3. Set a named property in a given scope.
  4. .. code-block:: cmake
  5. set_property(<GLOBAL |
  6. DIRECTORY [<dir>] |
  7. TARGET [<target1> ...] |
  8. SOURCE [<src1> ...]
  9. [<TARGET_DIRECTORY ... | DIRECTORY ...>] |
  10. INSTALL [<file1> ...] |
  11. TEST [<test1> ...] |
  12. CACHE [<entry1> ...] >
  13. [APPEND] [APPEND_STRING]
  14. PROPERTY <name> [value1 ...])
  15. Sets one property on zero or more objects of a scope.
  16. The first argument determines the scope in which the property is set.
  17. It must be one of the following:
  18. ``GLOBAL``
  19. Scope is unique and does not accept a name.
  20. ``DIRECTORY``
  21. Scope defaults to the current directory but another directory
  22. (already processed by CMake) may be named by full or relative path.
  23. See also the :command:`set_directory_properties` command.
  24. ``TARGET``
  25. Scope may name zero or more existing targets.
  26. See also the :command:`set_target_properties` command.
  27. ``SOURCE``
  28. Scope may name zero or more source files. Note that source
  29. file properties are by default visible only to targets added in the same
  30. directory (``CMakeLists.txt``).
  31. The file properties can be made visible in a different directory by specifying
  32. one of the additional options: ``TARGET_DIRECTORY`` or ``DIRECTORY``.
  33. ``DIRECTORY`` takes a list of processed directories paths, and sets the file
  34. properties in those directory scopes.
  35. ``TARGET_DIRECTORY`` takes a list of existing targets. The file
  36. properties will be set in these targets' directory scopes.
  37. See also the :command:`set_source_files_properties` command.
  38. ``INSTALL``
  39. Scope may name zero or more installed file paths.
  40. These are made available to CPack to influence deployment.
  41. Both the property key and value may use generator expressions.
  42. Specific properties may apply to installed files and/or directories.
  43. Path components have to be separated by forward slashes,
  44. must be normalized and are case sensitive.
  45. To reference the installation prefix itself with a relative path use ``.``.
  46. Currently installed file properties are only defined for
  47. the WIX generator where the given paths are relative
  48. to the installation prefix.
  49. ``TEST``
  50. Scope may name zero or more existing tests.
  51. See also the :command:`set_tests_properties` command.
  52. ``CACHE``
  53. Scope must name zero or more cache existing entries.
  54. The required ``PROPERTY`` option is immediately followed by the name of
  55. the property to set. Remaining arguments are used to compose the
  56. property value in the form of a semicolon-separated list.
  57. If the ``APPEND`` option is given the list is appended to any existing
  58. property value (except that empty values are ignored and not appended).
  59. If the ``APPEND_STRING`` option is given the string is
  60. appended to any existing property value as string, i.e. it results in a
  61. longer string and not a list of strings. When using ``APPEND`` or
  62. ``APPEND_STRING`` with a property defined to support ``INHERITED``
  63. behavior (see :command:`define_property`), no inheriting occurs when
  64. finding the initial value to append to. If the property is not already
  65. directly set in the nominated scope, the command will behave as though
  66. ``APPEND`` or ``APPEND_STRING`` had not been given.
  67. See the :manual:`cmake-properties(7)` manual for a list of properties
  68. in each scope.