How it works

The superbuild is a very useful pattern in our CMake toolbox. It lets us manage complex projects by separating them into smaller, more manageable subprojects. In addition, we can use CMake as a package manager for the project we are building. CMake can search for our dependencies and, in case they are not found on the system, freshly build them for us. The basic pattern requires three CMakeLists.txt files:

  • The root CMakeLists.txt  file contains settings shared by the project and the dependencies. It also includes our own project as an external project. In our case, we chose the name ${PROJECT_NAME}_core; that is, recipe-04_core, since the project name recipe-04 is used for the superbuild.
  • The external CMakeLists.txt file will ...

Get CMake Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.