What does the install keyword do exactly ?

Hi !

I’ve read the install keyword page https://cmake.org/cmake/help/latest/command/install.html but I don’t understand what this keyword actually does.

I know 2 use cases of this keyword from the Step 4 of the Cmake Tutorial : https://cmake.org/cmake/help/latest/guide/tutorial/Installing%20and%20Testing.html

install(TARGETS MathFunctions DESTINATION lib)
install(FILES MathFunctions.h DESTINATION include)


install(TARGETS Tutorial DESTINATION bin)
install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" DESTINATION include)

If I get it right here, the install keyword simply moves a file to a destination when the 1st argument is FILES and it does a bit the same with the TARGETS keyword but a little bit differently…

I wonder if I don’t understand the install keyword because maybe I don’t exactly know what the install word mean in computer science… Installing means moving a file to the install directory right ?

To install software, means to copy it to a system for use, and to configure the system to run the software. So, for example, if you go to the CMake website and download CMake for Windows, you will geta .msi installer that, when you open it, it will install CMake to your system, that is, it will copy CMake to an appropriate location on your system, and make any configuration changes needed to run CMake, such as optionally adding CMake to your %PATH% so you can run cmake from the command line.

The INSTALL command adds an install pseudo-target to your build system that can be used to install the software after it’s built. It was fairly normal on Linux to build and install software like this when CMake was first around, and it’s still possible today. This step can be used by tools like CPack to install to a staging directory and make a package or installer for the software.

Edit: As for what it actually does, you have the right idea. When the install target is invoked, the build system will copy any files specified by install(FILES) and any files generated for any targets specified with install(TARGET) into the install location.