[CMake] FindBoost.cmake from 2.6

Fernando Cacciola fernando.cacciola at gmail.com
Thu Jul 3 18:33:06 EDT 2008


Hi Doug,

> Hi Fernando,
>
>  [snip]
>
>
>> (4)
>> The two loops over _boost_TEST_VERSIONS are nearly indentical, and it's a
>> bit complicated, so I would put that in a macro to make it more readable,
>> discriminating the search path just around the call to find_path (where 
>> it
>> matters)
>
> With CMake 2.6.1, the HINTS feature of find_path allows us to collapse
> these two loops into a single loop.
>
OK, then.

>
>> So, on what platforms does this additional version search stuff work? I
>> certainly doesn't on my windows machine (yes, I tested it).
>
> It's meant for *nix platforms, where Boost.Build installs headers into
> versioned directories.
>
Ha OK.

>
>> (8)
>>
>> The "check minimum version" stuff is not working for me because the
>> Boost_VERSION_* variables are undefined by the time they are compared to 
>> the
>> Boost_FIND_VERSION_* requirement.
>>
>> Does it work for you there?
>
> This has been working for me for a while...
>
OK, I found the problem today.
The version is parsed (from version.hpp) into a variable named 
Booist_MAJOR_VERSION (et al)
But the comparison code incorrectly uses Boost_VERSION_MAJOR.
(Haven't tryed the latest patch though, just the "official" 2.6)

>> (9)
>> It is documented that this requires CMake 2.5 (which is 2.6 for us end
>> users). And later overdocumented that this ships with CMake 2.6 so the
>> version is always right.
>>
>> Well, strictly speaking one can use *this* module with earlier cmake
>> versions, such as 2.4.7 which is still largely used in many linuxes, by
>> emulating the additional find_package feautres.
>> That is, instead of calling it like:
>>
>> find_package(Boost 1.37.1 COMPONENTS thread )
>>
>> call it like this:
>>
>> set( Boost_FIND_VERSION 1.37.1 )
>> set( Boost_FIND_VERSION_MAJOR 1 )
>> set( Boost_FIND_VERSION_MINOR 37 )
>> set( Boost_FIND_VERSION_PATCH 1 )
>> set( Boost_FIND_COMPONENTS thread )
>>
>> find_package(Boost)
>>
>> which works just the same with the old find_package (this is in fact what
>> I'm doing in CGAL to avoid requiring users to install CMake 2.6 which is
>> usually not just a simple apt-get/rmp call in many linuxes)
>
> I'm not quite sure what to do about this... with the FindBoost we ship
> in CMake 2.6.1, we should take advantage of CMake's features (e.g.,
> the new HINTS feature, which eliminates a bunch of redundant code).
> Should we maintain a separate version of FindBoost for older versions
> of CMake? I don't know, but I'm concerned about the maintenance burden
> there, particularly for a complicated module like this one.
>
> Anyway, I'm working on a bunch of issues with FindBoost, and will ping
> the list when I think I have it right.
>
No, sorry, I was clear enough because my example code was wrong though. I 
meant that this:

I tried *this* version of FindBoost with 2.4.7 and 2.4.8 and it just works 
:) with one exception: the version number in the find_package command is 
ignored prior to 2.6.
But, that exception doesn't matter in practice becasue you can redundantly 
store the minimum required version manually in vairables of the form 
Boost_FIND_VERSION etc, like this:

set( Boost_FIND_VERSION 1.33.1 )
set( Boost_FIND_VERSION_MAJOR 1 )
set( Boost_FIND_VERSION_MINOR 33 )
set( Boost_FIND_VERSION_PATCH 1 )

 find_package(Boost 1.33.1 REQUIRED thread whatever )

that code works in 2.4.7, 2.4.8 and 2.6 as far as I tested it. And in all 
cases with the same FindBoost.cmake (the one we are discussing)

Best


-- 
Fernando Cacciola
SciSoft
http://scisoft-consulting.com
http://fcacciola.50webs.com
http://groups.google.com/group/cppba





More information about the CMake mailing list