Boost logo

Boost Interest :

Subject: Re: [Boost-cmake] Configuration for sonames for the boost dynamic libraries on Unix
From: Brad King (brad.king_at_[hidden])
Date: 2009-10-28 17:16:11

Michael Jackson wrote:
> This is THE SINGLE IMPROVEMENT someone could make for those of us using
> CMake and are dependent on the boost libraries. Finding Boost with CMake
> is historically a pain and is extremely error prone. There is no support
> for future versions in the current FindBoost. You can take a guess, but
> that is about all it is.
> If I had the time (which I don't.. ) I would add a "UseBoost.cmake"
> file that gets configured and installed with Boost. inside that file
> would be all the usual cmake variables that get set when FindBoost.cmake
> is run:
> Boost_VERSION.. and on and on.
> FindBoost.cmake boils down to looking for that file FIRST, then
> defaulting to the usual search that it currently does. Just my own "wish
> list"..

I'll elaborate.
(FYI, I'm the author of CMake's find_package() command.)

Currently CMake's FindBoost module must detect headers, libraries, and
other individual parts of the Boost installation separately. This is
tedious and error-prone because a user might have to set each result,
and the locations chosen might not correspond to the same
installation. It is better to provide a single file with the
installation that knows where everything was put (relative to its own

What Michael proposes is to install CMake Package Configuration files
with Boost. This is a pair of files like:


which will help a user project that writes code like

  find_package(Boost 1.41 REQUIRED)

find a suitable Boost version. BoostConfig.cmake describes the
installation with which it is provided.

  # Compute _PREFIX relative to file location (contained in Boost_DIR).
  get_filename_component(_PREFIX "${Boost_DIR}/../../.." ABSOLUTE) # ../../.. goes up to prefix

  # Details of corresponding installation...
  set(Boost_VERSION 1.41.0)
  set(Boost_INCLUDE_DIRS ${_PREFIX}/include/boost-1.41.0)
  set(Boost_LIBRARY_DIRS ${_PREFIX}/lib/boost-1.41.0)
  # ...

BoostConfigVersion.cmake decides whether its version of Boost is a
compatible or exact match for the version requested. It might contain
something like:

  set(PACKAGE_VERSION "1.41.0")

This tells the find_package command to accept any 1.41.x as compatible
with a request for 1.41.y, but only 1.41.y as an EXACT match. CMake
prescribes no version numbering is fully determined by
package-provided files.

See also

Note that all of the above is possible even for a non-CMake boost
build. Once a version of Boost is known to provide this file, we can
teach CMake's FindBoost.cmake module to take advantage of it...which
should be the last time we need to change the module.


Boost-cmake list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at