TIL - Debug FindBoost in CMake

Posted by Marcus Folkesson on Tuesday, November 29, 2022

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

``Boost_DEBUG``
  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

``BOOST_ROOT``, ``BOOSTROOT``
  Preferred installation prefix.

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

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

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

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