Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get CMake to find my alternative Boost installation?

I have installed the most recent version of Boost in /usr/local (with includes in /usr/local/include/boost and libraries in /usr/local/lib/boost) and I am now attempting to install Wt from source, but CMake (version 2.6) can't seem to find the Boost installation. It tries to give helpful suggestions about setting BOOST_DIR and Boost_LIBRARYDIR, but I haven't been able to get it to work by tweaking these variables.

The most recent error message that I get is that it can't find the libraries, but it seems to indicate that it is using "/usr/local/include" for the include path, which isn't correct (and I can't seem to fix it). Is there a solution for this off the top of their head, or do I need to go mucking around inside CMake to figure it out?

like image 512
BD at Rivenhill Avatar asked Jun 10 '10 16:06

BD at Rivenhill


People also ask

How do you get a Boost with CMake?

You can use find_package to search for available boost libraries. It defers searching for Boost to FindBoost. cmake, which is default installed with CMake. Upon finding Boost, the find_package() call will have filled many variables (check the reference for FindBoost.

Where is Boost include directory?

The path to the boost root directory (often C:\Program Files\boost\boost_1_40_0) is sometimes referred to as $BOOST_ROOT in documentation and mailing lists . To compile anything in Boost, you need a directory containing the boost\ subdirectory in your #include path.


2 Answers

You should have a look at FindBoost.cmake script, which handles Boost detection and setting up all Boost variables. It typically resides in /usr/share/cmake-2.6/Modules/. In it, you will find documentation. For instance:

# These last three variables are available also as environment variables: # #   BOOST_ROOT or BOOSTROOT      The preferred installation prefix for searching for #                                Boost.  Set this if the module has problems finding #                                the proper Boost installation. # 

In contrast to BOOST_ROOT, the variables you are referring to are actually variables that are set by the FindBoost module. Note that you don't have to (and probably also don't want to) edit your CMake project configuration to set BOOST_ROOT. Instead, you should use the environment variable, e.g. calling

# BOOST_ROOT=/usr/local/... ccmake .

like image 79
ypnos Avatar answered Oct 05 '22 22:10

ypnos


I was finally able to get what I wanted with

cmake -DCMAKE_INSTALL_PREFIX=$TARGET \     -DBoost_NO_BOOST_CMAKE=TRUE \     -DBoost_NO_SYSTEM_PATHS=TRUE \     -DBOOST_ROOT:PATHNAME=$TARGET \     -DBoost_LIBRARY_DIRS:FILEPATH=${TARGET}/lib 
like image 23
Damien Kick Avatar answered Oct 06 '22 00:10

Damien Kick