FindBoost
: Try to find Boost include dirs and librariesUsage of this module as follows:
== 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)
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
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 "0.99" "0.99.0" "1.78" "1.78.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.
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_COMPILER Set this to the compiler suffix used by Boost
(e.g. "-gcc43") if FindBoost has problems finding
the proper Boost installation
These last three variables are available also as environment variables:
BOOST_ROOT or BOOSTROOT The preferred installation prefix for searching for
Boost. Set this if the module has problems finding
the proper Boost installation.
BOOST_INCLUDEDIR Set this to the include directory of Boost, if the
module has problems finding the proper Boost installation
BOOST_LIBRARYDIR Set this to the lib directory of Boost, if the
module has problems finding the proper Boost installation
Variables defined by this module:
Boost_FOUND System has Boost, this means the include dir was
found, as well as all the libraries specified in
the COMPONENTS list.
Boost_INCLUDE_DIRS Boost include directories: not cached
Boost_INCLUDE_DIR This is almost the same as above, but this one is
cached and may be modified by advanced users
Boost_LIBRARIES Link to these to use the Boost libraries that you
specified: not cached
Boost_LIBRARY_DIRS The path to where the Boost library files are.
Boost_VERSION The version number of the boost libraries that
have been found, same as in version.hpp from Boost
Boost_LIB_VERSION The version number in filename form as
it's appended to the library filenames
Boost_MAJOR_VERSION major version number of boost
Boost_MINOR_VERSION minor version number of boost
Boost_SUBMINOR_VERSION subminor version number of boost
Boost_LIB_DIAGNOSTIC_DEFINITIONS [WIN32 Only] You can call
add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINTIIONS})
to have diagnostic information about Boost's
automatic linking outputted during compilation time.
For each component you specify in find_package(), the following (UPPER-CASE) variables are set. You can use these variables if you would like to pick and choose components for your targets instead of just using Boost_LIBRARIES.
Boost_${COMPONENT}_FOUND True IF the Boost library "component" was found.
Boost_${COMPONENT}_LIBRARY Contains the libraries for the specified Boost
"component" (includes debug and optimized keywords
when needed).
=====================================================================
Copyright (c) 2006-2008 Andreas Schneider <mail@cynapses.org>
Copyright (c) 2007 Wengo
Copyright (c) 2007 Mike Jackson
Copyright (c) 2008 Andreas Pakulat <apaku@gmx.de>
Redistribution AND use is allowed according to the terms of the New
BSD license.
For details see the accompanying COPYING-CMAKE-SCRIPTS file.