Boost

# Header-only libraries
hunter_add_package(Boost)
find_package(Boost CONFIG REQUIRED)
target_link_libraries(... Boost::boost)
# Boost components (see list below)
hunter_add_package(Boost COMPONENTS system filesystem)
find_package(Boost CONFIG REQUIRED system filesystem)
target_link_libraries(... Boost::system Boost::filesystem)

Examples:

List of components (other libraries are header-only):

  • atomic
  • chrono
  • context
  • coroutine
  • date_time
  • exception
  • filesystem
  • graph
  • graph_parallel
  • iostreams
  • locale
  • log
  • math
  • mpi
  • program_options
  • python
  • random
  • regex
  • serialization
  • signals
  • system
  • test
  • thread
  • timer
  • wave

Compatibility mode

hunter_add_package(Boost COMPONENTS system filesystem)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost REQUIRED system filesystem)
if(MSVC)
  add_definitions(-DBOOST_ALL_NO_LIB=1)
endif()

include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(... ${Boost_LIBRARIES})

CMake options

CMake options can be passed to boost build using CMAKE_ARGS feature (see customization). Options of special form <COMPONENT-UPPERCASE>_<OPTION>=<VALUE> will be added to b2 as -s <OPTION>=<VALUE> while building component . For example:

hunter_config(Boost VERSION ... CMAKE_ARGS IOSTREAMS_NO_BZIP2=1)
# add NO_BZIP2=1 to the b2 build of iostreams library, i.e. `b2 -s NO_BZIP2=1`

Math

When using Boost Math you will need to link in the libraries, however these are not named math but rather are individual based on what you need to link it, the easiest of which is to link in all parts:

hunter_add_package(Boost COMPONENTS math)
find_package(Boost CONFIG REQUIRED math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l)
target_link_libraries(...
  Boost::math_c99
  Boost::math_c99f
  Boost::math_c99l
  Boost::math_tr1
  Boost::math_tr1f
  Boost::math_tr1l
)

If you are using only the header-only parts of Boost::Math then the libraries can be ignored:

hunter_add_package(Boost COMPONENTS math)
find_package(Boost CONFIG REQUIRED)

Bugs