install.rst 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  1. install
  2. -------
  3. Specify rules to run at install time.
  4. Synopsis
  5. ^^^^^^^^
  6. .. parsed-literal::
  7. install(`TARGETS`_ <target>... [...])
  8. install(`IMPORTED_RUNTIME_ARTIFACTS`_ <target>... [...])
  9. install({`FILES`_ | `PROGRAMS`_} <file>... [...])
  10. install(`DIRECTORY`_ <dir>... [...])
  11. install(`SCRIPT`_ <file> [...])
  12. install(`CODE`_ <code> [...])
  13. install(`EXPORT`_ <export-name> [...])
  14. install(`RUNTIME_DEPENDENCY_SET`_ <set-name> [...])
  15. Introduction
  16. ^^^^^^^^^^^^
  17. This command generates installation rules for a project. Install rules
  18. specified by calls to the ``install()`` command within a source directory
  19. are executed in order during installation.
  20. .. versionchanged:: 3.14
  21. Install rules in subdirectories
  22. added by calls to the :command:`add_subdirectory` command are interleaved
  23. with those in the parent directory to run in the order declared (see
  24. policy :policy:`CMP0082`).
  25. .. versionchanged:: 3.22
  26. The environment variable :envvar:`CMAKE_INSTALL_MODE` can override the
  27. default copying behavior of ``install()``.
  28. There are multiple signatures for this command. Some of them define
  29. installation options for files and targets. Options common to
  30. multiple signatures are covered here but they are valid only for
  31. signatures that specify them. The common options are:
  32. ``DESTINATION``
  33. Specify the directory on disk to which a file will be installed.
  34. Arguments can be relative or absolute paths.
  35. If a relative path is given it is interpreted relative to the value
  36. of the :variable:`CMAKE_INSTALL_PREFIX` variable.
  37. The prefix can be relocated at install time using the ``DESTDIR``
  38. mechanism explained in the :variable:`CMAKE_INSTALL_PREFIX` variable
  39. documentation.
  40. If an absolute path (with a leading slash or drive letter) is given
  41. it is used verbatim.
  42. As absolute paths are not supported by :manual:`cpack <cpack(1)>` installer
  43. generators, it is preferable to use relative paths throughout.
  44. In particular, there is no need to make paths absolute by prepending
  45. :variable:`CMAKE_INSTALL_PREFIX`; this prefix is used by default if
  46. the DESTINATION is a relative path.
  47. ``PERMISSIONS``
  48. Specify permissions for installed files. Valid permissions are
  49. ``OWNER_READ``, ``OWNER_WRITE``, ``OWNER_EXECUTE``, ``GROUP_READ``,
  50. ``GROUP_WRITE``, ``GROUP_EXECUTE``, ``WORLD_READ``, ``WORLD_WRITE``,
  51. ``WORLD_EXECUTE``, ``SETUID``, and ``SETGID``. Permissions that do
  52. not make sense on certain platforms are ignored on those platforms.
  53. ``CONFIGURATIONS``
  54. Specify a list of build configurations for which the install rule
  55. applies (Debug, Release, etc.). Note that the values specified for
  56. this option only apply to options listed AFTER the ``CONFIGURATIONS``
  57. option. For example, to set separate install paths for the Debug and
  58. Release configurations, do the following:
  59. .. code-block:: cmake
  60. install(TARGETS target
  61. CONFIGURATIONS Debug
  62. RUNTIME DESTINATION Debug/bin)
  63. install(TARGETS target
  64. CONFIGURATIONS Release
  65. RUNTIME DESTINATION Release/bin)
  66. Note that ``CONFIGURATIONS`` appears BEFORE ``RUNTIME DESTINATION``.
  67. ``COMPONENT``
  68. Specify an installation component name with which the install rule
  69. is associated, such as ``Runtime`` or ``Development``. During
  70. component-specific installation only install rules associated with
  71. the given component name will be executed. During a full installation
  72. all components are installed unless marked with ``EXCLUDE_FROM_ALL``.
  73. If ``COMPONENT`` is not provided a default component "Unspecified" is
  74. created. The default component name may be controlled with the
  75. :variable:`CMAKE_INSTALL_DEFAULT_COMPONENT_NAME` variable.
  76. ``EXCLUDE_FROM_ALL``
  77. .. versionadded:: 3.6
  78. Specify that the file is excluded from a full installation and only
  79. installed as part of a component-specific installation
  80. ``RENAME``
  81. Specify a name for an installed file that may be different from the
  82. original file. Renaming is allowed only when a single file is
  83. installed by the command.
  84. ``OPTIONAL``
  85. Specify that it is not an error if the file to be installed does
  86. not exist.
  87. .. versionadded:: 3.1
  88. Command signatures that install files may print messages during
  89. installation. Use the :variable:`CMAKE_INSTALL_MESSAGE` variable
  90. to control which messages are printed.
  91. .. versionadded:: 3.11
  92. Many of the ``install()`` variants implicitly create the directories
  93. containing the installed files. If
  94. :variable:`CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS` is set, these
  95. directories will be created with the permissions specified. Otherwise,
  96. they will be created according to the uname rules on Unix-like platforms.
  97. Windows platforms are unaffected.
  98. Installing Targets
  99. ^^^^^^^^^^^^^^^^^^
  100. .. _`install(TARGETS)`:
  101. .. _TARGETS:
  102. .. code-block:: cmake
  103. install(TARGETS targets... [EXPORT <export-name>]
  104. [RUNTIME_DEPENDENCIES args...|RUNTIME_DEPENDENCY_SET <set-name>]
  105. [[ARCHIVE|LIBRARY|RUNTIME|OBJECTS|FRAMEWORK|BUNDLE|
  106. PRIVATE_HEADER|PUBLIC_HEADER|RESOURCE|FILE_SET <set-name>|CXX_MODULES_BMI]
  107. [DESTINATION <dir>]
  108. [PERMISSIONS permissions...]
  109. [CONFIGURATIONS [Debug|Release|...]]
  110. [COMPONENT <component>]
  111. [NAMELINK_COMPONENT <component>]
  112. [OPTIONAL] [EXCLUDE_FROM_ALL]
  113. [NAMELINK_ONLY|NAMELINK_SKIP]
  114. ] [...]
  115. [INCLUDES DESTINATION [<dir> ...]]
  116. )
  117. The ``TARGETS`` form specifies rules for installing targets from a
  118. project. There are several kinds of target :ref:`Output Artifacts`
  119. that may be installed:
  120. ``ARCHIVE``
  121. Target artifacts of this kind include:
  122. * *Static libraries*
  123. (except on macOS when marked as ``FRAMEWORK``, see below);
  124. * *DLL import libraries*
  125. (on all Windows-based systems including Cygwin; they have extension
  126. ``.lib``, in contrast to the ``.dll`` libraries that go to ``RUNTIME``);
  127. * On AIX, the *linker import file* created for executables with
  128. :prop_tgt:`ENABLE_EXPORTS` enabled.
  129. * On macOS, the *linker import file* created for shared libraries with
  130. :prop_tgt:`ENABLE_EXPORTS` enabled (except when marked as ``FRAMEWORK``,
  131. see below).
  132. ``LIBRARY``
  133. Target artifacts of this kind include:
  134. * *Shared libraries*, except
  135. - DLLs (these go to ``RUNTIME``, see below),
  136. - on macOS when marked as ``FRAMEWORK`` (see below).
  137. ``RUNTIME``
  138. Target artifacts of this kind include:
  139. * *Executables*
  140. (except on macOS when marked as ``MACOSX_BUNDLE``, see ``BUNDLE`` below);
  141. * DLLs (on all Windows-based systems including Cygwin; note that the
  142. accompanying import libraries are of kind ``ARCHIVE``).
  143. ``OBJECTS``
  144. .. versionadded:: 3.9
  145. Object files associated with *object libraries*.
  146. ``FRAMEWORK``
  147. Both static and shared libraries marked with the ``FRAMEWORK``
  148. property are treated as ``FRAMEWORK`` targets on macOS.
  149. ``BUNDLE``
  150. Executables marked with the :prop_tgt:`MACOSX_BUNDLE` property are treated as
  151. ``BUNDLE`` targets on macOS.
  152. ``PUBLIC_HEADER``
  153. Any :prop_tgt:`PUBLIC_HEADER` files associated with a library are installed in
  154. the destination specified by the ``PUBLIC_HEADER`` argument on non-Apple
  155. platforms. Rules defined by this argument are ignored for :prop_tgt:`FRAMEWORK`
  156. libraries on Apple platforms because the associated files are installed
  157. into the appropriate locations inside the framework folder. See
  158. :prop_tgt:`PUBLIC_HEADER` for details.
  159. ``PRIVATE_HEADER``
  160. Similar to ``PUBLIC_HEADER``, but for ``PRIVATE_HEADER`` files. See
  161. :prop_tgt:`PRIVATE_HEADER` for details.
  162. ``RESOURCE``
  163. Similar to ``PUBLIC_HEADER`` and ``PRIVATE_HEADER``, but for
  164. ``RESOURCE`` files. See :prop_tgt:`RESOURCE` for details.
  165. ``FILE_SET <set>``
  166. .. versionadded:: 3.23
  167. File sets are defined by the :command:`target_sources(FILE_SET)` command.
  168. If the file set ``<set>`` exists and is ``PUBLIC`` or ``INTERFACE``, any
  169. files in the set are installed under the destination (see below).
  170. The directory structure relative to the file set's base directories is
  171. preserved. For example, a file added to the file set as
  172. ``/blah/include/myproj/here.h`` with a base directory ``/blah/include``
  173. would be installed to ``myproj/here.h`` below the destination.
  174. ``CXX_MODULES_BMI``
  175. .. note ::
  176. Experimental. Gated by ``CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API``
  177. Any module files from C++ modules from ``PUBLIC`` sources in a file set of
  178. type ``CXX_MODULES`` will be installed to the given ``DESTINATION``. All
  179. modules are placed directly in the destination as no directory structure is
  180. derived from the names of the modules. An empty ``DESTINATION`` may be used
  181. to suppress installing these files (for use in generic code).
  182. For each of these arguments given, the arguments following them only apply
  183. to the target or file type specified in the argument. If none is given, the
  184. installation properties apply to all target types.
  185. For regular executables, static libraries and shared libraries, the
  186. ``DESTINATION`` argument is not required. For these target types, when
  187. ``DESTINATION`` is omitted, a default destination will be taken from the
  188. appropriate variable from :module:`GNUInstallDirs`, or set to a built-in
  189. default value if that variable is not defined. The same is true for file
  190. sets, and the public and private headers associated with the installed
  191. targets through the :prop_tgt:`PUBLIC_HEADER` and :prop_tgt:`PRIVATE_HEADER`
  192. target properties. A destination must always be provided for module libraries,
  193. Apple bundles and frameworks. A destination can be omitted for interface and
  194. object libraries, but they are handled differently (see the discussion of this
  195. topic toward the end of this section).
  196. For shared libraries on DLL platforms, if neither ``RUNTIME`` nor ``ARCHIVE``
  197. destinations are specified, both the ``RUNTIME`` and ``ARCHIVE`` components are
  198. installed to their default destinations. If either a ``RUNTIME`` or ``ARCHIVE``
  199. destination is specified, the component is installed to that destination, and
  200. the other component is not installed. If both ``RUNTIME`` and ``ARCHIVE``
  201. destinations are specified, then both components are installed to their
  202. respective destinations.
  203. The following table shows the target types with their associated variables and
  204. built-in defaults that apply when no destination is given:
  205. =============================== =============================== ======================
  206. Target Type GNUInstallDirs Variable Built-In Default
  207. =============================== =============================== ======================
  208. ``RUNTIME`` ``${CMAKE_INSTALL_BINDIR}`` ``bin``
  209. ``LIBRARY`` ``${CMAKE_INSTALL_LIBDIR}`` ``lib``
  210. ``ARCHIVE`` ``${CMAKE_INSTALL_LIBDIR}`` ``lib``
  211. ``PRIVATE_HEADER`` ``${CMAKE_INSTALL_INCLUDEDIR}`` ``include``
  212. ``PUBLIC_HEADER`` ``${CMAKE_INSTALL_INCLUDEDIR}`` ``include``
  213. ``FILE_SET`` (type ``HEADERS``) ``${CMAKE_INSTALL_INCLUDEDIR}`` ``include``
  214. =============================== =============================== ======================
  215. Projects wishing to follow the common practice of installing headers into a
  216. project-specific subdirectory may prefer using file sets with appropriate
  217. paths and base directories. Otherwise, they must provide a ``DESTINATION``
  218. instead of being able to rely on the above (see next example below).
  219. To make packages compliant with distribution filesystem layout policies, if
  220. projects must specify a ``DESTINATION``, it is recommended that they use a
  221. path that begins with the appropriate :module:`GNUInstallDirs` variable.
  222. This allows package maintainers to control the install destination by setting
  223. the appropriate cache variables. The following example shows a static library
  224. being installed to the default destination provided by
  225. :module:`GNUInstallDirs`, but with its headers installed to a project-specific
  226. subdirectory without using file sets:
  227. .. code-block:: cmake
  228. add_library(mylib STATIC ...)
  229. set_target_properties(mylib PROPERTIES PUBLIC_HEADER mylib.h)
  230. include(GNUInstallDirs)
  231. install(TARGETS mylib
  232. PUBLIC_HEADER
  233. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/myproj
  234. )
  235. In addition to the common options listed above, each target can accept
  236. the following additional arguments:
  237. ``NAMELINK_COMPONENT``
  238. .. versionadded:: 3.12
  239. On some platforms a versioned shared library has a symbolic link such
  240. as::
  241. lib<name>.so -> lib<name>.so.1
  242. where ``lib<name>.so.1`` is the soname of the library and ``lib<name>.so``
  243. is a "namelink" allowing linkers to find the library when given
  244. ``-l<name>``. The ``NAMELINK_COMPONENT`` option is similar to the
  245. ``COMPONENT`` option, but it changes the installation component of a shared
  246. library namelink if one is generated. If not specified, this defaults to the
  247. value of ``COMPONENT``. It is an error to use this parameter outside of a
  248. ``LIBRARY`` block.
  249. .. versionchanged:: 3.27
  250. This parameter is also usable for an ``ARCHIVE`` block to manage
  251. the linker import file created, on macOS, for shared libraries with
  252. :prop_tgt:`ENABLE_EXPORTS` enabled.
  253. Consider the following example:
  254. .. code-block:: cmake
  255. install(TARGETS mylib
  256. LIBRARY
  257. COMPONENT Libraries
  258. NAMELINK_COMPONENT Development
  259. PUBLIC_HEADER
  260. COMPONENT Development
  261. )
  262. In this scenario, if you choose to install only the ``Development``
  263. component, both the headers and namelink will be installed without the
  264. library. (If you don't also install the ``Libraries`` component, the
  265. namelink will be a dangling symlink, and projects that link to the library
  266. will have build errors.) If you install only the ``Libraries`` component,
  267. only the library will be installed, without the headers and namelink.
  268. This option is typically used for package managers that have separate
  269. runtime and development packages. For example, on Debian systems, the
  270. library is expected to be in the runtime package, and the headers and
  271. namelink are expected to be in the development package.
  272. See the :prop_tgt:`VERSION` and :prop_tgt:`SOVERSION` target properties for
  273. details on creating versioned shared libraries.
  274. ``NAMELINK_ONLY``
  275. This option causes the installation of only the namelink when a library
  276. target is installed. On platforms where versioned shared libraries do not
  277. have namelinks or when a library is not versioned, the ``NAMELINK_ONLY``
  278. option installs nothing. It is an error to use this parameter outside of a
  279. ``LIBRARY`` block.
  280. .. versionchanged:: 3.27
  281. This parameter is also usable for an ``ARCHIVE`` block to manage
  282. the linker import file created, on macOS, for shared libraries with
  283. :prop_tgt:`ENABLE_EXPORTS` enabled.
  284. When ``NAMELINK_ONLY`` is given, either ``NAMELINK_COMPONENT`` or
  285. ``COMPONENT`` may be used to specify the installation component of the
  286. namelink, but ``COMPONENT`` should generally be preferred.
  287. ``NAMELINK_SKIP``
  288. Similar to ``NAMELINK_ONLY``, but it has the opposite effect: it causes the
  289. installation of library files other than the namelink when a library target
  290. is installed. When neither ``NAMELINK_ONLY`` or ``NAMELINK_SKIP`` are given,
  291. both portions are installed. On platforms where versioned shared libraries
  292. do not have symlinks or when a library is not versioned, ``NAMELINK_SKIP``
  293. installs the library. It is an error to use this parameter outside of a
  294. ``LIBRARY`` block.
  295. .. versionchanged:: 3.27
  296. This parameter is also usable for an ``ARCHIVE`` block to manage
  297. the linker import file created, on macOS, for shared libraries with
  298. :prop_tgt:`ENABLE_EXPORTS` enabled.
  299. If ``NAMELINK_SKIP`` is specified, ``NAMELINK_COMPONENT`` has no effect. It
  300. is not recommended to use ``NAMELINK_SKIP`` in conjunction with
  301. ``NAMELINK_COMPONENT``.
  302. The `install(TARGETS)`_ command can also accept the following options at the
  303. top level:
  304. ``EXPORT``
  305. This option associates the installed target files with an export called
  306. ``<export-name>``. It must appear before any target options. To actually
  307. install the export file itself, call `install(EXPORT)`_, documented below.
  308. See documentation of the :prop_tgt:`EXPORT_NAME` target property to change
  309. the name of the exported target.
  310. If ``EXPORT`` is used and the targets include ``PUBLIC`` or ``INTERFACE``
  311. file sets, all of them must be specified with ``FILE_SET`` arguments. All
  312. ``PUBLIC`` or ``INTERFACE`` file sets associated with a target are included
  313. in the export.
  314. ``INCLUDES DESTINATION``
  315. This option specifies a list of directories which will be added to the
  316. :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` target property of the
  317. ``<targets>`` when exported by the `install(EXPORT)`_ command. If a
  318. relative path is specified, it is treated as relative to the
  319. :genex:`$<INSTALL_PREFIX>`.
  320. ``RUNTIME_DEPENDENCY_SET``
  321. .. versionadded:: 3.21
  322. This option causes all runtime dependencies of installed executable, shared
  323. library, and module targets to be added to the specified runtime dependency
  324. set. This set can then be installed with an
  325. `install(RUNTIME_DEPENDENCY_SET)`_ command.
  326. This keyword and the ``RUNTIME_DEPENDENCIES`` keyword are mutually
  327. exclusive.
  328. ``RUNTIME_DEPENDENCIES``
  329. .. versionadded:: 3.21
  330. This option causes all runtime dependencies of installed executable, shared
  331. library, and module targets to be installed along with the targets
  332. themselves. The ``RUNTIME``, ``LIBRARY``, ``FRAMEWORK``, and generic
  333. arguments are used to determine the properties (``DESTINATION``,
  334. ``COMPONENT``, etc.) of the installation of these dependencies.
  335. ``RUNTIME_DEPENDENCIES`` is semantically equivalent to the following pair
  336. of calls:
  337. .. code-block:: cmake
  338. install(TARGETS ... RUNTIME_DEPENDENCY_SET <set-name>)
  339. install(RUNTIME_DEPENDENCY_SET <set-name> args...)
  340. where ``<set-name>`` will be a randomly generated set name.
  341. The ``args...`` may include any of the following keywords supported by
  342. the `install(RUNTIME_DEPENDENCY_SET)`_ command:
  343. * ``DIRECTORIES``
  344. * ``PRE_INCLUDE_REGEXES``
  345. * ``PRE_EXCLUDE_REGEXES``
  346. * ``POST_INCLUDE_REGEXES``
  347. * ``POST_EXCLUDE_REGEXES``
  348. * ``POST_INCLUDE_FILES``
  349. * ``POST_EXCLUDE_FILES``
  350. The ``RUNTIME_DEPENDENCIES`` and ``RUNTIME_DEPENDENCY_SET`` keywords are
  351. mutually exclusive.
  352. One or more groups of properties may be specified in a single call to
  353. the ``TARGETS`` form of this command. A target may be installed more than
  354. once to different locations. Consider hypothetical targets ``myExe``,
  355. ``mySharedLib``, and ``myStaticLib``. The code:
  356. .. code-block:: cmake
  357. install(TARGETS myExe mySharedLib myStaticLib
  358. RUNTIME DESTINATION bin
  359. LIBRARY DESTINATION lib
  360. ARCHIVE DESTINATION lib/static)
  361. install(TARGETS mySharedLib DESTINATION /some/full/path)
  362. will install ``myExe`` to ``<prefix>/bin`` and ``myStaticLib`` to
  363. ``<prefix>/lib/static``. On non-DLL platforms ``mySharedLib`` will be
  364. installed to ``<prefix>/lib`` and ``/some/full/path``. On DLL platforms
  365. the ``mySharedLib`` DLL will be installed to ``<prefix>/bin`` and
  366. ``/some/full/path`` and its import library will be installed to
  367. ``<prefix>/lib/static`` and ``/some/full/path``.
  368. :ref:`Interface Libraries` may be listed among the targets to install.
  369. They install no artifacts but will be included in an associated ``EXPORT``.
  370. If :ref:`Object Libraries` are listed but given no destination for their
  371. object files, they will be exported as :ref:`Interface Libraries`.
  372. This is sufficient to satisfy transitive usage requirements of other
  373. targets that link to the object libraries in their implementation.
  374. Installing a target with the :prop_tgt:`EXCLUDE_FROM_ALL` target property
  375. set to ``TRUE`` has undefined behavior.
  376. .. versionadded:: 3.3
  377. An install destination given as a ``DESTINATION`` argument may
  378. use "generator expressions" with the syntax ``$<...>``. See the
  379. :manual:`cmake-generator-expressions(7)` manual for available expressions.
  380. .. versionadded:: 3.13
  381. `install(TARGETS)`_ can install targets that were created in
  382. other directories. When using such cross-directory install rules, running
  383. ``make install`` (or similar) from a subdirectory will not guarantee that
  384. targets from other directories are up-to-date. You can use
  385. :command:`target_link_libraries` or :command:`add_dependencies`
  386. to ensure that such out-of-directory targets are built before the
  387. subdirectory-specific install rules are run.
  388. Installing Imported Runtime Artifacts
  389. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  390. .. _`install(IMPORTED_RUNTIME_ARTIFACTS)`:
  391. .. _IMPORTED_RUNTIME_ARTIFACTS:
  392. .. versionadded:: 3.21
  393. .. code-block:: cmake
  394. install(IMPORTED_RUNTIME_ARTIFACTS targets...
  395. [RUNTIME_DEPENDENCY_SET <set-name>]
  396. [[LIBRARY|RUNTIME|FRAMEWORK|BUNDLE]
  397. [DESTINATION <dir>]
  398. [PERMISSIONS permissions...]
  399. [CONFIGURATIONS [Debug|Release|...]]
  400. [COMPONENT <component>]
  401. [OPTIONAL] [EXCLUDE_FROM_ALL]
  402. ] [...]
  403. )
  404. The ``IMPORTED_RUNTIME_ARTIFACTS`` form specifies rules for installing the
  405. runtime artifacts of imported targets. Projects may do this if they want to
  406. bundle outside executables or modules inside their installation. The
  407. ``LIBRARY``, ``RUNTIME``, ``FRAMEWORK``, and ``BUNDLE`` arguments have the
  408. same semantics that they do in the `TARGETS`_ mode. Only the runtime artifacts
  409. of imported targets are installed (except in the case of :prop_tgt:`FRAMEWORK`
  410. libraries, :prop_tgt:`MACOSX_BUNDLE` executables, and :prop_tgt:`BUNDLE`
  411. CFBundles.) For example, headers and import libraries associated with DLLs are
  412. not installed. In the case of :prop_tgt:`FRAMEWORK` libraries,
  413. :prop_tgt:`MACOSX_BUNDLE` executables, and :prop_tgt:`BUNDLE` CFBundles, the
  414. entire directory is installed.
  415. The ``RUNTIME_DEPENDENCY_SET`` option causes the runtime artifacts of the
  416. imported executable, shared library, and module library ``targets`` to be
  417. added to the ``<set-name>`` runtime dependency set. This set can then be
  418. installed with an `install(RUNTIME_DEPENDENCY_SET)`_ command.
  419. Installing Files
  420. ^^^^^^^^^^^^^^^^
  421. .. _`install(FILES)`:
  422. .. _`install(PROGRAMS)`:
  423. .. _FILES:
  424. .. _PROGRAMS:
  425. .. note::
  426. If installing header files, consider using file sets defined by
  427. :command:`target_sources(FILE_SET)` instead. File sets associate
  428. headers with a target and they install as part of the target.
  429. .. code-block:: cmake
  430. install(<FILES|PROGRAMS> files...
  431. TYPE <type> | DESTINATION <dir>
  432. [PERMISSIONS permissions...]
  433. [CONFIGURATIONS [Debug|Release|...]]
  434. [COMPONENT <component>]
  435. [RENAME <name>] [OPTIONAL] [EXCLUDE_FROM_ALL])
  436. The ``FILES`` form specifies rules for installing files for a project.
  437. File names given as relative paths are interpreted with respect to the
  438. current source directory. Files installed by this form are by default
  439. given permissions ``OWNER_WRITE``, ``OWNER_READ``, ``GROUP_READ``, and
  440. ``WORLD_READ`` if no ``PERMISSIONS`` argument is given.
  441. The ``PROGRAMS`` form is identical to the ``FILES`` form except that the
  442. default permissions for the installed file also include ``OWNER_EXECUTE``,
  443. ``GROUP_EXECUTE``, and ``WORLD_EXECUTE``. This form is intended to install
  444. programs that are not targets, such as shell scripts. Use the ``TARGETS``
  445. form to install targets built within the project.
  446. The list of ``files...`` given to ``FILES`` or ``PROGRAMS`` may use
  447. "generator expressions" with the syntax ``$<...>``. See the
  448. :manual:`cmake-generator-expressions(7)` manual for available expressions.
  449. However, if any item begins in a generator expression it must evaluate
  450. to a full path.
  451. Either a ``TYPE`` or a ``DESTINATION`` must be provided, but not both.
  452. A ``TYPE`` argument specifies the generic file type of the files being
  453. installed. A destination will then be set automatically by taking the
  454. corresponding variable from :module:`GNUInstallDirs`, or by using a
  455. built-in default if that variable is not defined. See the table below for
  456. the supported file types and their corresponding variables and built-in
  457. defaults. Projects can provide a ``DESTINATION`` argument instead of a
  458. file type if they wish to explicitly define the install destination.
  459. ======================= ================================== =========================
  460. ``TYPE`` Argument GNUInstallDirs Variable Built-In Default
  461. ======================= ================================== =========================
  462. ``BIN`` ``${CMAKE_INSTALL_BINDIR}`` ``bin``
  463. ``SBIN`` ``${CMAKE_INSTALL_SBINDIR}`` ``sbin``
  464. ``LIB`` ``${CMAKE_INSTALL_LIBDIR}`` ``lib``
  465. ``INCLUDE`` ``${CMAKE_INSTALL_INCLUDEDIR}`` ``include``
  466. ``SYSCONF`` ``${CMAKE_INSTALL_SYSCONFDIR}`` ``etc``
  467. ``SHAREDSTATE`` ``${CMAKE_INSTALL_SHARESTATEDIR}`` ``com``
  468. ``LOCALSTATE`` ``${CMAKE_INSTALL_LOCALSTATEDIR}`` ``var``
  469. ``RUNSTATE`` ``${CMAKE_INSTALL_RUNSTATEDIR}`` ``<LOCALSTATE dir>/run``
  470. ``DATA`` ``${CMAKE_INSTALL_DATADIR}`` ``<DATAROOT dir>``
  471. ``INFO`` ``${CMAKE_INSTALL_INFODIR}`` ``<DATAROOT dir>/info``
  472. ``LOCALE`` ``${CMAKE_INSTALL_LOCALEDIR}`` ``<DATAROOT dir>/locale``
  473. ``MAN`` ``${CMAKE_INSTALL_MANDIR}`` ``<DATAROOT dir>/man``
  474. ``DOC`` ``${CMAKE_INSTALL_DOCDIR}`` ``<DATAROOT dir>/doc``
  475. ======================= ================================== =========================
  476. Projects wishing to follow the common practice of installing headers into a
  477. project-specific subdirectory will need to provide a destination rather than
  478. rely on the above. Using file sets for headers instead of ``install(FILES)``
  479. would be even better (see :command:`target_sources(FILE_SET)`).
  480. Note that some of the types' built-in defaults use the ``DATAROOT`` directory as
  481. a prefix. The ``DATAROOT`` prefix is calculated similarly to the types, with
  482. ``CMAKE_INSTALL_DATAROOTDIR`` as the variable and ``share`` as the built-in
  483. default. You cannot use ``DATAROOT`` as a ``TYPE`` parameter; please use
  484. ``DATA`` instead.
  485. To make packages compliant with distribution filesystem layout policies, if
  486. projects must specify a ``DESTINATION``, it is recommended that they use a
  487. path that begins with the appropriate :module:`GNUInstallDirs` variable.
  488. This allows package maintainers to control the install destination by setting
  489. the appropriate cache variables. The following example shows how to follow
  490. this advice while installing an image to a project-specific documentation
  491. subdirectory:
  492. .. code-block:: cmake
  493. include(GNUInstallDirs)
  494. install(FILES logo.png
  495. DESTINATION ${CMAKE_INSTALL_DOCDIR}/myproj
  496. )
  497. .. versionadded:: 3.4
  498. An install destination given as a ``DESTINATION`` argument may
  499. use "generator expressions" with the syntax ``$<...>``. See the
  500. :manual:`cmake-generator-expressions(7)` manual for available expressions.
  501. .. versionadded:: 3.20
  502. An install rename given as a ``RENAME`` argument may
  503. use "generator expressions" with the syntax ``$<...>``. See the
  504. :manual:`cmake-generator-expressions(7)` manual for available expressions.
  505. Installing Directories
  506. ^^^^^^^^^^^^^^^^^^^^^^
  507. .. _`install(DIRECTORY)`:
  508. .. _DIRECTORY:
  509. .. note::
  510. To install a directory sub-tree of headers, consider using file sets
  511. defined by :command:`target_sources(FILE_SET)` instead. File sets not only
  512. preserve directory structure, they also associate headers with a target
  513. and install as part of the target.
  514. .. code-block:: cmake
  515. install(DIRECTORY dirs...
  516. TYPE <type> | DESTINATION <dir>
  517. [FILE_PERMISSIONS permissions...]
  518. [DIRECTORY_PERMISSIONS permissions...]
  519. [USE_SOURCE_PERMISSIONS] [OPTIONAL] [MESSAGE_NEVER]
  520. [CONFIGURATIONS [Debug|Release|...]]
  521. [COMPONENT <component>] [EXCLUDE_FROM_ALL]
  522. [FILES_MATCHING]
  523. [[PATTERN <pattern> | REGEX <regex>]
  524. [EXCLUDE] [PERMISSIONS permissions...]] [...])
  525. The ``DIRECTORY`` form installs contents of one or more directories to a
  526. given destination. The directory structure is copied verbatim to the
  527. destination. The last component of each directory name is appended to
  528. the destination directory but a trailing slash may be used to avoid
  529. this because it leaves the last component empty. Directory names
  530. given as relative paths are interpreted with respect to the current
  531. source directory. If no input directory names are given the
  532. destination directory will be created but nothing will be installed
  533. into it. The ``FILE_PERMISSIONS`` and ``DIRECTORY_PERMISSIONS`` options
  534. specify permissions given to files and directories in the destination.
  535. If ``USE_SOURCE_PERMISSIONS`` is specified and ``FILE_PERMISSIONS`` is not,
  536. file permissions will be copied from the source directory structure.
  537. If no permissions are specified files will be given the default
  538. permissions specified in the ``FILES`` form of the command, and the
  539. directories will be given the default permissions specified in the
  540. ``PROGRAMS`` form of the command.
  541. .. versionadded:: 3.1
  542. The ``MESSAGE_NEVER`` option disables file installation status output.
  543. Installation of directories may be controlled with fine granularity
  544. using the ``PATTERN`` or ``REGEX`` options. These "match" options specify a
  545. globbing pattern or regular expression to match directories or files
  546. encountered within input directories. They may be used to apply
  547. certain options (see below) to a subset of the files and directories
  548. encountered. The full path to each input file or directory (with
  549. forward slashes) is matched against the expression. A ``PATTERN`` will
  550. match only complete file names: the portion of the full path matching
  551. the pattern must occur at the end of the file name and be preceded by
  552. a slash. A ``REGEX`` will match any portion of the full path but it may
  553. use ``/`` and ``$`` to simulate the ``PATTERN`` behavior. By default all
  554. files and directories are installed whether or not they are matched.
  555. The ``FILES_MATCHING`` option may be given before the first match option
  556. to disable installation of files (but not directories) not matched by
  557. any expression. For example, the code
  558. .. code-block:: cmake
  559. install(DIRECTORY src/ DESTINATION doc/myproj
  560. FILES_MATCHING PATTERN "*.png")
  561. will extract and install images from a source tree.
  562. Some options may follow a ``PATTERN`` or ``REGEX`` expression as described
  563. under :ref:`string(REGEX) <Regex Specification>` and are applied
  564. only to files or directories matching them. The ``EXCLUDE`` option will
  565. skip the matched file or directory. The ``PERMISSIONS`` option overrides
  566. the permissions setting for the matched file or directory. For
  567. example the code
  568. .. code-block:: cmake
  569. install(DIRECTORY icons scripts/ DESTINATION share/myproj
  570. PATTERN "CVS" EXCLUDE
  571. PATTERN "scripts/*"
  572. PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
  573. GROUP_EXECUTE GROUP_READ)
  574. will install the ``icons`` directory to ``share/myproj/icons`` and the
  575. ``scripts`` directory to ``share/myproj``. The icons will get default
  576. file permissions, the scripts will be given specific permissions, and any
  577. ``CVS`` directories will be excluded.
  578. Either a ``TYPE`` or a ``DESTINATION`` must be provided, but not both.
  579. A ``TYPE`` argument specifies the generic file type of the files within the
  580. listed directories being installed. A destination will then be set
  581. automatically by taking the corresponding variable from
  582. :module:`GNUInstallDirs`, or by using a built-in default if that variable
  583. is not defined. See the table below for the supported file types and their
  584. corresponding variables and built-in defaults. Projects can provide a
  585. ``DESTINATION`` argument instead of a file type if they wish to explicitly
  586. define the install destination.
  587. ======================= ================================== =========================
  588. ``TYPE`` Argument GNUInstallDirs Variable Built-In Default
  589. ======================= ================================== =========================
  590. ``BIN`` ``${CMAKE_INSTALL_BINDIR}`` ``bin``
  591. ``SBIN`` ``${CMAKE_INSTALL_SBINDIR}`` ``sbin``
  592. ``LIB`` ``${CMAKE_INSTALL_LIBDIR}`` ``lib``
  593. ``INCLUDE`` ``${CMAKE_INSTALL_INCLUDEDIR}`` ``include``
  594. ``SYSCONF`` ``${CMAKE_INSTALL_SYSCONFDIR}`` ``etc``
  595. ``SHAREDSTATE`` ``${CMAKE_INSTALL_SHARESTATEDIR}`` ``com``
  596. ``LOCALSTATE`` ``${CMAKE_INSTALL_LOCALSTATEDIR}`` ``var``
  597. ``RUNSTATE`` ``${CMAKE_INSTALL_RUNSTATEDIR}`` ``<LOCALSTATE dir>/run``
  598. ``DATA`` ``${CMAKE_INSTALL_DATADIR}`` ``<DATAROOT dir>``
  599. ``INFO`` ``${CMAKE_INSTALL_INFODIR}`` ``<DATAROOT dir>/info``
  600. ``LOCALE`` ``${CMAKE_INSTALL_LOCALEDIR}`` ``<DATAROOT dir>/locale``
  601. ``MAN`` ``${CMAKE_INSTALL_MANDIR}`` ``<DATAROOT dir>/man``
  602. ``DOC`` ``${CMAKE_INSTALL_DOCDIR}`` ``<DATAROOT dir>/doc``
  603. ======================= ================================== =========================
  604. Note that some of the types' built-in defaults use the ``DATAROOT`` directory as
  605. a prefix. The ``DATAROOT`` prefix is calculated similarly to the types, with
  606. ``CMAKE_INSTALL_DATAROOTDIR`` as the variable and ``share`` as the built-in
  607. default. You cannot use ``DATAROOT`` as a ``TYPE`` parameter; please use
  608. ``DATA`` instead.
  609. To make packages compliant with distribution filesystem layout policies, if
  610. projects must specify a ``DESTINATION``, it is recommended that they use a
  611. path that begins with the appropriate :module:`GNUInstallDirs` variable.
  612. This allows package maintainers to control the install destination by setting
  613. the appropriate cache variables.
  614. .. versionadded:: 3.4
  615. An install destination given as a ``DESTINATION`` argument may
  616. use "generator expressions" with the syntax ``$<...>``. See the
  617. :manual:`cmake-generator-expressions(7)` manual for available expressions.
  618. .. versionadded:: 3.5
  619. The list of ``dirs...`` given to ``DIRECTORY`` may use
  620. "generator expressions" too.
  621. Custom Installation Logic
  622. ^^^^^^^^^^^^^^^^^^^^^^^^^
  623. .. _`install(CODE)`:
  624. .. _`install(SCRIPT)`:
  625. .. _CODE:
  626. .. _SCRIPT:
  627. .. code-block:: cmake
  628. install([[SCRIPT <file>] [CODE <code>]]
  629. [ALL_COMPONENTS | COMPONENT <component>]
  630. [EXCLUDE_FROM_ALL] [...])
  631. The ``SCRIPT`` form will invoke the given CMake script files during
  632. installation. If the script file name is a relative path it will be
  633. interpreted with respect to the current source directory. The ``CODE``
  634. form will invoke the given CMake code during installation. Code is
  635. specified as a single argument inside a double-quoted string. For
  636. example, the code
  637. .. code-block:: cmake
  638. install(CODE "MESSAGE(\"Sample install message.\")")
  639. will print a message during installation.
  640. .. versionadded:: 3.21
  641. When the ``ALL_COMPONENTS`` option is given, the custom installation
  642. script code will be executed for every component of a component-specific
  643. installation. This option is mutually exclusive with the ``COMPONENT``
  644. option.
  645. .. versionadded:: 3.14
  646. ``<file>`` or ``<code>`` may use "generator expressions" with the syntax
  647. ``$<...>`` (in the case of ``<file>``, this refers to their use in the file
  648. name, not the file's contents). See the
  649. :manual:`cmake-generator-expressions(7)` manual for available expressions.
  650. Installing Exports
  651. ^^^^^^^^^^^^^^^^^^
  652. .. _`install(EXPORT)`:
  653. .. _EXPORT:
  654. .. code-block:: cmake
  655. install(EXPORT <export-name> DESTINATION <dir>
  656. [NAMESPACE <namespace>] [FILE <name>.cmake]
  657. [PERMISSIONS permissions...]
  658. [CONFIGURATIONS [Debug|Release|...]
  659. [CXX_MODULES_DIRECTORY <directory>]
  660. [EXPORT_LINK_INTERFACE_LIBRARIES]
  661. [COMPONENT <component>]
  662. [EXCLUDE_FROM_ALL])
  663. install(EXPORT_ANDROID_MK <export-name> DESTINATION <dir> [...])
  664. The ``EXPORT`` form generates and installs a CMake file containing code to
  665. import targets from the installation tree into another project.
  666. Target installations are associated with the export ``<export-name>``
  667. using the ``EXPORT`` option of the `install(TARGETS)`_ signature
  668. documented above. The ``NAMESPACE`` option will prepend ``<namespace>`` to
  669. the target names as they are written to the import file. By default
  670. the generated file will be called ``<export-name>.cmake`` but the ``FILE``
  671. option may be used to specify a different name. The value given to
  672. the ``FILE`` option must be a file name with the ``.cmake`` extension.
  673. If a ``CONFIGURATIONS`` option is given then the file will only be installed
  674. when one of the named configurations is installed. Additionally, the
  675. generated import file will reference only the matching target
  676. configurations. The ``EXPORT_LINK_INTERFACE_LIBRARIES`` keyword, if
  677. present, causes the contents of the properties matching
  678. ``(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?`` to be exported, when
  679. policy :policy:`CMP0022` is ``NEW``.
  680. .. note::
  681. The installed ``<export-name>.cmake`` file may come with additional
  682. per-configuration ``<export-name>-*.cmake`` files to be loaded by
  683. globbing. Do not use an export name that is the same as the package
  684. name in combination with installing a ``<package-name>-config.cmake``
  685. file or the latter may be incorrectly matched by the glob and loaded.
  686. When a ``COMPONENT`` option is given, the listed ``<component>`` implicitly
  687. depends on all components mentioned in the export set. The exported
  688. ``<name>.cmake`` file will require each of the exported components to be
  689. present in order for dependent projects to build properly. For example, a
  690. project may define components ``Runtime`` and ``Development``, with shared
  691. libraries going into the ``Runtime`` component and static libraries and
  692. headers going into the ``Development`` component. The export set would also
  693. typically be part of the ``Development`` component, but it would export
  694. targets from both the ``Runtime`` and ``Development`` components. Therefore,
  695. the ``Runtime`` component would need to be installed if the ``Development``
  696. component was installed, but not vice versa. If the ``Development`` component
  697. was installed without the ``Runtime`` component, dependent projects that try
  698. to link against it would have build errors. Package managers, such as APT and
  699. RPM, typically handle this by listing the ``Runtime`` component as a dependency
  700. of the ``Development`` component in the package metadata, ensuring that the
  701. library is always installed if the headers and CMake export file are present.
  702. .. versionadded:: 3.7
  703. In addition to cmake language files, the ``EXPORT_ANDROID_MK`` mode may be
  704. used to specify an export to the android ndk build system. This mode
  705. accepts the same options as the normal export mode. The Android
  706. NDK supports the use of prebuilt libraries, both static and shared. This
  707. allows cmake to build the libraries of a project and make them available
  708. to an ndk build system complete with transitive dependencies, include flags
  709. and defines required to use the libraries.
  710. ``CXX_MODULES_DIRECTORY``
  711. .. note ::
  712. Experimental. Gated by ``CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API``
  713. Specify a subdirectory to store C++ module information for targets in the
  714. export set. This directory will be populated with files which add the
  715. necessary target property information to the relevant targets. Note that
  716. without this information, none of the C++ modules which are part of the
  717. targets in the export set will support being imported in consuming targets.
  718. The ``EXPORT`` form is useful to help outside projects use targets built
  719. and installed by the current project. For example, the code
  720. .. code-block:: cmake
  721. install(TARGETS myexe EXPORT myproj DESTINATION bin)
  722. install(EXPORT myproj NAMESPACE mp_ DESTINATION lib/myproj)
  723. install(EXPORT_ANDROID_MK myproj DESTINATION share/ndk-modules)
  724. will install the executable ``myexe`` to ``<prefix>/bin`` and code to import
  725. it in the file ``<prefix>/lib/myproj/myproj.cmake`` and
  726. ``<prefix>/share/ndk-modules/Android.mk``. An outside project
  727. may load this file with the include command and reference the ``myexe``
  728. executable from the installation tree using the imported target name
  729. ``mp_myexe`` as if the target were built in its own tree.
  730. .. note::
  731. This command supersedes the :command:`install_targets` command and
  732. the :prop_tgt:`PRE_INSTALL_SCRIPT` and :prop_tgt:`POST_INSTALL_SCRIPT`
  733. target properties. It also replaces the ``FILES`` forms of the
  734. :command:`install_files` and :command:`install_programs` commands.
  735. The processing order of these install rules relative to
  736. those generated by :command:`install_targets`,
  737. :command:`install_files`, and :command:`install_programs` commands
  738. is not defined.
  739. Installing Runtime Dependencies
  740. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  741. .. _`install(RUNTIME_DEPENDENCY_SET)`:
  742. .. _RUNTIME_DEPENDENCY_SET:
  743. .. versionadded:: 3.21
  744. .. code-block:: cmake
  745. install(RUNTIME_DEPENDENCY_SET <set-name>
  746. [[LIBRARY|RUNTIME|FRAMEWORK]
  747. [DESTINATION <dir>]
  748. [PERMISSIONS permissions...]
  749. [CONFIGURATIONS [Debug|Release|...]]
  750. [COMPONENT <component>]
  751. [NAMELINK_COMPONENT <component>]
  752. [OPTIONAL] [EXCLUDE_FROM_ALL]
  753. ] [...]
  754. [PRE_INCLUDE_REGEXES regexes...]
  755. [PRE_EXCLUDE_REGEXES regexes...]
  756. [POST_INCLUDE_REGEXES regexes...]
  757. [POST_EXCLUDE_REGEXES regexes...]
  758. [POST_INCLUDE_FILES files...]
  759. [POST_EXCLUDE_FILES files...]
  760. [DIRECTORIES directories...]
  761. )
  762. Installs a runtime dependency set previously created by one or more
  763. `install(TARGETS)`_ or `install(IMPORTED_RUNTIME_ARTIFACTS)`_ commands. The
  764. dependencies of targets belonging to a runtime dependency set are installed in
  765. the ``RUNTIME`` destination and component on DLL platforms, and in the
  766. ``LIBRARY`` destination and component on non-DLL platforms. macOS frameworks
  767. are installed in the ``FRAMEWORK`` destination and component.
  768. Targets built within the build tree will never be installed as runtime
  769. dependencies, nor will their own dependencies, unless the targets themselves
  770. are installed with `install(TARGETS)`_.
  771. The generated install script calls :command:`file(GET_RUNTIME_DEPENDENCIES)`
  772. on the build-tree files to calculate the runtime dependencies. The build-tree
  773. executable files are passed as the ``EXECUTABLES`` argument, the build-tree
  774. shared libraries as the ``LIBRARIES`` argument, and the build-tree modules as
  775. the ``MODULES`` argument. On macOS, if one of the executables is a
  776. :prop_tgt:`MACOSX_BUNDLE`, that executable is passed as the
  777. ``BUNDLE_EXECUTABLE`` argument. At most one such bundle executable may be in
  778. the runtime dependency set on macOS. The :prop_tgt:`MACOSX_BUNDLE` property
  779. has no effect on other platforms. Note that
  780. :command:`file(GET_RUNTIME_DEPENDENCIES)` only supports collecting the runtime
  781. dependencies for Windows, Linux and macOS platforms, so
  782. ``install(RUNTIME_DEPENDENCY_SET)`` has the same limitation.
  783. The following sub-arguments are forwarded through as the corresponding
  784. arguments to :command:`file(GET_RUNTIME_DEPENDENCIES)` (for those that provide
  785. a non-empty list of directories, regular expressions or files). They all
  786. support :manual:`generator expressions <cmake-generator-expressions(7)>`.
  787. * ``DIRECTORIES <directories>``
  788. * ``PRE_INCLUDE_REGEXES <regexes>``
  789. * ``PRE_EXCLUDE_REGEXES <regexes>``
  790. * ``POST_INCLUDE_REGEXES <regexes>``
  791. * ``POST_EXCLUDE_REGEXES <regexes>``
  792. * ``POST_INCLUDE_FILES <files>``
  793. * ``POST_EXCLUDE_FILES <files>``
  794. Generated Installation Script
  795. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  796. .. note::
  797. Use of this feature is not recommended. Please consider using the
  798. :option:`cmake --install` instead.
  799. The ``install()`` command generates a file, ``cmake_install.cmake``, inside
  800. the build directory, which is used internally by the generated install target
  801. and by CPack. You can also invoke this script manually with
  802. :option:`cmake -P`. This script accepts several variables:
  803. ``COMPONENT``
  804. Set this variable to install only a single CPack component as opposed to all
  805. of them. For example, if you only want to install the ``Development``
  806. component, run ``cmake -DCOMPONENT=Development -P cmake_install.cmake``.
  807. ``BUILD_TYPE``
  808. Set this variable to change the build type if you are using a multi-config
  809. generator. For example, to install with the ``Debug`` configuration, run
  810. ``cmake -DBUILD_TYPE=Debug -P cmake_install.cmake``.
  811. ``DESTDIR``
  812. This is an environment variable rather than a CMake variable. It allows you
  813. to change the installation prefix on UNIX systems. See :envvar:`DESTDIR` for
  814. details.