The code for this recipe is available at https://github.com/dev-cafe/cmake-cookbook/tree/v1.0/chapter-08/recipe-01 and has a C++ example. The recipe is valid with CMake version 3.5 (and higher) and has been tested on GNU/Linux, macOS, and Windows.
This recipe will introduce the superbuild pattern with a very simple example. We will show how to use the ExternalProject_Add command to build a simple "Hello, World" program.