install.rst 43 KB

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