[CMake] Boost system library

Geir Erikstad geirr at baldr.no
Fri Mar 13 08:13:17 EDT 2009


09/3/13 Philip Lowman <philip at yhbt.com>:
> On Thu, Mar 12, 2009 at 7:39 PM, Bart Janssens <bart.janssens at lid.kviv.be>
> wrote:
>>
>> Not sure if this ever came up, but I'm struggling with FindBoost and
>> the boost system library. The system library is required from boost
>> 1.35 onwards, but doesn't exist in earlier versions. Is there a way to
>> make CMake only look for the system library if the boost version is
>> greater than or equal to 1.35? I'm using CMake 2.6.1.
>
> I've never seen this come up before but you do have a good point about the
> System library refactoring causing some people a bit of heartache here.
>
> I've logged a bug report for it here.  I'm pretty sure the best fix would be
> to get FindBoost to ignore the system component when it's detected a version
> less than 1.35.  I've attached a new FindBoost.cmake to the bug report which
> does this, if you could give it a shot?
>
> http://public.kitware.com/Bug/view.php?id=8734
>
>
> P.S.
>
> A crappier workaround might be to do something like this.  This probably
> will fail initially and the user could toggle the option and I think it
> would start working on the second configure... kinda sucky though.
>
> OPTION(I_AM_USING_OLDER_BOOST "Set to true if using Boost 1.35" OFF)
> IF(I_AM_USING_OLDER_BOOST)
>    find_package(Boost 1.30 REQUIRED filesystem)
> ELSE()
>    find_package(Boost 1.35 REQUIRED filesystem system)
> ENDIF()
>
> There might be other ways of faking out FindBoost as well by poking around
> with advanced cache variables it relies upon.
>
> --
> Philip Lowman
>

As an alternative to the "crappier workaround" you could run find_package twice,
first to get the version number, and then to get the modules you want:

find_package(Boost)
set(local_boost_version "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}")
if (${local_boost_version} VERSION_LESS "1.35")
    find_package(Boost COMPONENTS filesystem)
else()
    find_package(Boost COMPONENTS system filesystem)
endif()

---
-geirr


More information about the CMake mailing list