More Modern CMake: Glossary

Key Points

Introduction
  • Build systems describe exactly how to build targets.

  • Build system generators describe general relationships.

  • Modern CMake is simpler and reduces the chance of build problems.

Building with CMake
  • Build a project.

  • Use out-of-source builds.

  • Build options and customization.

  • Debug a CMakeLists easily.

Your first CMakeLists.txt file
  • The cmake_minimum_version setting has deep implications

  • You need a project line.

  • You should prepare one or more targets to do anything interesting.

Working with Targets
  • Libraries and executables are targets.

  • Targets have lots of useful properties.

  • Targets can be linked to other target.

  • You can control what parts of a target get inherited when linking.

  • You can make INTERFACE targets instead of making variables.

Variables explained
  • Local variables work in this directory or below.

  • Cached variables are stored between runs.

  • You can access environment variables, properties, and more.

  • You can glob to collect files from disk, but it might not always be a good idea.

Project Structure
  • Projects should be well organised.

  • Subproject CMakeLists are used for tests and more.

Common Problems and Solutions
  • Setting a CMake version too low.

  • Avoid building inplace.

  • How to select a compiler.

  • How to work with spaces in paths.

Debugging
  • There are several methods for debugging your CMake code.

  • CMake can help you debug and profile your source code.

Finding Packages
  • A FindPackage.cmake file can factor out package discovery for a package you don’t own.

  • A PackageConfig.cmake helps others find your package.

ROOT
  • ROOT has a CONFIG package you can use to integrate with CMake.

Functions in CMake
  • Functions and macros allow factorization.

  • CMake has an argument parsing function to help with making functions.

Glossary

BSG
Build system generator

Other material