2
votes

I was using Boost 1.54.0 and it was located in "/usr/include". We blew that away and installed Boost 1.57.0. It got installed in "/usr/local/include".

Now, my CLion project, which uses CMake cannot find the Boost library. Here is my CMakeLists.txt file:

enter image description here

And here are my errors:

enter image description here

I have no idea how to make CMake look in the correct place for Boost.

1
it seems you've forgot to add CMakeLists.txt contents and error description.zaufi
For code (also CMake code), please use copy and paste, select the pasted code and press on the {} buttonAntonio

1 Answers

3
votes

According to the FindBoost documentation (http://www.cmake.org/cmake/help/v3.1/module/FindBoost.html), you can set a CMake variable BOOST_ROOT to give CMake a hint about where to look.

In your CMakeLists.txt file, you can add the following before the find_package(Boost...) line:

set(BOOST_ROOT /usr/local)

Update: I agree with the comments that putting machine specific configuration parameters directly in CMakeLists.txt is not best practice.

As an alternative to directly setting this variable, you can pass options like this to the cmake process in CLion by doing the following:

Navigate to File -> Settings... -> Build, Execution, and Deployment -> CMake. Under Generation, add -DBOOST_ROOT=/usr/local to CMake options.