How to change where CMakeLists.txt looks for Boost Libraries Ubuntu

后端 未结 1 1376
心在旅途
心在旅途 2021-01-22 12:52

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 CLio

1条回答
  •  闹比i
    闹比i (楼主)
    2021-01-22 13:35

    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.

    0 讨论(0)
提交回复
热议问题