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

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

cmake install boost
cmake boost components
boost cmake
cmake find boost windows
install boost ubuntu
cmake unable to find requested boost libraries
boost interprocess cmake
cmake boost/stacktrace

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?


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 .

FindBoost, Find Boost include dirs and libraries Boost_ADDITIONAL_VERSIONS - List of Boost versions not known to this module (Boost install locations may contain the Boost_NAMESPACE - Alternate namespace used to build boost with e.g. if set​  I had a similar issue, cmake finding vendor installed boost only, but my cluster has a locally installed version which is what I wanted it to use.RHEL 6. Anyway, looks like all the BOOSTROOT, BOOST_ROOT, Boost_DIR stuff would get annoyed unless one also sets Boost_NO_BOOST_CMAKE (e.g add to cmd line -DBoost_NO_BOOST_CMAKE=TRUE).


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

FindBoost, Find Boost include dirs and libraries Boost_ADDITIONAL_VERSIONS - List of Boost versions not known to this module (Boost install locations may contain the Boost_NAMESPACE - Alternate namespace used to build boost with e.g. if set​  j'ai installé la version la plus récente de Boost dans /usr/local (avec des inclusions dans /usr/local/include/boost et des bibliothèques dans /usr/local/lib/boost) et je tente maintenant d'installer Wt à partir de la source, mais CMake (version 2.6) ne semble pas trouver l'installation de Boost.


The short version

You only need BOOST_ROOT, but you're going to want to disable searching the system for your local Boost if you have multiple installations or cross-compiling for iOS or Android. In which case add Boost_NO_SYSTEM_PATHS is set to false.

set( BOOST_ROOT "" CACHE PATH "Boost library path" )
set( Boost_NO_SYSTEM_PATHS on CACHE BOOL "Do not search system for Boost" )

Normally this is passed on the CMake command-line using the syntax -D<VAR>=value.

The longer version

Officially speaking the FindBoost page states these variables should be used to 'hint' the location of Boost.

This module reads hints about search locations from variables:

BOOST_ROOT             - Preferred installation prefix
 (or BOOSTROOT)
BOOST_INCLUDEDIR       - Preferred include directory e.g. <prefix>/include
BOOST_LIBRARYDIR       - Preferred library directory e.g. <prefix>/lib
Boost_NO_SYSTEM_PATHS  - Set to ON to disable searching in locations not
                         specified by these hint variables. Default is OFF.
Boost_ADDITIONAL_VERSIONS
                       - List of Boost versions not known to this module
                         (Boost install locations may contain the version)

This makes a theoretically correct incantation:

cmake -DBoost_NO_SYSTEM_PATHS=TRUE \
      -DBOOST_ROOT=/path/to/boost-dir
When you compile from source
include( ExternalProject )

set( boost_URL "http://sourceforge.net/projects/boost/files/boost/1.63.0/boost_1_63_0.tar.bz2" )
set( boost_SHA1 "9f1dd4fa364a3e3156a77dc17aa562ef06404ff6" )
set( boost_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/third_party/boost )
set( boost_INCLUDE_DIR ${boost_INSTALL}/include )
set( boost_LIB_DIR ${boost_INSTALL}/lib )

ExternalProject_Add( boost
        PREFIX boost
        URL ${boost_URL}
        URL_HASH SHA1=${boost_SHA1}
        BUILD_IN_SOURCE 1
        CONFIGURE_COMMAND
        ./bootstrap.sh
        --with-libraries=filesystem
        --with-libraries=system
        --with-libraries=date_time
        --prefix=<INSTALL_DIR>
        BUILD_COMMAND
        ./b2 install link=static variant=release threading=multi runtime-link=static
        INSTALL_COMMAND ""
        INSTALL_DIR ${boost_INSTALL} )

set( Boost_LIBRARIES
        ${boost_LIB_DIR}/libboost_filesystem.a
        ${boost_LIB_DIR}/libboost_system.a
        ${boost_LIB_DIR}/libboost_date_time.a )
message( STATUS "Boost static libs: " ${Boost_LIBRARIES} )

Then when you call this script you'll need to include the boost.cmake script (mine is in the a subdirectory), include the headers, indicate the dependency, and link the libraries.

include( boost )
include_directories( ${boost_INCLUDE_DIR} )
add_dependencies( MyProject boost )
target_link_libraries( MyProject
                       ${Boost_LIBRARIES} )

How can I get cmake to find my alternative boost installation , I had a similar issue, cmake finding vendor installed boost only, but my cluster has a locally installed version which is what I wanted it to use. If Boost was built using the boost-cmake project it provides a package configuration file for use with find_package’s Config mode. This module looks for the package configuration file called BoostConfig.cmake or boost-config.cmake and stores the result in cache entry “Boost_DIR”. If found, the package configuration file is loaded and this


Generally the most common mistake is not cleaning your build directory after adding new options. I have Boost installed from system packet manager. Its version is 1.49.

I also downloaded Boost 1.53 and "installed" it under $HOME/installs.

The only thing that I had to do in my project was to (I keep sources in my_project_directory/src):

cd my_project_directory
mkdir build
cd build
cmake -DCMAKE_INCLUDE_PATH=$HOME/installs/include -DCMAKE_LIBRARY_PATH=$HOME/installs/lib ../src

And that's it. Ta bum tss.

But if I'd make after cd build -> cmake ../src it would set Boost from the system path. Then doing cmake -DCMAKE_INCLUDE_PATH=$HOME/installs/include -DCMAKE_LIBRARY_PATH=$HOME/installs/lib ../src would change nothing.

You have to clean your build directory ( cd build && rm -rf * ;) )

Install Boost · GitBook, . hpp or similar to get that) for BOOST_VERSION or BOOST_LIB_VERSION . Installing CMake. There are several ways to install CMake, depending on your platform. Windows. There are pre-compiled binaries available on the Download page for Windows as MSI packages and ZIP files. One may alternatively download and build CMake from source. The Download page also provides source releases. In order to build CMake from a


