[CMake] find_package

Chuck Atkins chuck.atkins at kitware.com
Fri Apr 24 14:44:06 EDT 2015


Hi Matt,

1) (... set boost_root ...)
> 2) FIND_PACKAGE(Boost 1.57 COMPONENTS log thread filesystem system)
>

If you're using CMake >= 3.0, then there's a Boost_NAMESPACE variable you
can set that will cause the find module look for mangled library names line
myboostnamespace_datetime instead of boost_datetime.  You can generate a
source tree with an alternate namespace using the boost bcp tool.  I know
that doesn't seem to be your issue at the moment but it could help in
making sure your system boost doesn't get found.



> 3) (... build boost if it Boost_FOUND is 0)
>

Unrelated to your issue, but in general, when testing boolean variables in
CMake, it's best to treat them as a true/false value instead of integers or
strings.  So instead of "if(Boost_FOUND EQUAL 0)", use "if(NOT
Boost_FOUND)".  The reasoning is that there are many different ways to
create true/false boolean values in cmake. For example, a false boolean
value can be represented as NO, 0, FALSE, OFF, "", etc. By just letting the
variable act as a boolean, it streamlines the code needing to deal with it.



> 4) FIND_PACKAGE(Boost 1.57 REQUIRED COMPONENTS log thread filesystem
> system)
>

>From what I can tell, it doesn't look like you set an updated BOOST_ROOT to
the install prefix of the newly built boost, i.e. ${APT_BOOST_BIN}.
Without that, it's just going to look in the same places as before.

Also try setting Boost_DEBUG=ON before the find package calls.  This will
output some additional debugging information for the find module regarding
what and where it's actually searching for.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150424/f896d97c/attachment.html>


More information about the CMake mailing list