Cannot specify BOOST_ROOT for cmake
Solution 1
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.
Solution 2
Try this:
cmake -DBOOST_ROOT=path
Solution 3
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?
Pietro
C++ software developer. Particularly interested in software for technical/scientific applications, also in a research and development environment, following the full lifecycle of projects where possible. Interested in Standard C++, Boost, GPGPU, OpenCL, (spiking/convolutional/biological) neural networks, genetic algorithms, databases, ... and a few more things.
Updated on July 09, 2022Comments
-
Pietro almost 2 years
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?