How it works

This recipe shows how the superbuild pattern can be harnessed to muster the dependencies of your project. Let us take another look at the layout of the project:

.├── CMakeLists.txt├── external│   └── upstream│       ├── boost│       │   └── CMakeLists.txt│       └── CMakeLists.txt└── src    ├── CMakeLists.txt    └── path-info.cpp

We have introduced four CMakeLists.txt files in the project source tree:

  1. The root CMakeLists.txt will coordinate the superbuild.
  2. The file in external/upstream will lead us to the boost leaf directory.
  3. external/upstream/boost/CMakeLists.txt will take care of the Boost dependency.
  4. Finally, the CMakeLists.txt under src will build our example code, which depends on Boost.

Let us start start the discussion with the external/upstream/boost/CMakeLists.txt ...

Get CMake Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.