Installing Logical Targets
Let's learn about installation mode in CMake.
install()
command specifics for TARGETS
mode specifier
Targets defined by add_library()
and add_executable()
can easily be installed with the install(TARGETS)
command. This means copying the artifacts that have been produced by the buildsystem to the appropriate destination directories and setting suitable file permissions for them. The general signature for this mode is as follows:
install(TARGETS <target>... [EXPORT <export-name>][<output-artifact-configuration> ...][INCLUDES DESTINATION [<dir> ...]])
After the initial mode specifier—that is, TARGETS
—we must provide a list of targets we'd like to install. Here, we may optionally assign them to a named export with the EXPORT
option, which can be used in export(EXPORT)
and install(EXPORT)
to produce a target export file. Then, we must configure the installation of output artifacts (grouped by type). Optionally, we can provide a list of directories that will be added to the target export file for each target in its INTERFACE_INCLUDE_DIRECTORIES
property.
[<output-artifact-configuration>...]
provides a list of configuration blocks. The full syntax of a single block is as follows:
<TYPE> [DESTINATION <dir>] [PERMISSIONS permissions...] [CONFIGURATIONS [Debug|Release|...]][COMPONENT <component>] [NAMELINK_COMPONENT <component>][OPTIONAL] [EXCLUDE_FROM_ALL] [NAMELINK_ONLY|NAMELINK_SKIP]
Output artifact
Every output artifact block has to start with <TYPE>
...