FindBoost
: Try to find Boost include dirs and librariesUsage of this module as follows:
NOTE: Take note of the Boost_ADDITIONAL_VERSIONS variable below. Due to Boost naming conventions and limitations in CMake this find module is NOT future safe with respect to Boost version numbers, and may break.
== Using Header-Only libraries from within Boost: ==
find_package( Boost 1.36.0 )
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(foo foo.cc)
endif()
== Using actual libraries from within Boost: ==
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package( Boost 1.36.0 COMPONENTS date_time filesystem system ... )
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(foo foo.cc)
target_link_libraries(foo ${Boost_LIBRARIES})
endif()
The components list needs to contain actual names of boost libraries only, such as "date_time" for "libboost_date_time". If you're using parts of Boost that contain header files only (e.g. foreach) you do not need to specify COMPONENTS.
You should provide a minimum version number that should be used. If you provide this version number and specify the REQUIRED attribute, this module will fail if it can't find the specified or a later version. If you specify a version number this is automatically put into the considered list of version numbers and thus doesn't need to be specified in the Boost_ADDITIONAL_VERSIONS variable (see below).
NOTE for Visual Studio Users:
Automatic linking is used on MSVC & Borland compilers by default when
#including things in Boost. It's important to note that setting
Boost_USE_STATIC_LIBS to OFF is NOT enough to get you dynamic linking,
should you need this feature. Automatic linking typically uses static
libraries with a few exceptions (Boost.Python is one).
Please see the section below near Boost_LIB_DIAGNOSTIC_DEFINITIONS for
more details. Adding a TARGET_LINK_LIBRARIES() as shown in the example
above appears to cause VS to link dynamically if Boost_USE_STATIC_LIBS
gets set to OFF. It is suggested you avoid automatic linking since it
will make your application less portable.
=========== The mess that is Boost_ADDITIONAL_VERSIONS (sorry?) ============
OK, so the Boost_ADDITIONAL_VERSIONS variable can be used to specify a list of boost version numbers that should be taken into account when searching for Boost. Unfortunately boost puts the version number into the actual filename for the libraries, so this variable will certainly be needed in the future when new Boost versions are released.
Currently this module searches for the following version numbers: 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1, 1.36, 1.36.0, 1.36.1, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0, 1.40, 1.40.0, 1.41, 1.41.0, 1.42, 1.42.0, 1.43, 1.43.0, 1.44, 1.44.0, 1.45, 1.45.0, 1.46, 1.46.0, 1.46.1
NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should add both 1.x and 1.x.0 as shown above. Official Boost include directories omit the 3rd version number from include paths if it is 0 although not all binary Boost releases do so.
set(Boost_ADDITIONAL_VERSIONS "1.78" "1.78.0" "1.79" "1.79.0")
===================================== ============= ========================
Variables used by this module, they can change the default behaviour and need to be set before calling find_package:
Boost_USE_MULTITHREADED Can be set to OFF to use the non-multithreaded
boost libraries. If not specified, defaults
to ON.
Boost_USE_STATIC_LIBS Can be set to ON to force the use of the static
boost libraries. Defaults to OFF.
Boost_NO_SYSTEM_PATHS Set to TRUE to suppress searching in system
paths (or other locations outside of BOOST_ROOT
or BOOST_INCLUDEDIR). Useful when specifying
BOOST_ROOT. Defaults to OFF.
[Since CMake 2.8.3]
Boost_NO_BOOST_CMAKE Do not do a find_package call in config mode
before searching for a regular boost install.
This will avoid finding boost-cmake installs.
Defaults to OFF.
[Since CMake 2.8.6]
Boost_USE_STATIC_RUNTIME If enabled, searches for boost libraries
linked against a static C++ standard library
('s' ABI tag). This option should be set to
ON or OFF because the default behavior
if not specified is platform dependent
for backwards compatibility.
[Since CMake 2.8.3]
Boost_USE_DEBUG_PYTHON If enabled, searches for boost libraries
compiled against a special debug build of
Python ('y' ABI tag). Defaults to OFF.
[Since CMake 2.8.3]
Boost_USE_STLPORT If enabled, searches for boost libraries
compiled against the STLPort standard
library ('p' ABI tag). Defaults to OFF.
[Since CMake 2.8.3]
Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS
If enabled, searches for boost libraries
compiled against the deprecated STLPort
"native iostreams" feature ('n' ABI tag).
Defaults to OFF.
[Since CMake 2.8.3]
Other Variables used by this module which you may want to set.
Boost_ADDITIONAL_VERSIONS A list of version numbers to use for searching
the boost include directory. Please see
the documentation above regarding this
annoying, but necessary variable :(
Boost_DEBUG Set this to TRUE to enable debugging output
of FindBoost.cmake if you are having problems.
Please enable this before filing any bug
reports.
Boost_DETAILED_FAILURE_MSG FindBoost doesn't output detailed information
about why it failed or how to fix the problem
unless this is set to TRUE or the REQUIRED
keyword is specified in find_package().
[Since CMake 2.8.0]
Boost_COMPILER Set this to the compiler suffix used by Boost
(e.g. "-gcc43") if FindBoost has problems finding
the proper Boost installation
Boost_THREADAPI When building boost.thread, sometimes the name of the
library contains an additional "pthread" or "win32"
string known as the threadapi. This can happen when
compiling against pthreads on Windows or win32 threads
on Cygwin. You may specify this variable and if set
when FindBoost searches for the Boost threading library
it will first try to match the threadapi you specify.
For Example: libboost_thread_win32-mgw45-mt-1_43.a
might be found if you specified "win32" here before
falling back on libboost_thread-mgw45-mt-1_43.a.
[Since CMake 2.8.3]
Boost_REALPATH Resolves symbolic links for discovered boost libraries
to assist with packaging. For example, instead of
Boost_SYSTEM_LIBRARY_RELEASE being resolved to
"/usr/lib/libboost_system.so" it would be
"/usr/lib/libboost_system.so.1.42.0" instead.
This does not affect linking and should not be
enabled unless the user needs this information.
[Since CMake 2.8.3]