Search⌘ K
AI Features

Installing Projects on the System

Explore the process of installing C++ projects on your system using CMake commands. Understand how to use the install() function to copy built artifacts, manage installation paths, set permissions, and create reusable packages. Gain knowledge to simplify project distribution and ensure platform-specific consistency.

CMake offers following command-line mode that installs built projects on the system:

cmake --install <dir> [<options>]

<dir> is the path to the generated build tree (required). Our <options> are as follows:

  • --config <cfg>: This picks the build configuration for a multi-configuration generator.

  • --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).

  • --prefix <prefix>: This specifies the non-default installation path (stored in the CMAKE_INSTALL_PREFIX variable). It defaults to /usr/local for Unix-like systems and c:/Program Files/${PROJECT_NAME} for Windows. ...