Low-Level Installation

Let's learn how we can specify a more complex installation directory structure.

Modern CMake is moving away from the concept of manipulating files directly. Ideally, we'd always add them to a logical target and use that as a higher level of abstraction to represent all the underlying assets: source files, headers, resources, configuration, and so on. The main advantage is the dryness of the code: usually, we won't need to change more than one line to add a file to the target.

Unfortunately, adding every installed file to a target isn't always possible or convenient. For such cases, three choices are available:

  • install(FILES)

  • install(PROGRAMS)

  • install(DIRECTORY)

Installing file sets with install(FILES|PROGRAMS)

The FILES and PROGRAMS modes are very similar. They can be used to install public header files, documentation, shell scripts, configuration, and all kinds of assets, including images, audio files, and datasets to be used at runtime.

Here's the command signature:

Get hands-on with 1200+ tech skills courses.