Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set minimum version of boost in cmake

Tags:

c++

boost

cmake

I want to define a minimum boost version to be available on the system. I tried the following approach. Unfortunately this did not work, as it tries to compile also with only boost 1.40.0 available on the system.

SET(Boost_USE_STATIC_LIBS OFF)
SET(Boost_USE_MULTITHREAD OFF)
SET(BOOST_MIN_VERSION "1.47.0")

FIND_PACKAGE(Boost REQUIRED)

FIND_PACKAGE(Boost REQUIRED)
if (NOT Boost_FOUND)
      message(FATAL_ERROR "Fatal error: Boost (version >= 1.47.0) required.\n")
endif (NOT Boost_FOUND)

INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})

How did I get cmake to control the correct boost version, before compiling?

like image 993
tune2fs Avatar asked Oct 21 '11 20:10

tune2fs


1 Answers

Based on this it seems that FIND_PACKAGE ignores SET(BOOST_MIN_VERSION "1.47.0") instead you could use FIND_PACKAGE(Boost 1.47.0 REQUIRED) or slightly nicer FIND_PACKAGE(Boost ${BOOST_MIN_VERSION} REQUIRED)

like image 95
Johannes Kommer Avatar answered Oct 05 '22 09:10

Johannes Kommer