TIL - Debug FindBoost in CMake

TIL, Today I Learned, is more of a "I just figured this out: here are my notes, you may find them useful too" rather than a full blog post

When you use find_package for a Boost component in CMake it will end up with the FindBoost.cmake [1] module. It is usually located in /usr/share/cmake/Modules/FindBoost.cmake.

I had to debug a cross compile setup for an application using CMake, and the root file system did use wierd paths for everything.

There are a few variables you could set (all of those are mention in the FindBoost.cmake file) to make your debugging easier.

The first one is Boost_DEBUG, it is described as follows

  Set to ``ON`` to enable debug output from ``FindBoost``.
  Please enable this before filing any bug report.

It will give you verbose information during the build process and print all the search paths it goes through.

Once you find out what is not right with your setup, you can hand over some hints where the CMake buildsystem should search

  Preferred installation prefix.

  Preferred include directory e.g. ``<prefix>/include``.

  Preferred library directory e.g. ``<prefix>/lib``.

  Set to ``ON`` to disable searching in locations not
  specified by these hint variables. Default is ``OFF``.

  List of Boost versions not known to this module.
  (Boost install locations may contain the version).