Installing projects on the system
In Chapter 1, First Steps with CMake, we indicated that CMake offers a command-line mode for installing built projects on the system:
cmake --install <dir> [<options>]
Here, <dir>
is the path to the generated build tree (required). The <options>
include:
--config <cfg>
: This selects the build configuration for multi-configuration generators.--component <comp>
: This limits the installation to the given component.--default-directory-permissions <permissions>
: This sets the default permissions for the installed directories (in<u=rwx,g=rx,o=rx>
format).--install-prefix <prefix>
: This specifies the non-default installation path (stored in theCMAKE_INSTALL_PREFIX
variable). It defaults to/usr/local
on Unix-like systems and toc:/Program Files/${PROJECT_NAME}
on Windows. Before CMake 3.21, you’ll have to use a less-explicit option:--prefix <prefix...