Is there a CMake '--install' switch?

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.


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.

Tags:

Cmake