Is there a CMake '--install' switch?

Cmake

Cmake Problem Overview


With reference to this question there is a so-called 'install' phase in CMake. I'm used to run CMake in a sequence that looks like this:

cmake ..
cmake --build . --config Debug
cmake --build . --config Release

Is there a cmake --install command line switch meant to be invoked after this?

Although I figure it is somehow related, I'm not looking for the so called install command here (I perceive this to be a function rather than a command, but this is likely a terminology issue).

Cmake Solutions


Solution 1 - Cmake

No, this switch does not exist (until CMake 3.15, see my other answer).

If a project uses the install command, it generates the target install. You can call it with

cmake --build . --target install

This uses CMake's Build Tool Mode, which is an abstract interface for a couple of commands to the native build tool (e.g. make or Ninja) and can also be used to pass arbitrary arguments to the native build tool.

Solution 2 - Cmake

Beginning with version 3.15, CMake offers an install switch. From the release notes:

> The "cmake(1)" command gained a new "--install" option. This may > be used after building a project to run installation without using > the generated build system or the native build tool.

Source: https://cmake.org/cmake/help/v3.15/release/3.15.html#id6

So you can use

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

The optional --prefix flag lets you override the CMAKE_INSTALL_PREFIX.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser234736View Question on Stackoverflow
Solution 1 - Cmakeusr1234567View Answer on Stackoverflow
Solution 2 - Cmakeusr1234567View Answer on Stackoverflow