4
votes

CMake has a built-in install target, so that you can use make install if you're generating Makefiles, or build an INSTALL project in Visual Studio, etc.

The behavior of this target is defined by various install() commands in your CMake files, e.g. copying files or products of existing CMake targets to specific installation directories.

The install() command also allows you to specify a component. If you then call CMake specifying a component, then the install target will install only products associated with that particular component.

What I haven't found, though, is: What targets does the install target depend on?

  • If one of my targets does not compile, will this cause make install to fail, even if that target doesn't produce anything for installation?
  • If I'm building one specific component, and I've specified it in my original CMake call, will make install build all the targets in my source tree (but only install the one component)? Or will it build only the targets necessary for the installation of the specific component?
2

2 Answers

5
votes

It depends on all.

You can control what's in this using EXCLUDE_FROM_ALL, or remove the dependency by setting CMAKE_SKIP_INSTALL_ALL_DEPENDENCY, but that doesn't replace it with specific targets, it just means make install does the installation without trying to build anything.

Here's the documentation from CMAKE_SKIP_INSTALL_ALL_DEPENDENCY

By default, the install target depends on the all target. This has the effect, that when make install is invoked or INSTALL is built, first the all target is built, then the installation starts. If CMAKE_SKIP_INSTALL_ALL_DEPENDENCY is set to TRUE, this dependency is not created, so the installation process will start immediately, independent from whether the project has been completely built or not.

0
votes

make install unconditionally depends from make all.

That is, for install even single file you need to (successfully) complete make all stage.