CrustyPeanut
CrustyPeanut

Reputation: 69

Cmake won't find correct version of Boost

I am trying to build some code using cmake. The code uses some Boost libraries. Because of that I try to find Boost in the cmakefile:

find_package(Boost 1.65.1 REQUIRED COMPONENTS unit_test_framework program_options )

I have installed boost version 1.58 via apt (I am using Linux Mint 18.3), so I obviously get the error message when trying to cmake the code:

CMake Error at /usr/share/cmake-3.5/Modules/FindBoost.cmake:1677 (message):
Unable to find the requested Boost libraries.

Boost version: 1.58.0

Boost include path: /usr/include

Detected version of Boost is too old.  Requested version was 1.65.1 (or newer).
Call Stack (most recent call first):
CMakeLists.txt:14 (find_package)

-- Configuring incomplete, errors occurred!

So I went on and downloaded Boost 1.65.1 by source and built it the intended way and installed it with the prefix

sudo ./b2 install --prefix=/usr/include

When I try to build the code again, it still gives the exact same error message as before, stating that it didn't find the newer version. I have tried to uninstall version 1.58 and build, but then cmake doesn't find Boost at all.

How can I install Boost in a way, that cmake is able to find it?

Thanks in advance, cheers!

Upvotes: 0

Views: 2774

Answers (1)

vre
vre

Reputation: 6734

When changing the version information of Boost in a find_package(Boost) call you need to clear the CMakeCache.txt file. Otherwise the cached information from the previous run is used.

Upvotes: 1

Related Questions