I had a similar issue, CMake finding a vendor-installed Boost only, but my cluster had a locally installed version which is what I wanted it to use. Red Hat Linux 6.

Anyway, it looks like all the BOOSTROOT, BOOST_ROOT, and Boost_DIR stuff would get annoyed unless one also sets Boost_NO_BOOST_CMAKE (e.g add to cmd line -DBoost_NO_BOOST_CMAKE=TRUE).

(I will concede the usefulness of CMake for multiplatform, but I can still hate it.)

apt - How can I find Boost version?, Information: I have two versions of boost installed on my system. If I brew unlink boost then FindBoost.cmake seems to find boost 1.59.0 as I  My intention is to show how “new” (>= 3.0.0) features can be employed to reshape your CMake system into a more maintainable and intuitive alternative that actually makes sense. Many of the concepts presented here find their roots in Daniel Pfeifer’s masterpiece Effective CMake. Daniel has practically become the Messiah of the modern CMake


How does gcc know where boost is installed, txt file and CMakeFiles directory from your build directory. Otherwise, CMake will attempt to use cached options which may not include your new  For example, the Linux-x86_64 tar file is all under the directory cmake–Linux-x86_64. This prefix can be removed as long as the share, bin, man and doc directories are moved relative to each other. To build the source distributions, unpack them with zip or tar and follow the instructions in Readme.txt at the top of the source tree.


CMake sets Boost Include path and Boost Library paths to different , A possible (but a bit more complex to use) alternative is provided with the smaller and more self-contained cd [anaconda folder]/bin $ source activate my-rdkit-​env You need to tell cmake where to find the boost libraries and header files:. I have the latest cmake 3.0.2 compiled from sources, also libboost-all-dev installed. And find_package(Boost) can't find it. Here is output of cmake: Unable to find the requested Boost libraries. Unable to find the Boost header files.


CMake cannot locate boost which is installed in /usr/include/boost , 5.1 Install Visual Studio Binaries; 5.2 Or, Simplified Build From Source; 5.3 Or, Build; 5.3.2 Identify Your Toolset; 5.3.3 Select a Build Directory; 5.3.4 Invoke b2 an experimental CMake build for boost, supported and distributed separately. Install Boost, CMake, and Visual Studio. Rename a folder (boost\lib32-msvc-14.1-> boost\lib) Run a couple commands (that we give you) on the command line for each