Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where can I find the list of boost component that I can use in cmake?

Tags:

c++

boost

I have a cmake file that adds boost like this:

if(ADD_BOOST)
#add boost library
  set(Boost_USE_STATIC_LIBS ON)
    set(Boost_USE_STATIC_RUNTIME ON)
  file(TO_CMAKE_PATH $ENV{BOOST_ROOT} BOOST_ROOT)
  if (MSVC)
    set(BOOST_LIBRARYDIR ${BOOST_ROOT}/lib64-msvc-12.0)
  else (MSVC)
    set(BOOST_LIBRARY_DIR $ENV{BOOST_ROOT})
  endif (MSVC)
  find_package(Boost COMPONENTS filesystem system program-options thread REQUIRED)
endif (ADD_BOOST)

I have this line:

 find_package(Boost COMPONENTS filesystem system program-options thread REQUIRED)

I want to use program-option libabray from boost. what name should I add to the above list?

where can I find the list of boost library that I can use in above mentioned line in cmake?

like image 890
mans Avatar asked May 01 '15 15:05

mans


People also ask

How do you get a Boost with CMake?

You can use find_package to search for available boost libraries. It defers searching for Boost to FindBoost. cmake, which is default installed with CMake. Upon finding Boost, the find_package() call will have filled many variables (check the reference for FindBoost.

Where is Boost include directory?

The path to the boost root directory (often C:\Program Files\boost\boost_1_40_0) is sometimes referred to as $BOOST_ROOT in documentation and mailing lists . To compile anything in Boost, you need a directory containing the boost\ subdirectory in your #include path.

Which version of Boost do I have?

You can check version. hpp inside Boost include dir (normally /usr/include/boost , you can use locate /boost/version. hpp or similar to get that) for BOOST_VERSION or BOOST_LIB_VERSION .

How many libraries Boost?

Boost is a set of libraries for the C++ programming language that provides support for tasks and structures such as linear algebra, pseudorandom number generation, multithreading, image processing, regular expressions, and unit testing. It contains 164 individual libraries (as of version 1.76).

What does the boost CMake module do?

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "Boost CMake" build. For the latter case skip to the Boost CMake section below. New in version 3.7: bzip2 and zlib components (Windows only).

Is there a way to set up a component in CMake?

There’s another interesting talk called ‘Oh No! More Modern CMake’ that recommends this but unfortunately doesn’t show exactly how to set it up. In the example I linked in my first email I do now have things working and have locally experimented with the adding the COMPONENT keyword and using cmake --install build --component <component>.

What is new in CMake version 3 18?

New in version 3.18. Set to the platform-specific library name prefix (e.g. lib) used by Boost static libs. This is needed only on platforms where CMake does not know the prefix by default. New in version 3.13. Set to the architecture-specific library suffix (e.g. -x64 ).

Where can I find the boost component names?

Or check the sub-directories in include/boost or include/boost_1_68/boost directory, respectively, under your $BOOST_ROOT folder. In fact the sub-directory names can be used as component names for the find_package (Boost COMPONENTS...) command.


1 Answers

Create a dummy CMakeLists.txt:

cmake_minimum_required(VERSION 3.0)
project(dummy)

set(Boost_DEBUG ON)
find_package(Boost COMPONENTS ALL)

Then check the output of cmake .:

[...]
-- BoostConfig: discovered components: atomic;chrono;container;context;coroutine;date_time;exception;fiber;filesystem;graph;graph_parallel;headers;iostreams;locale;log;log_setup;math_c99;math_c99f;math_c99l;math_tr1;math_tr1f;math_tr1l;mpi;mpi_python;nowide;numpy;prg_exec_monitor;program_options;python;random;regex;serialization;stacktrace_addr2line;stacktrace_backtrace;stacktrace_basic;stacktrace_noop;system;test_exec_monitor;thread;timer;type_erasure;unit_test_framework;wave;wserialization
[...]
-- BoostConfig: Boost_ALL_TARGETS: Boost::headers;Boost::atomic;Boost::chrono;Boost::container;Boost::context;Boost::coroutine;Boost::date_time;Boost::exception;Boost::fiber;Boost::filesystem;Boost::graph;Boost::graph_parallel;Boost::iostreams;Boost::locale;Boost::log;Boost::log_setup;Boost::math_c99;Boost::math_c99f;Boost::math_c99l;Boost::math_tr1;Boost::math_tr1f;Boost::math_tr1l;Boost::mpi;Boost::mpi_python;Boost::nowide;Boost::numpy;Boost::prg_exec_monitor;Boost::program_options;Boost::python;Boost::random;Boost::regex;Boost::serialization;Boost::stacktrace_addr2line;Boost::stacktrace_backtrace;Boost::stacktrace_basic;Boost::stacktrace_noop;Boost::system;Boost::test_exec_monitor;Boost::thread;Boost::timer;Boost::type_erasure;Boost::unit_test_framework;Boost::wave;Boost::wserialization
[...]

Note that this can list components only if they are installed on your system. I got the above output after installing libboost 1.74 development files on Debian 11 (e.g. apt install libboost-all-dev=1.74.0.3).

Here is a prettified version of above output for future reference:

-- BoostConfig: discovered components:
atomic
chrono
container
context
coroutine
date_time
exception
fiber
filesystem
graph
graph_parallel
headers
iostreams
locale
log
log_setup
math_c99
math_c99f
math_c99l
math_tr1
math_tr1f
math_tr1l
mpi
mpi_python
nowide
numpy
prg_exec_monitor
program_options
python
random
regex
serialization
stacktrace_addr2line
stacktrace_backtrace
stacktrace_basic
stacktrace_noop
system
test_exec_monitor
thread
timer
type_erasure
unit_test_framework
wave
wserialization
-- BoostConfig: Boost_ALL_TARGETS:
Boost::headers
Boost::atomic
Boost::chrono
Boost::container
Boost::context
Boost::coroutine
Boost::date_time
Boost::exception
Boost::fiber
Boost::filesystem
Boost::graph
Boost::graph_parallel
Boost::iostreams
Boost::locale
Boost::log
Boost::log_setup
Boost::math_c99
Boost::math_c99f
Boost::math_c99l
Boost::math_tr1
Boost::math_tr1f
Boost::math_tr1l
Boost::mpi
Boost::mpi_python
Boost::nowide
Boost::numpy
Boost::prg_exec_monitor
Boost::program_options
Boost::python
Boost::random
Boost::regex
Boost::serialization
Boost::stacktrace_addr2line
Boost::stacktrace_backtrace
Boost::stacktrace_basic
Boost::stacktrace_noop
Boost::system
Boost::test_exec_monitor
Boost::thread
Boost::timer
Boost::type_erasure
Boost::unit_test_framework
Boost::wave
Boost::wserialization
like image 63
ofo Avatar answered Oct 23 '22 07:10

ofo