Pietro
Pietro

Reputation: 13172

Cannot specify BOOST_ROOT for cmake

I have multiple versions of Boost installed (Windows 7/MinGW). I need to use a particular one (1.53.0).

I defined BOOST_ROOT in the CMakeFiles.txt file: SET(BOOST_ROOT C:/boost_1_53_0/), but I keep getting this error:

> cmake .
BOOST_ROOT=C:/boost_1_53_0/
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:1191 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.48.0

  Boost include path: C:/Boost/include/boost-1_48

  Detected version of Boost is too old.  Requested version was 1.53 (or
  newer).

  The following Boost libraries could not be found:

          boost_filesystem

  No Boost libraries were found.  You may need to set BOOST_LIBRARYDIR to the
  directory containing Boost libraries or BOOST_ROOT to the location of
  Boost.

I also defined BOOST_ROOT as an environment variable, but with the same result.

Why is cmake still looking for the old version?

Upvotes: 11

Views: 49213

Answers (3)

Magog
Magog

Reputation: 505

Try this:

cmake -DBOOST_ROOT=path

Upvotes: 24

Liosan
Liosan

Reputation: 7940

If you are using a precompiled version of Boost libraries for Visual Studio, they come in a specific flavor of MSVC version and bitness. I needed to point CMake to that specific location - in my case, setting BOOST_ROOT to C:/local/boost_1_59_0 and BOOST_LIBRARYDIR to C:/local/boost_1_59_0/lib64-msvc-11.0 helped.

Upvotes: 6

phobon
phobon

Reputation: 121

I also struggled with this same problem for a while. If this is the same issue that I had, then the problem is you aren't running the CMake configuration completely fresh without any cache. Once it runs once and finds the default installation (C:\Boost or /usr/include) it will continue to find that one regardless of the value of BOOST_ROOT. So make sure to completely delete any generated build files. Then set BOOST_ROOT to your desired separate installation and it should work fine.

This is also mentioned by jaor on the previously linked question: How can I get cmake to find my alternative boost installation?

Upvotes: 12

Related Questions