|
|
@ -1,6 +1,10 @@
|
|
|
|
install
|
|
|
|
install
|
|
|
|
-------
|
|
|
|
-------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. only:: html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. contents::
|
|
|
|
|
|
|
|
|
|
|
|
Specify rules to run at install time.
|
|
|
|
Specify rules to run at install time.
|
|
|
|
|
|
|
|
|
|
|
|
Synopsis
|
|
|
|
Synopsis
|
|
|
@ -34,12 +38,14 @@ are executed in order during installation.
|
|
|
|
The environment variable :envvar:`CMAKE_INSTALL_MODE` can override the
|
|
|
|
The environment variable :envvar:`CMAKE_INSTALL_MODE` can override the
|
|
|
|
default copying behavior of ``install()``.
|
|
|
|
default copying behavior of ``install()``.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. _`common options`:
|
|
|
|
|
|
|
|
|
|
|
|
There are multiple signatures for this command. Some of them define
|
|
|
|
There are multiple signatures for this command. Some of them define
|
|
|
|
installation options for files and targets. Options common to
|
|
|
|
installation options for files and targets. Options common to
|
|
|
|
multiple signatures are covered here but they are valid only for
|
|
|
|
multiple signatures are covered here but they are valid only for
|
|
|
|
signatures that specify them. The common options are:
|
|
|
|
signatures that specify them. The common options are:
|
|
|
|
|
|
|
|
|
|
|
|
``DESTINATION``
|
|
|
|
``DESTINATION <dir>``
|
|
|
|
Specify the directory on disk to which a file will be installed.
|
|
|
|
Specify the directory on disk to which a file will be installed.
|
|
|
|
Arguments can be relative or absolute paths.
|
|
|
|
Arguments can be relative or absolute paths.
|
|
|
|
|
|
|
|
|
|
|
@ -58,32 +64,28 @@ signatures that specify them. The common options are:
|
|
|
|
:variable:`CMAKE_INSTALL_PREFIX`; this prefix is used by default if
|
|
|
|
:variable:`CMAKE_INSTALL_PREFIX`; this prefix is used by default if
|
|
|
|
the DESTINATION is a relative path.
|
|
|
|
the DESTINATION is a relative path.
|
|
|
|
|
|
|
|
|
|
|
|
``PERMISSIONS``
|
|
|
|
``PERMISSIONS <permission>...``
|
|
|
|
Specify permissions for installed files. Valid permissions are
|
|
|
|
Specify permissions for installed files. Valid permissions are
|
|
|
|
``OWNER_READ``, ``OWNER_WRITE``, ``OWNER_EXECUTE``, ``GROUP_READ``,
|
|
|
|
``OWNER_READ``, ``OWNER_WRITE``, ``OWNER_EXECUTE``, ``GROUP_READ``,
|
|
|
|
``GROUP_WRITE``, ``GROUP_EXECUTE``, ``WORLD_READ``, ``WORLD_WRITE``,
|
|
|
|
``GROUP_WRITE``, ``GROUP_EXECUTE``, ``WORLD_READ``, ``WORLD_WRITE``,
|
|
|
|
``WORLD_EXECUTE``, ``SETUID``, and ``SETGID``. Permissions that do
|
|
|
|
``WORLD_EXECUTE``, ``SETUID``, and ``SETGID``. Permissions that do
|
|
|
|
not make sense on certain platforms are ignored on those platforms.
|
|
|
|
not make sense on certain platforms are ignored on those platforms.
|
|
|
|
|
|
|
|
|
|
|
|
``CONFIGURATIONS``
|
|
|
|
If this option is used multiple times in a single call, its list
|
|
|
|
Specify a list of build configurations for which the install rule
|
|
|
|
of permissions accumulates. If an :command:`install(TARGETS)` call
|
|
|
|
applies (Debug, Release, etc.). Note that the values specified for
|
|
|
|
uses `\<artifact-kind\>`_ arguments, a separate list of permissions
|
|
|
|
this option only apply to options listed AFTER the ``CONFIGURATIONS``
|
|
|
|
is accumulated for each kind of artifact.
|
|
|
|
option. For example, to set separate install paths for the Debug and
|
|
|
|
|
|
|
|
Release configurations, do the following:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: cmake
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
install(TARGETS target
|
|
|
|
``CONFIGURATIONS <config>...``
|
|
|
|
CONFIGURATIONS Debug
|
|
|
|
Specify a list of build configurations for which the install rule
|
|
|
|
RUNTIME DESTINATION Debug/bin)
|
|
|
|
applies (Debug, Release, etc.).
|
|
|
|
install(TARGETS target
|
|
|
|
|
|
|
|
CONFIGURATIONS Release
|
|
|
|
|
|
|
|
RUNTIME DESTINATION Release/bin)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Note that ``CONFIGURATIONS`` appears BEFORE ``RUNTIME DESTINATION``.
|
|
|
|
If this option is used multiple times in a single call, its list
|
|
|
|
|
|
|
|
of configurations accumulates. If an :command:`install(TARGETS)`
|
|
|
|
|
|
|
|
call uses `\<artifact-kind\>`_ arguments, a separate list of
|
|
|
|
|
|
|
|
configurations is accumulated for each kind of artifact.
|
|
|
|
|
|
|
|
|
|
|
|
``COMPONENT``
|
|
|
|
``COMPONENT <component>``
|
|
|
|
Specify an installation component name with which the install rule
|
|
|
|
Specify an installation component name with which the install rule
|
|
|
|
is associated, such as ``Runtime`` or ``Development``. During
|
|
|
|
is associated, such as ``Runtime`` or ``Development``. During
|
|
|
|
component-specific installation only install rules associated with
|
|
|
|
component-specific installation only install rules associated with
|
|
|
@ -99,7 +101,7 @@ signatures that specify them. The common options are:
|
|
|
|
Specify that the file is excluded from a full installation and only
|
|
|
|
Specify that the file is excluded from a full installation and only
|
|
|
|
installed as part of a component-specific installation
|
|
|
|
installed as part of a component-specific installation
|
|
|
|
|
|
|
|
|
|
|
|
``RENAME``
|
|
|
|
``RENAME <name>``
|
|
|
|
Specify a name for an installed file that may be different from the
|
|
|
|
Specify a name for an installed file that may be different from the
|
|
|
|
original file. Renaming is allowed only when a single file is
|
|
|
|
original file. Renaming is allowed only when a single file is
|
|
|
|
installed by the command.
|
|
|
|
installed by the command.
|
|
|
@ -121,32 +123,43 @@ signatures that specify them. The common options are:
|
|
|
|
they will be created according to the uname rules on Unix-like platforms.
|
|
|
|
they will be created according to the uname rules on Unix-like platforms.
|
|
|
|
Windows platforms are unaffected.
|
|
|
|
Windows platforms are unaffected.
|
|
|
|
|
|
|
|
|
|
|
|
Installing Targets
|
|
|
|
Signatures
|
|
|
|
^^^^^^^^^^^^^^^^^^
|
|
|
|
^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. signature::
|
|
|
|
|
|
|
|
install(TARGETS <target>... [...])
|
|
|
|
|
|
|
|
|
|
|
|
.. _`install(TARGETS)`:
|
|
|
|
Install target :ref:`Output Artifacts` and associated files:
|
|
|
|
.. _TARGETS:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: cmake
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
install(TARGETS <target>... [EXPORT <export-name>]
|
|
|
|
|
|
|
|
[RUNTIME_DEPENDENCIES <arg>...|RUNTIME_DEPENDENCY_SET <set-name>]
|
|
|
|
|
|
|
|
[<artifact-option>...]
|
|
|
|
|
|
|
|
[<artifact-kind> <artifact-option>...]...
|
|
|
|
|
|
|
|
[INCLUDES DESTINATION [<dir> ...]]
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
where ``<artifact-option>...`` group may contain:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: cmake
|
|
|
|
.. code-block:: cmake
|
|
|
|
|
|
|
|
|
|
|
|
install(TARGETS targets... [EXPORT <export-name>]
|
|
|
|
|
|
|
|
[RUNTIME_DEPENDENCIES args...|RUNTIME_DEPENDENCY_SET <set-name>]
|
|
|
|
|
|
|
|
[[ARCHIVE|LIBRARY|RUNTIME|OBJECTS|FRAMEWORK|BUNDLE|
|
|
|
|
|
|
|
|
PRIVATE_HEADER|PUBLIC_HEADER|RESOURCE|FILE_SET <set-name>|CXX_MODULES_BMI]
|
|
|
|
|
|
|
|
[DESTINATION <dir>]
|
|
|
|
[DESTINATION <dir>]
|
|
|
|
[PERMISSIONS permissions...]
|
|
|
|
[PERMISSIONS <permission>...]
|
|
|
|
[CONFIGURATIONS [Debug|Release|...]]
|
|
|
|
[CONFIGURATIONS <config>...]
|
|
|
|
[COMPONENT <component>]
|
|
|
|
[COMPONENT <component>]
|
|
|
|
[NAMELINK_COMPONENT <component>]
|
|
|
|
[NAMELINK_COMPONENT <component>]
|
|
|
|
[OPTIONAL] [EXCLUDE_FROM_ALL]
|
|
|
|
[OPTIONAL] [EXCLUDE_FROM_ALL]
|
|
|
|
[NAMELINK_ONLY|NAMELINK_SKIP]
|
|
|
|
[NAMELINK_ONLY|NAMELINK_SKIP]
|
|
|
|
] [...]
|
|
|
|
|
|
|
|
[INCLUDES DESTINATION [<dir> ...]]
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The ``TARGETS`` form specifies rules for installing targets from a
|
|
|
|
The first ``<artifact-option>...`` group applies to target
|
|
|
|
project. There are several kinds of target :ref:`Output Artifacts`
|
|
|
|
:ref:`Output Artifacts` that do not have a dedicated group specified
|
|
|
|
that may be installed:
|
|
|
|
later in the same call.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. _`<artifact-kind>`:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Each ``<artifact-kind> <artifact-option>...`` group applies to
|
|
|
|
|
|
|
|
:ref:`Output Artifacts` of the specified artifact kind:
|
|
|
|
|
|
|
|
|
|
|
|
``ARCHIVE``
|
|
|
|
``ARCHIVE``
|
|
|
|
Target artifacts of this kind include:
|
|
|
|
Target artifacts of this kind include:
|
|
|
@ -207,22 +220,19 @@ that may be installed:
|
|
|
|
Similar to ``PUBLIC_HEADER`` and ``PRIVATE_HEADER``, but for
|
|
|
|
Similar to ``PUBLIC_HEADER`` and ``PRIVATE_HEADER``, but for
|
|
|
|
``RESOURCE`` files. See :prop_tgt:`RESOURCE` for details.
|
|
|
|
``RESOURCE`` files. See :prop_tgt:`RESOURCE` for details.
|
|
|
|
|
|
|
|
|
|
|
|
``FILE_SET <set>``
|
|
|
|
``FILE_SET <set-name>``
|
|
|
|
.. versionadded:: 3.23
|
|
|
|
.. versionadded:: 3.23
|
|
|
|
|
|
|
|
|
|
|
|
File sets are defined by the :command:`target_sources(FILE_SET)` command.
|
|
|
|
File sets are defined by the :command:`target_sources(FILE_SET)` command.
|
|
|
|
If the file set ``<set>`` exists and is ``PUBLIC`` or ``INTERFACE``, any
|
|
|
|
If the file set ``<set-name>`` exists and is ``PUBLIC`` or ``INTERFACE``,
|
|
|
|
files in the set are installed under the destination (see below).
|
|
|
|
any files in the set are installed under the destination (see below).
|
|
|
|
The directory structure relative to the file set's base directories is
|
|
|
|
The directory structure relative to the file set's base directories is
|
|
|
|
preserved. For example, a file added to the file set as
|
|
|
|
preserved. For example, a file added to the file set as
|
|
|
|
``/blah/include/myproj/here.h`` with a base directory ``/blah/include``
|
|
|
|
``/blah/include/myproj/here.h`` with a base directory ``/blah/include``
|
|
|
|
would be installed to ``myproj/here.h`` below the destination.
|
|
|
|
would be installed to ``myproj/here.h`` below the destination.
|
|
|
|
|
|
|
|
|
|
|
|
``CXX_MODULES_BMI``
|
|
|
|
``CXX_MODULES_BMI``
|
|
|
|
|
|
|
|
.. versionadded:: 3.28
|
|
|
|
.. note ::
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Experimental. Gated by ``CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API``
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Any module files from C++ modules from ``PUBLIC`` sources in a file set of
|
|
|
|
Any module files from C++ modules from ``PUBLIC`` sources in a file set of
|
|
|
|
type ``CXX_MODULES`` will be installed to the given ``DESTINATION``. All
|
|
|
|
type ``CXX_MODULES`` will be installed to the given ``DESTINATION``. All
|
|
|
@ -230,10 +240,6 @@ that may be installed:
|
|
|
|
derived from the names of the modules. An empty ``DESTINATION`` may be used
|
|
|
|
derived from the names of the modules. An empty ``DESTINATION`` may be used
|
|
|
|
to suppress installing these files (for use in generic code).
|
|
|
|
to suppress installing these files (for use in generic code).
|
|
|
|
|
|
|
|
|
|
|
|
For each of these arguments given, the arguments following them only apply
|
|
|
|
|
|
|
|
to the target or file type specified in the argument. If none is given, the
|
|
|
|
|
|
|
|
installation properties apply to all target types.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For regular executables, static libraries and shared libraries, the
|
|
|
|
For regular executables, static libraries and shared libraries, the
|
|
|
|
``DESTINATION`` argument is not required. For these target types, when
|
|
|
|
``DESTINATION`` argument is not required. For these target types, when
|
|
|
|
``DESTINATION`` is omitted, a default destination will be taken from the
|
|
|
|
``DESTINATION`` is omitted, a default destination will be taken from the
|
|
|
@ -292,7 +298,7 @@ subdirectory without using file sets:
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/myproj
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/myproj
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
In addition to the common options listed above, each target can accept
|
|
|
|
In addition to the `common options`_ listed above, each target can accept
|
|
|
|
the following additional arguments:
|
|
|
|
the following additional arguments:
|
|
|
|
|
|
|
|
|
|
|
|
``NAMELINK_COMPONENT``
|
|
|
|
``NAMELINK_COMPONENT``
|
|
|
@ -316,24 +322,8 @@ the following additional arguments:
|
|
|
|
the linker import file created, on macOS, for shared libraries with
|
|
|
|
the linker import file created, on macOS, for shared libraries with
|
|
|
|
:prop_tgt:`ENABLE_EXPORTS` enabled.
|
|
|
|
:prop_tgt:`ENABLE_EXPORTS` enabled.
|
|
|
|
|
|
|
|
|
|
|
|
Consider the following example:
|
|
|
|
See the `Example: Install Targets with Per-Artifact Components`_
|
|
|
|
|
|
|
|
for an example using ``NAMELINK_COMPONENT``.
|
|
|
|
.. code-block:: cmake
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
install(TARGETS mylib
|
|
|
|
|
|
|
|
LIBRARY
|
|
|
|
|
|
|
|
COMPONENT Libraries
|
|
|
|
|
|
|
|
NAMELINK_COMPONENT Development
|
|
|
|
|
|
|
|
PUBLIC_HEADER
|
|
|
|
|
|
|
|
COMPONENT Development
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
In this scenario, if you choose to install only the ``Development``
|
|
|
|
|
|
|
|
component, both the headers and namelink will be installed without the
|
|
|
|
|
|
|
|
library. (If you don't also install the ``Libraries`` component, the
|
|
|
|
|
|
|
|
namelink will be a dangling symlink, and projects that link to the library
|
|
|
|
|
|
|
|
will have build errors.) If you install only the ``Libraries`` component,
|
|
|
|
|
|
|
|
only the library will be installed, without the headers and namelink.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This option is typically used for package managers that have separate
|
|
|
|
This option is typically used for package managers that have separate
|
|
|
|
runtime and development packages. For example, on Debian systems, the
|
|
|
|
runtime and development packages. For example, on Debian systems, the
|
|
|
@ -377,13 +367,14 @@ the following additional arguments:
|
|
|
|
is not recommended to use ``NAMELINK_SKIP`` in conjunction with
|
|
|
|
is not recommended to use ``NAMELINK_SKIP`` in conjunction with
|
|
|
|
``NAMELINK_COMPONENT``.
|
|
|
|
``NAMELINK_COMPONENT``.
|
|
|
|
|
|
|
|
|
|
|
|
The `install(TARGETS)`_ command can also accept the following options at the
|
|
|
|
The :command:`install(TARGETS)` command can also accept the following
|
|
|
|
top level:
|
|
|
|
options at the top level:
|
|
|
|
|
|
|
|
|
|
|
|
``EXPORT``
|
|
|
|
``EXPORT``
|
|
|
|
This option associates the installed target files with an export called
|
|
|
|
This option associates the installed target files with an export called
|
|
|
|
``<export-name>``. It must appear before any target options. To actually
|
|
|
|
``<export-name>``. It must appear before any target options.
|
|
|
|
install the export file itself, call `install(EXPORT)`_, documented below.
|
|
|
|
To actually install the export file itself, call
|
|
|
|
|
|
|
|
:command:`install(EXPORT)`, documented below.
|
|
|
|
See documentation of the :prop_tgt:`EXPORT_NAME` target property to change
|
|
|
|
See documentation of the :prop_tgt:`EXPORT_NAME` target property to change
|
|
|
|
the name of the exported target.
|
|
|
|
the name of the exported target.
|
|
|
|
|
|
|
|
|
|
|
@ -395,22 +386,22 @@ top level:
|
|
|
|
``INCLUDES DESTINATION``
|
|
|
|
``INCLUDES DESTINATION``
|
|
|
|
This option specifies a list of directories which will be added to the
|
|
|
|
This option specifies a list of directories which will be added to the
|
|
|
|
:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` target property of the
|
|
|
|
:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` target property of the
|
|
|
|
``<targets>`` when exported by the `install(EXPORT)`_ command. If a
|
|
|
|
``<targets>`` when exported by the :command:`install(EXPORT)` command.
|
|
|
|
relative path is specified, it is treated as relative to the
|
|
|
|
If a relative path is specified, it is treated as relative to the
|
|
|
|
:genex:`$<INSTALL_PREFIX>`.
|
|
|
|
:genex:`$<INSTALL_PREFIX>`.
|
|
|
|
|
|
|
|
|
|
|
|
``RUNTIME_DEPENDENCY_SET``
|
|
|
|
``RUNTIME_DEPENDENCY_SET <set-name>``
|
|
|
|
.. versionadded:: 3.21
|
|
|
|
.. versionadded:: 3.21
|
|
|
|
|
|
|
|
|
|
|
|
This option causes all runtime dependencies of installed executable, shared
|
|
|
|
This option causes all runtime dependencies of installed executable, shared
|
|
|
|
library, and module targets to be added to the specified runtime dependency
|
|
|
|
library, and module targets to be added to the specified runtime dependency
|
|
|
|
set. This set can then be installed with an
|
|
|
|
set. This set can then be installed with an
|
|
|
|
`install(RUNTIME_DEPENDENCY_SET)`_ command.
|
|
|
|
:command:`install(RUNTIME_DEPENDENCY_SET)` command.
|
|
|
|
|
|
|
|
|
|
|
|
This keyword and the ``RUNTIME_DEPENDENCIES`` keyword are mutually
|
|
|
|
This keyword and the ``RUNTIME_DEPENDENCIES`` keyword are mutually
|
|
|
|
exclusive.
|
|
|
|
exclusive.
|
|
|
|
|
|
|
|
|
|
|
|
``RUNTIME_DEPENDENCIES``
|
|
|
|
``RUNTIME_DEPENDENCIES <arg>...``
|
|
|
|
.. versionadded:: 3.21
|
|
|
|
.. versionadded:: 3.21
|
|
|
|
|
|
|
|
|
|
|
|
This option causes all runtime dependencies of installed executable, shared
|
|
|
|
This option causes all runtime dependencies of installed executable, shared
|
|
|
@ -425,11 +416,11 @@ top level:
|
|
|
|
.. code-block:: cmake
|
|
|
|
.. code-block:: cmake
|
|
|
|
|
|
|
|
|
|
|
|
install(TARGETS ... RUNTIME_DEPENDENCY_SET <set-name>)
|
|
|
|
install(TARGETS ... RUNTIME_DEPENDENCY_SET <set-name>)
|
|
|
|
install(RUNTIME_DEPENDENCY_SET <set-name> args...)
|
|
|
|
install(RUNTIME_DEPENDENCY_SET <set-name> <arg>...)
|
|
|
|
|
|
|
|
|
|
|
|
where ``<set-name>`` will be a randomly generated set name.
|
|
|
|
where ``<set-name>`` will be a randomly generated set name.
|
|
|
|
The ``args...`` may include any of the following keywords supported by
|
|
|
|
``<arg>...`` may include any of the following keywords supported by
|
|
|
|
the `install(RUNTIME_DEPENDENCY_SET)`_ command:
|
|
|
|
the :command:`install(RUNTIME_DEPENDENCY_SET)` command:
|
|
|
|
|
|
|
|
|
|
|
|
* ``DIRECTORIES``
|
|
|
|
* ``DIRECTORIES``
|
|
|
|
* ``PRE_INCLUDE_REGEXES``
|
|
|
|
* ``PRE_INCLUDE_REGEXES``
|
|
|
@ -442,26 +433,6 @@ top level:
|
|
|
|
The ``RUNTIME_DEPENDENCIES`` and ``RUNTIME_DEPENDENCY_SET`` keywords are
|
|
|
|
The ``RUNTIME_DEPENDENCIES`` and ``RUNTIME_DEPENDENCY_SET`` keywords are
|
|
|
|
mutually exclusive.
|
|
|
|
mutually exclusive.
|
|
|
|
|
|
|
|
|
|
|
|
One or more groups of properties may be specified in a single call to
|
|
|
|
|
|
|
|
the ``TARGETS`` form of this command. A target may be installed more than
|
|
|
|
|
|
|
|
once to different locations. Consider hypothetical targets ``myExe``,
|
|
|
|
|
|
|
|
``mySharedLib``, and ``myStaticLib``. The code:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: cmake
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
install(TARGETS myExe mySharedLib myStaticLib
|
|
|
|
|
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
|
|
|
|
ARCHIVE DESTINATION lib/static)
|
|
|
|
|
|
|
|
install(TARGETS mySharedLib DESTINATION /some/full/path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
will install ``myExe`` to ``<prefix>/bin`` and ``myStaticLib`` to
|
|
|
|
|
|
|
|
``<prefix>/lib/static``. On non-DLL platforms ``mySharedLib`` will be
|
|
|
|
|
|
|
|
installed to ``<prefix>/lib`` and ``/some/full/path``. On DLL platforms
|
|
|
|
|
|
|
|
the ``mySharedLib`` DLL will be installed to ``<prefix>/bin`` and
|
|
|
|
|
|
|
|
``/some/full/path`` and its import library will be installed to
|
|
|
|
|
|
|
|
``<prefix>/lib/static`` and ``/some/full/path``.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:ref:`Interface Libraries` may be listed among the targets to install.
|
|
|
|
:ref:`Interface Libraries` may be listed among the targets to install.
|
|
|
|
They install no artifacts but will be included in an associated ``EXPORT``.
|
|
|
|
They install no artifacts but will be included in an associated ``EXPORT``.
|
|
|
|
If :ref:`Object Libraries` are listed but given no destination for their
|
|
|
|
If :ref:`Object Libraries` are listed but given no destination for their
|
|
|
@ -478,7 +449,7 @@ set to ``TRUE`` has undefined behavior.
|
|
|
|
:manual:`cmake-generator-expressions(7)` manual for available expressions.
|
|
|
|
:manual:`cmake-generator-expressions(7)` manual for available expressions.
|
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 3.13
|
|
|
|
.. versionadded:: 3.13
|
|
|
|
`install(TARGETS)`_ can install targets that were created in
|
|
|
|
:command:`install(TARGETS)` can install targets that were created in
|
|
|
|
other directories. When using such cross-directory install rules, running
|
|
|
|
other directories. When using such cross-directory install rules, running
|
|
|
|
``make install`` (or similar) from a subdirectory will not guarantee that
|
|
|
|
``make install`` (or similar) from a subdirectory will not guarantee that
|
|
|
|
targets from other directories are up-to-date. You can use
|
|
|
|
targets from other directories are up-to-date. You can use
|
|
|
@ -486,22 +457,21 @@ set to ``TRUE`` has undefined behavior.
|
|
|
|
to ensure that such out-of-directory targets are built before the
|
|
|
|
to ensure that such out-of-directory targets are built before the
|
|
|
|
subdirectory-specific install rules are run.
|
|
|
|
subdirectory-specific install rules are run.
|
|
|
|
|
|
|
|
|
|
|
|
Installing Imported Runtime Artifacts
|
|
|
|
.. signature::
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
install(IMPORTED_RUNTIME_ARTIFACTS <target>... [...])
|
|
|
|
|
|
|
|
|
|
|
|
.. _`install(IMPORTED_RUNTIME_ARTIFACTS)`:
|
|
|
|
|
|
|
|
.. _IMPORTED_RUNTIME_ARTIFACTS:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 3.21
|
|
|
|
.. versionadded:: 3.21
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Install runtime artifacts of imported targets:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: cmake
|
|
|
|
.. code-block:: cmake
|
|
|
|
|
|
|
|
|
|
|
|
install(IMPORTED_RUNTIME_ARTIFACTS targets...
|
|
|
|
install(IMPORTED_RUNTIME_ARTIFACTS <target>...
|
|
|
|
[RUNTIME_DEPENDENCY_SET <set-name>]
|
|
|
|
[RUNTIME_DEPENDENCY_SET <set-name>]
|
|
|
|
[[LIBRARY|RUNTIME|FRAMEWORK|BUNDLE]
|
|
|
|
[[LIBRARY|RUNTIME|FRAMEWORK|BUNDLE]
|
|
|
|
[DESTINATION <dir>]
|
|
|
|
[DESTINATION <dir>]
|
|
|
|
[PERMISSIONS permissions...]
|
|
|
|
[PERMISSIONS <permission>...]
|
|
|
|
[CONFIGURATIONS [Debug|Release|...]]
|
|
|
|
[CONFIGURATIONS <config>...]
|
|
|
|
[COMPONENT <component>]
|
|
|
|
[COMPONENT <component>]
|
|
|
|
[OPTIONAL] [EXCLUDE_FROM_ALL]
|
|
|
|
[OPTIONAL] [EXCLUDE_FROM_ALL]
|
|
|
|
] [...]
|
|
|
|
] [...]
|
|
|
@ -522,15 +492,11 @@ entire directory is installed.
|
|
|
|
The ``RUNTIME_DEPENDENCY_SET`` option causes the runtime artifacts of the
|
|
|
|
The ``RUNTIME_DEPENDENCY_SET`` option causes the runtime artifacts of the
|
|
|
|
imported executable, shared library, and module library ``targets`` to be
|
|
|
|
imported executable, shared library, and module library ``targets`` to be
|
|
|
|
added to the ``<set-name>`` runtime dependency set. This set can then be
|
|
|
|
added to the ``<set-name>`` runtime dependency set. This set can then be
|
|
|
|
installed with an `install(RUNTIME_DEPENDENCY_SET)`_ command.
|
|
|
|
installed with an :command:`install(RUNTIME_DEPENDENCY_SET)` command.
|
|
|
|
|
|
|
|
|
|
|
|
Installing Files
|
|
|
|
|
|
|
|
^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. _`install(FILES)`:
|
|
|
|
.. signature::
|
|
|
|
.. _`install(PROGRAMS)`:
|
|
|
|
install(FILES <file>... [...])
|
|
|
|
.. _FILES:
|
|
|
|
install(PROGRAMS <program>... [...])
|
|
|
|
.. _PROGRAMS:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
|
@ -538,12 +504,14 @@ Installing Files
|
|
|
|
:command:`target_sources(FILE_SET)` instead. File sets associate
|
|
|
|
:command:`target_sources(FILE_SET)` instead. File sets associate
|
|
|
|
headers with a target and they install as part of the target.
|
|
|
|
headers with a target and they install as part of the target.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Install files or programs:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: cmake
|
|
|
|
.. code-block:: cmake
|
|
|
|
|
|
|
|
|
|
|
|
install(<FILES|PROGRAMS> files...
|
|
|
|
install(<FILES|PROGRAMS> <file>...
|
|
|
|
TYPE <type> | DESTINATION <dir>
|
|
|
|
TYPE <type> | DESTINATION <dir>
|
|
|
|
[PERMISSIONS permissions...]
|
|
|
|
[PERMISSIONS <permission>...]
|
|
|
|
[CONFIGURATIONS [Debug|Release|...]]
|
|
|
|
[CONFIGURATIONS <config>...]
|
|
|
|
[COMPONENT <component>]
|
|
|
|
[COMPONENT <component>]
|
|
|
|
[RENAME <name>] [OPTIONAL] [EXCLUDE_FROM_ALL])
|
|
|
|
[RENAME <name>] [OPTIONAL] [EXCLUDE_FROM_ALL])
|
|
|
|
|
|
|
|
|
|
|
@ -628,11 +596,8 @@ subdirectory:
|
|
|
|
use "generator expressions" with the syntax ``$<...>``. See the
|
|
|
|
use "generator expressions" with the syntax ``$<...>``. See the
|
|
|
|
:manual:`cmake-generator-expressions(7)` manual for available expressions.
|
|
|
|
:manual:`cmake-generator-expressions(7)` manual for available expressions.
|
|
|
|
|
|
|
|
|
|
|
|
Installing Directories
|
|
|
|
.. signature::
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
install(DIRECTORY <dir>... [...])
|
|
|
|
|
|
|
|
|
|
|
|
.. _`install(DIRECTORY)`:
|
|
|
|
|
|
|
|
.. _DIRECTORY:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
|
@ -641,18 +606,20 @@ Installing Directories
|
|
|
|
preserve directory structure, they also associate headers with a target
|
|
|
|
preserve directory structure, they also associate headers with a target
|
|
|
|
and install as part of the target.
|
|
|
|
and install as part of the target.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Install the contents of one or more directories:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: cmake
|
|
|
|
.. code-block:: cmake
|
|
|
|
|
|
|
|
|
|
|
|
install(DIRECTORY dirs...
|
|
|
|
install(DIRECTORY dirs...
|
|
|
|
TYPE <type> | DESTINATION <dir>
|
|
|
|
TYPE <type> | DESTINATION <dir>
|
|
|
|
[FILE_PERMISSIONS permissions...]
|
|
|
|
[FILE_PERMISSIONS <permission>...]
|
|
|
|
[DIRECTORY_PERMISSIONS permissions...]
|
|
|
|
[DIRECTORY_PERMISSIONS <permission>...]
|
|
|
|
[USE_SOURCE_PERMISSIONS] [OPTIONAL] [MESSAGE_NEVER]
|
|
|
|
[USE_SOURCE_PERMISSIONS] [OPTIONAL] [MESSAGE_NEVER]
|
|
|
|
[CONFIGURATIONS [Debug|Release|...]]
|
|
|
|
[CONFIGURATIONS <config>...]
|
|
|
|
[COMPONENT <component>] [EXCLUDE_FROM_ALL]
|
|
|
|
[COMPONENT <component>] [EXCLUDE_FROM_ALL]
|
|
|
|
[FILES_MATCHING]
|
|
|
|
[FILES_MATCHING]
|
|
|
|
[[PATTERN <pattern> | REGEX <regex>]
|
|
|
|
[[PATTERN <pattern> | REGEX <regex>]
|
|
|
|
[EXCLUDE] [PERMISSIONS permissions...]] [...])
|
|
|
|
[EXCLUDE] [PERMISSIONS <permission>...]] [...])
|
|
|
|
|
|
|
|
|
|
|
|
The ``DIRECTORY`` form installs contents of one or more directories to a
|
|
|
|
The ``DIRECTORY`` form installs contents of one or more directories to a
|
|
|
|
given destination. The directory structure is copied verbatim to the
|
|
|
|
given destination. The directory structure is copied verbatim to the
|
|
|
@ -766,13 +733,11 @@ the appropriate cache variables.
|
|
|
|
The list of ``dirs...`` given to ``DIRECTORY`` may use
|
|
|
|
The list of ``dirs...`` given to ``DIRECTORY`` may use
|
|
|
|
"generator expressions" too.
|
|
|
|
"generator expressions" too.
|
|
|
|
|
|
|
|
|
|
|
|
Custom Installation Logic
|
|
|
|
.. signature::
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
install(SCRIPT <file> [...])
|
|
|
|
|
|
|
|
install(CODE <code> [...])
|
|
|
|
|
|
|
|
|
|
|
|
.. _`install(CODE)`:
|
|
|
|
Invoke CMake scripts or code during installation:
|
|
|
|
.. _`install(SCRIPT)`:
|
|
|
|
|
|
|
|
.. _CODE:
|
|
|
|
|
|
|
|
.. _SCRIPT:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: cmake
|
|
|
|
.. code-block:: cmake
|
|
|
|
|
|
|
|
|
|
|
@ -805,18 +770,17 @@ will print a message during installation.
|
|
|
|
name, not the file's contents). See the
|
|
|
|
name, not the file's contents). See the
|
|
|
|
:manual:`cmake-generator-expressions(7)` manual for available expressions.
|
|
|
|
:manual:`cmake-generator-expressions(7)` manual for available expressions.
|
|
|
|
|
|
|
|
|
|
|
|
Installing Exports
|
|
|
|
.. signature::
|
|
|
|
^^^^^^^^^^^^^^^^^^
|
|
|
|
install(EXPORT <export-name> [...])
|
|
|
|
|
|
|
|
|
|
|
|
.. _`install(EXPORT)`:
|
|
|
|
Install a CMake file exporting targets for dependent projects:
|
|
|
|
.. _EXPORT:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: cmake
|
|
|
|
.. code-block:: cmake
|
|
|
|
|
|
|
|
|
|
|
|
install(EXPORT <export-name> DESTINATION <dir>
|
|
|
|
install(EXPORT <export-name> DESTINATION <dir>
|
|
|
|
[NAMESPACE <namespace>] [FILE <name>.cmake]
|
|
|
|
[NAMESPACE <namespace>] [FILE <name>.cmake]
|
|
|
|
[PERMISSIONS permissions...]
|
|
|
|
[PERMISSIONS <permission>...]
|
|
|
|
[CONFIGURATIONS [Debug|Release|...]
|
|
|
|
[CONFIGURATIONS <config>...]
|
|
|
|
[CXX_MODULES_DIRECTORY <directory>]
|
|
|
|
[CXX_MODULES_DIRECTORY <directory>]
|
|
|
|
[EXPORT_LINK_INTERFACE_LIBRARIES]
|
|
|
|
[EXPORT_LINK_INTERFACE_LIBRARIES]
|
|
|
|
[COMPONENT <component>]
|
|
|
|
[COMPONENT <component>]
|
|
|
@ -826,7 +790,7 @@ Installing Exports
|
|
|
|
The ``EXPORT`` form generates and installs a CMake file containing code to
|
|
|
|
The ``EXPORT`` form generates and installs a CMake file containing code to
|
|
|
|
import targets from the installation tree into another project.
|
|
|
|
import targets from the installation tree into another project.
|
|
|
|
Target installations are associated with the export ``<export-name>``
|
|
|
|
Target installations are associated with the export ``<export-name>``
|
|
|
|
using the ``EXPORT`` option of the `install(TARGETS)`_ signature
|
|
|
|
using the ``EXPORT`` option of the :command:`install(TARGETS)` signature
|
|
|
|
documented above. The ``NAMESPACE`` option will prepend ``<namespace>`` to
|
|
|
|
documented above. The ``NAMESPACE`` option will prepend ``<namespace>`` to
|
|
|
|
the target names as they are written to the import file. By default
|
|
|
|
the target names as they are written to the import file. By default
|
|
|
|
the generated file will be called ``<export-name>.cmake`` but the ``FILE``
|
|
|
|
the generated file will be called ``<export-name>.cmake`` but the ``FILE``
|
|
|
@ -876,10 +840,7 @@ library is always installed if the headers and CMake export file are present.
|
|
|
|
and defines required to use the libraries.
|
|
|
|
and defines required to use the libraries.
|
|
|
|
|
|
|
|
|
|
|
|
``CXX_MODULES_DIRECTORY``
|
|
|
|
``CXX_MODULES_DIRECTORY``
|
|
|
|
|
|
|
|
.. versionadded:: 3.28
|
|
|
|
.. note ::
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Experimental. Gated by ``CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API``
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Specify a subdirectory to store C++ module information for targets in the
|
|
|
|
Specify a subdirectory to store C++ module information for targets in the
|
|
|
|
export set. This directory will be populated with files which add the
|
|
|
|
export set. This directory will be populated with files which add the
|
|
|
@ -913,43 +874,42 @@ executable from the installation tree using the imported target name
|
|
|
|
:command:`install_files`, and :command:`install_programs` commands
|
|
|
|
:command:`install_files`, and :command:`install_programs` commands
|
|
|
|
is not defined.
|
|
|
|
is not defined.
|
|
|
|
|
|
|
|
|
|
|
|
Installing Runtime Dependencies
|
|
|
|
.. signature::
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
install(RUNTIME_DEPENDENCY_SET <set-name> [...])
|
|
|
|
|
|
|
|
|
|
|
|
.. _`install(RUNTIME_DEPENDENCY_SET)`:
|
|
|
|
|
|
|
|
.. _RUNTIME_DEPENDENCY_SET:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 3.21
|
|
|
|
.. versionadded:: 3.21
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Installs a runtime dependency set:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: cmake
|
|
|
|
.. code-block:: cmake
|
|
|
|
|
|
|
|
|
|
|
|
install(RUNTIME_DEPENDENCY_SET <set-name>
|
|
|
|
install(RUNTIME_DEPENDENCY_SET <set-name>
|
|
|
|
[[LIBRARY|RUNTIME|FRAMEWORK]
|
|
|
|
[[LIBRARY|RUNTIME|FRAMEWORK]
|
|
|
|
[DESTINATION <dir>]
|
|
|
|
[DESTINATION <dir>]
|
|
|
|
[PERMISSIONS permissions...]
|
|
|
|
[PERMISSIONS <permission>...]
|
|
|
|
[CONFIGURATIONS [Debug|Release|...]]
|
|
|
|
[CONFIGURATIONS <config>...]
|
|
|
|
[COMPONENT <component>]
|
|
|
|
[COMPONENT <component>]
|
|
|
|
[NAMELINK_COMPONENT <component>]
|
|
|
|
[NAMELINK_COMPONENT <component>]
|
|
|
|
[OPTIONAL] [EXCLUDE_FROM_ALL]
|
|
|
|
[OPTIONAL] [EXCLUDE_FROM_ALL]
|
|
|
|
] [...]
|
|
|
|
] [...]
|
|
|
|
[PRE_INCLUDE_REGEXES regexes...]
|
|
|
|
[PRE_INCLUDE_REGEXES <regex>...]
|
|
|
|
[PRE_EXCLUDE_REGEXES regexes...]
|
|
|
|
[PRE_EXCLUDE_REGEXES <regex>...]
|
|
|
|
[POST_INCLUDE_REGEXES regexes...]
|
|
|
|
[POST_INCLUDE_REGEXES <regex>...]
|
|
|
|
[POST_EXCLUDE_REGEXES regexes...]
|
|
|
|
[POST_EXCLUDE_REGEXES <regex>...]
|
|
|
|
[POST_INCLUDE_FILES files...]
|
|
|
|
[POST_INCLUDE_FILES <file>...]
|
|
|
|
[POST_EXCLUDE_FILES files...]
|
|
|
|
[POST_EXCLUDE_FILES <file>...]
|
|
|
|
[DIRECTORIES directories...]
|
|
|
|
[DIRECTORIES <dir>...]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
Installs a runtime dependency set previously created by one or more
|
|
|
|
Installs a runtime dependency set previously created by one or more
|
|
|
|
`install(TARGETS)`_ or `install(IMPORTED_RUNTIME_ARTIFACTS)`_ commands. The
|
|
|
|
:command:`install(TARGETS)` or :command:`install(IMPORTED_RUNTIME_ARTIFACTS)`
|
|
|
|
dependencies of targets belonging to a runtime dependency set are installed in
|
|
|
|
commands. The dependencies of targets belonging to a runtime dependency set
|
|
|
|
the ``RUNTIME`` destination and component on DLL platforms, and in the
|
|
|
|
are installed in the ``RUNTIME`` destination and component on DLL platforms,
|
|
|
|
``LIBRARY`` destination and component on non-DLL platforms. macOS frameworks
|
|
|
|
and in the ``LIBRARY`` destination and component on non-DLL platforms.
|
|
|
|
are installed in the ``FRAMEWORK`` destination and component.
|
|
|
|
macOS frameworks are installed in the ``FRAMEWORK`` destination and component.
|
|
|
|
Targets built within the build tree will never be installed as runtime
|
|
|
|
Targets built within the build tree will never be installed as runtime
|
|
|
|
dependencies, nor will their own dependencies, unless the targets themselves
|
|
|
|
dependencies, nor will their own dependencies, unless the targets themselves
|
|
|
|
are installed with `install(TARGETS)`_.
|
|
|
|
are installed with :command:`install(TARGETS)`.
|
|
|
|
|
|
|
|
|
|
|
|
The generated install script calls :command:`file(GET_RUNTIME_DEPENDENCIES)`
|
|
|
|
The generated install script calls :command:`file(GET_RUNTIME_DEPENDENCIES)`
|
|
|
|
on the build-tree files to calculate the runtime dependencies. The build-tree
|
|
|
|
on the build-tree files to calculate the runtime dependencies. The build-tree
|
|
|
@ -969,13 +929,105 @@ arguments to :command:`file(GET_RUNTIME_DEPENDENCIES)` (for those that provide
|
|
|
|
a non-empty list of directories, regular expressions or files). They all
|
|
|
|
a non-empty list of directories, regular expressions or files). They all
|
|
|
|
support :manual:`generator expressions <cmake-generator-expressions(7)>`.
|
|
|
|
support :manual:`generator expressions <cmake-generator-expressions(7)>`.
|
|
|
|
|
|
|
|
|
|
|
|
* ``DIRECTORIES <directories>``
|
|
|
|
* ``DIRECTORIES <dir>...``
|
|
|
|
* ``PRE_INCLUDE_REGEXES <regexes>``
|
|
|
|
* ``PRE_INCLUDE_REGEXES <regex>...``
|
|
|
|
* ``PRE_EXCLUDE_REGEXES <regexes>``
|
|
|
|
* ``PRE_EXCLUDE_REGEXES <regex>...``
|
|
|
|
* ``POST_INCLUDE_REGEXES <regexes>``
|
|
|
|
* ``POST_INCLUDE_REGEXES <regex>...``
|
|
|
|
* ``POST_EXCLUDE_REGEXES <regexes>``
|
|
|
|
* ``POST_EXCLUDE_REGEXES <regex>...``
|
|
|
|
* ``POST_INCLUDE_FILES <files>``
|
|
|
|
* ``POST_INCLUDE_FILES <file>...``
|
|
|
|
* ``POST_EXCLUDE_FILES <files>``
|
|
|
|
* ``POST_EXCLUDE_FILES <file>...``
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Examples
|
|
|
|
|
|
|
|
^^^^^^^^
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example: Install Targets with Per-Artifact Components
|
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Consider a project that defines targets with different artifact kinds:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: cmake
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add_executable(myExe myExe.c)
|
|
|
|
|
|
|
|
add_library(myStaticLib STATIC myStaticLib.c)
|
|
|
|
|
|
|
|
target_sources(myStaticLib PUBLIC FILE_SET HEADERS FILES myStaticLib.h)
|
|
|
|
|
|
|
|
add_library(mySharedLib SHARED mySharedLib.c)
|
|
|
|
|
|
|
|
target_sources(mySharedLib PUBLIC FILE_SET HEADERS FILES mySharedLib.h)
|
|
|
|
|
|
|
|
set_property(TARGET mySharedLib PROPERTY SOVERSION 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
We may call :command:`install(TARGETS)` with `\<artifact-kind\>`_ arguments
|
|
|
|
|
|
|
|
to specify different options for each kind of artifact:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: cmake
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
install(TARGETS
|
|
|
|
|
|
|
|
myExe
|
|
|
|
|
|
|
|
mySharedLib
|
|
|
|
|
|
|
|
myStaticLib
|
|
|
|
|
|
|
|
RUNTIME # Following options apply to runtime artifacts.
|
|
|
|
|
|
|
|
COMPONENT Runtime
|
|
|
|
|
|
|
|
LIBRARY # Following options apply to library artifacts.
|
|
|
|
|
|
|
|
COMPONENT Runtime
|
|
|
|
|
|
|
|
NAMELINK_COMPONENT Development
|
|
|
|
|
|
|
|
ARCHIVE # Following options apply to archive artifacts.
|
|
|
|
|
|
|
|
COMPONENT Development
|
|
|
|
|
|
|
|
DESTINATION lib/static
|
|
|
|
|
|
|
|
FILE_SET HEADERS # Following options apply to file set HEADERS.
|
|
|
|
|
|
|
|
COMPONENT Development
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This will:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* Install ``myExe`` to ``<prefix>/bin``, the default RUNTIME artifact
|
|
|
|
|
|
|
|
destination, as part of the ``Runtime`` component.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* On non-DLL platforms:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* Install ``libmySharedLib.so.1`` to ``<prefix>/lib``, the default
|
|
|
|
|
|
|
|
LIBRARY artifact destination, as part of the ``Runtime`` component.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* Install the ``libmySharedLib.so`` "namelink" (symbolic link) to
|
|
|
|
|
|
|
|
``<prefix>/lib``, the default LIBRARY artifact destination, as part
|
|
|
|
|
|
|
|
of the ``Development`` component.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* On DLL platforms:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* Install ``mySharedLib.dll`` to ``<prefix>/bin``, the default RUNTIME
|
|
|
|
|
|
|
|
artifact destination, as part of the ``Runtime`` component.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* Install ``mySharedLib.lib`` to ``<prefix>/lib/static``, the specified
|
|
|
|
|
|
|
|
ARCHIVE artifact destination, as part of the ``Development`` component.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* Install ``myStaticLib`` to ``<prefix>/lib/static``, the specified
|
|
|
|
|
|
|
|
ARCHIVE artifact destination, as part of the ``Development`` component.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* Install ``mySharedLib.h`` and ``myStaticLib.h`` to ``<prefix>/include``,
|
|
|
|
|
|
|
|
the default destination for a file set of type HEADERS, as part of the
|
|
|
|
|
|
|
|
``Development`` component.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example: Install Targets to Per-Config Destinations
|
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Each :command:`install(TARGETS)` call installs a given target
|
|
|
|
|
|
|
|
:ref:`output artifact <Output Artifacts>` to at most one ``DESTINATION``,
|
|
|
|
|
|
|
|
but the install rule itself may be filtered by the ``CONFIGURATIONS`` option.
|
|
|
|
|
|
|
|
In order to install to a different destination for each configuration, one
|
|
|
|
|
|
|
|
call per configuration is needed. For example, the code:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: cmake
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
install(TARGETS myExe
|
|
|
|
|
|
|
|
CONFIGURATIONS Debug
|
|
|
|
|
|
|
|
RUNTIME
|
|
|
|
|
|
|
|
DESTINATION Debug/bin
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
install(TARGETS myExe
|
|
|
|
|
|
|
|
CONFIGURATIONS Release
|
|
|
|
|
|
|
|
RUNTIME
|
|
|
|
|
|
|
|
DESTINATION Release/bin
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
will install ``myExe`` to ``<prefix>/Debug/bin`` in the Debug configuration,
|
|
|
|
|
|
|
|
and to ``<prefix>/Release/bin`` in the Release configuration.
|
|
|
|
|
|
|
|
|
|
|
|
Generated Installation Script
|
|
|
|
Generated Installation Script
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|