Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

For CMake's "install" command, what can the COMPONENT argument do?

Tags:

cmake

I don't know what the argument COMPONENT of the install() command means, and I don't understand the CMake documentation for this. What is it in more detail?

What would an example be?

like image 806
Samuel Avatar asked Feb 08 '12 08:02

Samuel


People also ask

What does CMake install command do?

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.

Where is CMake 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.

What is Cmake_install CMake file?

cmake contains the commands generated by install command from your CMakeLists. txt . You can execute it by cmake -P cmake_install. cmake and it performs the installation of your project even on windows.


1 Answers

You can group installation targets into components, for example, "docs", "libs", "runtime", etc.

add_library(libone libone.c) add_executable(one main1.c) install(TARGETS libone one DESTINATION /somedir COMPONENT comp_one)  add_library(libtwo libtwo.c) add_executable(two main2.c) install(TARGETS libtwo two DESTINATION /somedir COMPONENT comp_two) 

This makes it possible to run cmake -DCOMPONENT=comp_one -P {your_build_dir}/cmake_install.cmake to install only the libone library and the one executable. When you issue make install all components are installed.

like image 126
arrowd Avatar answered Oct 08 '22 17:10

arrowd