Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a CMake '--install' switch?

Tags:

cmake

People also ask

What CMake install does?

CMake provides the install command to specify how a project is to be installed. This command is invoked by a project in the CMakeLists file and tells CMake how to generate installation scripts. The scripts are executed at install time to perform the actual installation of files.

Does CMake need to be installed?

Running the CMake GUI The cmake-gui is included in the CMake source code, but you will need an installation of Qt on your system in order to build it. On Windows, the executable is named cmake-gui.exe and it should be in your Start menu under Program Files.

Where should CMake be installed?

The installation directory is usually left at its default, which is /usr/local . Installing software here ensures that it is automatically available to users. It is possible to specify a different installation directory by adding -DCMAKE_INSTALL_PREFIX=/path/to/install/dir to the CMake command line.


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.