What is the CMake install time?
Building a CMake project can roughly be divided into three phases:
- Configure time. This includes everything that happens while running
cmake
itself. This phase is concerned with inspecting certain properties of the host system and generating the specific build files for that platform under the selected configuration. - Build time. This includes everything that happens while actually building your project from the files generated by CMake (like, when running
cmake --build
ormake
). This is where all of the actual compilation and linking happens, so at the end of the build phase, you have a usable binary. - Install time. This includes everything that happens when running the
INSTALL
target generated by CMake (like, when runningcmake --build --target install
ormake install
). This takes care of copying the binaries that were generated into the build tree to a different directory. Note that the build tree contains a lot of stuff that is no longer needed once the build is completed if you are only interested in running the binary. Examples include all intermediate build artifacts, like the build files generated during the configure phase or the intermediate object files created during the build phase. Furthermore, the install phase might include additional steps to ensure that the binaries produced during the build are portable. For instance, on Linux systems you might want to remove the build directory from the shared library search path in the binary and replace it with a portable equivalent. So the install phase might do more than just copy all the important files to a new directory. It could also include additional steps that change the binaries to make them more portable.
Note that the last phase is optional. If you do not want to support calling make install
but prefer another deployment mechanism, you simply don't use the install
command in your CMake script and no INSTALL
target will be generated.
I'd like to expand the answer, which ComicSansMS gave you, a little bit.
As he mentioned - CMake generates an extra target called install
for the make
tool (when you use a Makefile-based generator).
It may look weird for you as a package system is used for Linux. However the install
target is still useful or even necessary:
- When you develop your application you may need to install (move binaries and possibly some include files) to a certain location so some of your projects may see each other. For example, you may develop a library and a set of non-related applications which use it. Then this library must be installed somewhere to be visible. It doesn't mean you need to put it to the
/usr
directory; you may use your/home
. - The process of Linux package preparation requires an install step. For example, the RPM packaging system does three main steps when the rpm package file is being built: the project is configured, then is compiled and linked and finally is being installed to a certain location. All files from this location are being packed to the rpm file.