The Music in Noise

"If there were one million families praying the Rosary every day, the entire world would be saved."
✝ Pope Saint Pius X

The CMake ExternalProject Module - 2021-08-28

Recently I've started working on a C++ project that uses the CMake build system.[1] The first thing I was in charge of doing was fixing the build, as one of the dependencies is the SeetaFace2 project.[2] Originally you had to have the SeetaFace2 project in a directory adjacent to the SeetaRest project directory, and you would manually compile SeetaFace2. This, for obvious reasons, is not a good build setup. So my task was to integrate it directly into the build using CMake's ExternalProject module.[3]

Generally, for those of us used to the way things work on Linux, generally speaking you want to work solely with the dependencies you can install from your distribution's repositories. The problem with this is, save for certain very popular libraries/tools, there are some inconsistencies as to what packages may be available in different distributions, what versions they have available, or even if it's compiled with the flags you need for your project. It's still ideal to link to something from the repositories, but it's not always possible.

This is where ExternalProject comes in. This allows for dependencies to be downloaded and compiled with specific options that best suite the project. It's also done in a rather simple manner. Just by looking at the SeetaFace2.cmake module for the project, it's fairly easy for anyone with a basic knowledge of CMake syntax to see how this project is built and setup.[4] And since you're having to build an entire other project, it's also helpful that you have the option of choosing which targets to build (instead of the entire project).

  1. "Seeta Rest" on GitGud
  2. "SeetaFace2" on GitHub
  3. ExternalProject CMake documentation
  4. SeetaFace2.cmake file from Seeta Rest on GitGud.

Last updated: