CLion 2018.2 Help

Using CMake Install

If your workflow includes project installation, you may want to use the CMake install command that generates installation rules. There are multiple signatures for this command, for example, the TARGETS form:

install(TARGETS targets... [EXPORT export-name] [[ARCHIVE|LIBRARY|RUNTIME|OBJECTS|FRAMEWORK|BUNDLE|PRIVATE_HEADER|PUBLIC_HEADER|RESOURCE] [DESTINATION dir] [PERMISSIONS permissions...] [CONFIGURATIONS [Debug|Release|...]] [COMPONENT component] [OPTIONAL] [EXCLUDE_FROM_ALL] [NAMELINK_ONLY|NAMELINK_SKIP] ] [...] [INCLUDES DESTINATION [dir ...]])

In CLion, the Install action (Run | Install on the main menu) runs cmake install on your project:

Configuring installation

  1. Place the install commands into your CMakeLists.txt files.

  2. Set up the installation paths via the [DESTINATION dir] field of the install command. Here you have two options:
    • Provide the full path with a leading slash or drive letter.

    • Use a relative path, which will be interpreted as relative to the value of the CMAKE_INSTALL_PREFIX variable, if provided in the CMake options section of the Settings/Preferences | Build, Execution, Deployment dialog:

      cl CmakeInstall Prefix

  3. To run the installation only, call the Install action from the main menu.
    If you want the installation to automatically precede the launch, open the Run | Edit Configurations dialog, choose the desired Run/Debug configuration, press plus green in the Before launch section, and choose Install from the drop-down list:

    cl CmakeInstall BeforeLaunch
    Then call the Run/Debug action for this configuration.

As a result, the targets you specified in the install commands are built and put into the desired directories.

Last modified: 27 November 2018