简体   繁体   中英

Set minimum version of boost in 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?

基于 ,似乎FIND_PACKAGE忽略SET(BOOST_MIN_VERSION "1.47.0")而不是你可以使用FIND_PACKAGE(Boost 1.47.0 REQUIRED)或稍微更好的FIND_PACKAGE(Boost ${BOOST_MIN_VERSION} REQUIRED)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM