1 # - Try to find Boost include dirs and libraries
2 # Usage of this module as follows:
4 # == Using Header-Only libraries from within Boost: ==
6 # find_package( Boost 1.36.0 )
8 # include_directories(${Boost_INCLUDE_DIRS})
9 # add_executable(foo foo.cc)
13 # == Using actual libraries from within Boost: ==
15 # set(Boost_USE_STATIC_LIBS ON)
16 # set(Boost_USE_MULTITHREADED ON)
17 # find_package( Boost 1.36.0 COMPONENTS date_time filesystem system ... )
20 # include_directories(${Boost_INCLUDE_DIRS})
21 # add_executable(foo foo.cc)
22 # target_link_libraries(foo ${Boost_LIBRARIES})
26 # The components list needs to contain actual names of boost libraries only,
27 # such as "date_time" for "libboost_date_time". If you're using parts of
28 # Boost that contain header files only (e.g. foreach) you do not need to
31 # You should provide a minimum version number that should be used. If you provide this
32 # version number and specify the REQUIRED attribute, this module will fail if it
33 # can't find the specified or a later version. If you specify a version number this is
34 # automatically put into the considered list of version numbers and thus doesn't need
35 # to be specified in the Boost_ADDITIONAL_VERSIONS variable (see below).
37 # NOTE for Visual Studio Users:
38 # Automatic linking is used on MSVC & Borland compilers by default when
39 # #including things in Boost. It's important to note that setting
40 # Boost_USE_STATIC_LIBS to OFF is NOT enough to get you dynamic linking,
41 # should you need this feature. Automatic linking typically uses static
42 # libraries with a few exceptions (Boost.Python is one).
44 # Please see the section below near Boost_LIB_DIAGNOSTIC_DEFINITIONS for
45 # more details. Adding a TARGET_LINK_LIBRARIES() as shown in the example
46 # above appears to cause VS to link dynamically if Boost_USE_STATIC_LIBS
47 # gets set to OFF. It is suggested you avoid automatic linking since it
48 # will make your application less portable.
50 # =========== The mess that is Boost_ADDITIONAL_VERSIONS (sorry?) ============
52 # OK, so the Boost_ADDITIONAL_VERSIONS variable can be used to specify a list of
53 # boost version numbers that should be taken into account when searching
54 # for Boost. Unfortunately boost puts the version number into the
55 # actual filename for the libraries, so this variable will certainly be needed
56 # in the future when new Boost versions are released.
58 # Currently this module searches for the following version numbers:
59 # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1,
60 # 1.36, 1.36.0, 1.36.1, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0,
63 # NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should
64 # add both 1.x and 1.x.0 as shown above. Official Boost include directories
65 # omit the 3rd version number from include paths if it is 0 although not all
66 # binary Boost releases do so.
68 # SET(Boost_ADDITIONAL_VERSIONS "0.99" "0.99.0" "1.78" "1.78.0")
70 # ===================================== ============= ========================
72 # Variables used by this module, they can change the default behaviour and
73 # need to be set before calling find_package:
75 # Boost_USE_MULTITHREADED Can be set to OFF to use the non-multithreaded
76 # boost libraries. If not specified, defaults
79 # Boost_USE_STATIC_LIBS Can be set to ON to force the use of the static
80 # boost libraries. Defaults to OFF.
82 # Other Variables used by this module which you may want to set.
84 # Boost_ADDITIONAL_VERSIONS A list of version numbers to use for searching
85 # the boost include directory. Please see
86 # the documentation above regarding this
87 # annoying, but necessary variable :(
89 # Boost_DEBUG Set this to TRUE to enable debugging output
90 # of FindBoost.cmake if you are having problems.
91 # Please enable this before filing any bug
94 # Boost_COMPILER Set this to the compiler suffix used by Boost
95 # (e.g. "-gcc43") if FindBoost has problems finding
96 # the proper Boost installation
98 # These last three variables are available also as environment variables:
100 # BOOST_ROOT or BOOSTROOT The preferred installation prefix for searching for
101 # Boost. Set this if the module has problems finding
102 # the proper Boost installation.
104 # BOOST_INCLUDEDIR Set this to the include directory of Boost, if the
105 # module has problems finding the proper Boost installation
107 # BOOST_LIBRARYDIR Set this to the lib directory of Boost, if the
108 # module has problems finding the proper Boost installation
110 # Variables defined by this module:
112 # Boost_FOUND System has Boost, this means the include dir was
113 # found, as well as all the libraries specified in
114 # the COMPONENTS list.
116 # Boost_INCLUDE_DIRS Boost include directories: not cached
118 # Boost_INCLUDE_DIR This is almost the same as above, but this one is
119 # cached and may be modified by advanced users
121 # Boost_LIBRARIES Link to these to use the Boost libraries that you
122 # specified: not cached
124 # Boost_LIBRARY_DIRS The path to where the Boost library files are.
126 # Boost_VERSION The version number of the boost libraries that
127 # have been found, same as in version.hpp from Boost
129 # Boost_LIB_VERSION The version number in filename form as
130 # it's appended to the library filenames
132 # Boost_MAJOR_VERSION major version number of boost
133 # Boost_MINOR_VERSION minor version number of boost
134 # Boost_SUBMINOR_VERSION subminor version number of boost
136 # Boost_LIB_DIAGNOSTIC_DEFINITIONS [WIN32 Only] You can call
137 # add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
138 # to have diagnostic information about Boost's
139 # automatic linking outputted during compilation time.
141 # For each component you specify in find_package(), the following (UPPER-CASE)
142 # variables are set. You can use these variables if you would like to pick and
143 # choose components for your targets instead of just using Boost_LIBRARIES.
145 # Boost_${COMPONENT}_FOUND True IF the Boost library "component" was found.
147 # Boost_${COMPONENT}_LIBRARY Contains the libraries for the specified Boost
148 # "component" (includes debug and optimized keywords
151 # =====================================================================
154 # Copyright (c) 2006-2008 Andreas Schneider <mail@cynapses.org>
155 # Copyright (c) 2007 Wengo
156 # Copyright (c) 2007 Mike Jackson
157 # Copyright (c) 2008 Andreas Pakulat <apaku@gmx.de>
159 # Redistribution AND use is allowed according to the terms of the New
161 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
166 #-------------------------------------------------------------------------------
167 # FindBoost functions & macros
169 ############################################
171 # Check the existence of the libraries.
173 ############################################
174 # This macro was taken directly from the FindQt4.cmake file that is included
175 # with the CMake distribution. This is NOT my work. All work was done by the
176 # original authors of the FindQt4.cmake file. Only minor modifications were
177 # made to remove references to Qt and make this file more generally applicable
178 # And ELSE/ENDIF pairs were removed for readability.
179 #########################################################################
181 MACRO (_Boost_ADJUST_LIB_VARS basename)
182 IF (Boost_INCLUDE_DIR )
183 IF (Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
184 # if the generator supports configuration types then set
185 # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
186 IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
187 SET(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
189 # if there are no configuration types and CMAKE_BUILD_TYPE has no value
190 # then just use the release libraries
191 SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
193 # FIXME: This probably should be set for both cases
194 SET(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
197 # if only the release version was found, set the debug variable also to the release version
198 IF (Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG)
199 SET(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE})
200 SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE})
201 SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE})
204 # if only the debug version was found, set the release variable also to the debug version
205 IF (Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE)
206 SET(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG})
207 SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG})
208 SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG})
211 IF (Boost_${basename}_LIBRARY)
212 set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library")
214 # Remove superfluous "debug" / "optimized" keywords from
216 FOREACH(_boost_my_lib ${Boost_${basename}_LIBRARY})
217 GET_FILENAME_COMPONENT(_boost_my_lib_path "${_boost_my_lib}" PATH)
218 LIST(APPEND Boost_LIBRARY_DIRS ${_boost_my_lib_path})
220 LIST(REMOVE_DUPLICATES Boost_LIBRARY_DIRS)
222 set(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS} CACHE FILEPATH "Boost library directory")
223 SET(Boost_${basename}_FOUND ON CACHE INTERNAL "Whether the Boost ${basename} library found")
224 ENDIF(Boost_${basename}_LIBRARY)
226 ENDIF (Boost_INCLUDE_DIR )
227 # Make variables changeble to the advanced user
229 Boost_${basename}_LIBRARY
230 Boost_${basename}_LIBRARY_RELEASE
231 Boost_${basename}_LIBRARY_DEBUG
233 ENDMACRO (_Boost_ADJUST_LIB_VARS)
235 #-------------------------------------------------------------------------------
238 # Runs compiler with "-dumpversion" and parses major/minor
239 # version with a regex.
241 FUNCTION(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION)
243 EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
244 ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
245 OUTPUT_VARIABLE _boost_COMPILER_VERSION
247 STRING(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
248 _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
250 SET(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE)
254 # End functions/macros
256 #-------------------------------------------------------------------------------
261 IF(NOT DEFINED Boost_USE_MULTITHREADED)
262 SET(Boost_USE_MULTITHREADED TRUE)
265 if(Boost_FIND_VERSION_EXACT)
266 # The version may appear in a directory with or without the patch
267 # level, even when the patch level is non-zero.
268 set(_boost_TEST_VERSIONS
269 "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.${Boost_FIND_VERSION_PATCH}"
270 "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
271 else(Boost_FIND_VERSION_EXACT)
272 # The user has not requested an exact version. Among known
273 # versions, find those that are acceptable to the user request.
274 set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
275 "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37"
276 "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0"
277 "1.34" "1.33.1" "1.33.0" "1.33")
278 set(_boost_TEST_VERSIONS)
279 if(Boost_FIND_VERSION)
280 set(_Boost_FIND_VERSION_SHORT "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
281 # Select acceptable versions.
282 foreach(version ${_Boost_KNOWN_VERSIONS})
283 if(NOT "${version}" VERSION_LESS "${Boost_FIND_VERSION}")
284 # This version is high enough.
285 list(APPEND _boost_TEST_VERSIONS "${version}")
286 elseif("${version}.99" VERSION_EQUAL "${_Boost_FIND_VERSION_SHORT}.99")
287 # This version is a short-form for the requested version with
288 # the patch level dropped.
289 list(APPEND _boost_TEST_VERSIONS "${version}")
292 else(Boost_FIND_VERSION)
293 # Any version is acceptable.
294 set(_boost_TEST_VERSIONS "${_Boost_KNOWN_VERSIONS}")
295 endif(Boost_FIND_VERSION)
296 endif(Boost_FIND_VERSION_EXACT)
298 # The reason that we failed to find Boost. This will be set to a
299 # user-friendly message when we fail to find some necessary piece of
301 set(Boost_ERROR_REASON)
303 SET( _boost_IN_CACHE TRUE)
304 IF(Boost_INCLUDE_DIR)
306 # On versions < 1.35, remove the System library from the considered list
307 # since it wasn't added until 1.35.
308 if(Boost_VERSION AND Boost_FIND_COMPONENTS)
309 math(EXPR _boost_maj "${Boost_VERSION} / 100000")
310 math(EXPR _boost_min "${Boost_VERSION} / 100 % 1000")
311 if(${_boost_maj}.${_boost_min} VERSION_LESS 1.35)
312 list(REMOVE_ITEM Boost_FIND_COMPONENTS system)
316 FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
317 STRING(TOUPPER ${COMPONENT} COMPONENT)
318 IF(NOT Boost_${COMPONENT}_FOUND)
319 SET( _boost_IN_CACHE FALSE)
320 ENDIF(NOT Boost_${COMPONENT}_FOUND)
321 ENDFOREACH(COMPONENT)
322 ELSE(Boost_INCLUDE_DIR)
323 SET( _boost_IN_CACHE FALSE)
324 ENDIF(Boost_INCLUDE_DIR)
328 SET(Boost_FOUND TRUE)
329 FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
330 STRING(TOUPPER ${COMPONENT} COMPONENT)
331 _Boost_ADJUST_LIB_VARS( ${COMPONENT} )
332 SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${COMPONENT}_LIBRARY})
333 ENDFOREACH(COMPONENT)
334 SET(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
335 IF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
336 MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
337 MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
338 MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
339 ENDIF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
341 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
342 "boost ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION} "
343 "is already in the cache. For debugging messages, please clear the cache.")
345 ELSE (_boost_IN_CACHE)
346 # Need to search for boost
348 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
349 "Boost not in cache")
350 # Output some of their choices
351 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
352 "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
353 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
354 "Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}")
355 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
356 "Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}")
360 # In windows, automatic linking is performed, so you do not have
361 # to specify the libraries. If you are linking to a dynamic
362 # runtime, then you can choose to link to either a static or a
363 # dynamic Boost library, the default is to do a static link. You
364 # can alter this for a specific library "whatever" by defining
365 # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be
366 # linked dynamically. Alternatively you can force all Boost
367 # libraries to dynamic link by defining BOOST_ALL_DYN_LINK.
369 # This feature can be disabled for Boost library "whatever" by
370 # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining
373 # If you want to observe which libraries are being linked against
374 # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking
375 # code to emit a #pragma message each time a library is selected
377 SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS
378 "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define")
381 SET(_boost_INCLUDE_SEARCH_DIRS
384 "$ENV{ProgramFiles}/boost"
388 # If BOOST_ROOT was defined in the environment, use it.
389 if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
390 set(BOOST_ROOT $ENV{BOOST_ROOT})
391 endif(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
393 # If BOOSTROOT was defined in the environment, use it.
394 if (NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
395 set(BOOST_ROOT $ENV{BOOSTROOT})
396 endif(NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
398 # If BOOST_INCLUDEDIR was defined in the environment, use it.
399 IF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
400 set(BOOST_INCLUDEDIR $ENV{BOOST_INCLUDEDIR})
401 ENDIF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
403 # If BOOST_LIBRARYDIR was defined in the environment, use it.
404 IF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
405 set(BOOST_LIBRARYDIR $ENV{BOOST_LIBRARYDIR})
406 ENDIF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
409 file(TO_CMAKE_PATH ${BOOST_ROOT} BOOST_ROOT)
413 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
414 "Declared as CMake or Environmental Variables:")
415 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
416 " BOOST_ROOT = ${BOOST_ROOT}")
417 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
418 " BOOST_INCLUDEDIR = ${BOOST_INCLUDEDIR}")
419 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
420 " BOOST_LIBRARYDIR = ${BOOST_LIBRARYDIR}")
421 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
422 "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
426 SET(_boost_INCLUDE_SEARCH_DIRS
427 ${BOOST_ROOT}/include
429 ${_boost_INCLUDE_SEARCH_DIRS})
432 IF( BOOST_INCLUDEDIR )
433 file(TO_CMAKE_PATH ${BOOST_INCLUDEDIR} BOOST_INCLUDEDIR)
434 SET(_boost_INCLUDE_SEARCH_DIRS
435 ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS})
436 ENDIF( BOOST_INCLUDEDIR )
438 # ------------------------------------------------------------------------
439 # Search for Boost include DIR
440 # ------------------------------------------------------------------------
441 # Try to find Boost by stepping backwards through the Boost versions
443 IF( NOT Boost_INCLUDE_DIR )
444 # Build a list of path suffixes for each version.
445 SET(_boost_PATH_SUFFIXES)
446 FOREACH(_boost_VER ${_boost_TEST_VERSIONS})
447 # Add in a path suffix, based on the required version, ideally
448 # we could read this from version.hpp, but for that to work we'd
449 # need to know the include dir already
450 set(_boost_BOOSTIFIED_VERSION)
452 # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0
453 IF(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
454 STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3"
455 _boost_BOOSTIFIED_VERSION ${_boost_VER})
456 ELSEIF(_boost_VER MATCHES "[0-9]+\\.[0-9]+")
457 STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2"
458 _boost_BOOSTIFIED_VERSION ${_boost_VER})
461 list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_BOOSTIFIED_VERSION}")
463 # For BoostPro's underscores (and others?)
464 list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_BOOSTIFIED_VERSION}")
467 ENDFOREACH(_boost_VER)
470 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
471 "Include debugging info:")
472 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
473 " _boost_INCLUDE_SEARCH_DIRS = ${_boost_INCLUDE_SEARCH_DIRS}")
474 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
475 " _boost_PATH_SUFFIXES = ${_boost_PATH_SUFFIXES}")
478 # Look for a standard boost header file.
479 FIND_PATH(Boost_INCLUDE_DIR
480 NAMES boost/config.hpp
481 HINTS ${_boost_INCLUDE_SEARCH_DIRS}
482 PATH_SUFFIXES ${_boost_PATH_SUFFIXES}
484 ENDIF( NOT Boost_INCLUDE_DIR )
486 # ------------------------------------------------------------------------
487 # Extract version information from version.hpp
488 # ------------------------------------------------------------------------
490 IF(Boost_INCLUDE_DIR)
491 # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp
492 # Read the whole file:
495 SET(BOOST_LIB_VERSION "")
496 FILE(READ "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS)
498 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
499 "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp")
502 STRING(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}")
503 STRING(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}")
505 SET(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE INTERNAL "The library version string for boost libraries")
506 SET(Boost_VERSION ${Boost_VERSION} CACHE INTERNAL "The version number for boost libraries")
508 IF(NOT "${Boost_VERSION}" STREQUAL "0")
509 MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
510 MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
511 MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
513 set(Boost_ERROR_REASON
514 "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}")
515 ENDIF(NOT "${Boost_VERSION}" STREQUAL "0")
517 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
518 "version.hpp reveals boost "
519 "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
521 ELSE(Boost_INCLUDE_DIR)
522 set(Boost_ERROR_REASON
523 "${Boost_ERROR_REASON}Unable to find the Boost header files. Please set BOOST_ROOT to the root directory containing Boost or BOOST_INCLUDEDIR to the directory containing Boost's headers.")
524 ENDIF(Boost_INCLUDE_DIR)
526 # ------------------------------------------------------------------------
527 # Suffix initialization and compiler suffix detection.
528 # ------------------------------------------------------------------------
530 # Setting some more suffixes for the library
531 SET (Boost_LIB_PREFIX "")
532 if ( WIN32 AND Boost_USE_STATIC_LIBS )
533 SET (Boost_LIB_PREFIX "lib")
537 set(_boost_COMPILER ${Boost_COMPILER})
539 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
540 "using user-specified Boost_COMPILER = ${_boost_COMPILER}")
543 # Attempt to guess the compiler suffix
544 # NOTE: this is not perfect yet, if you experience any issues
545 # please report them and use the Boost_COMPILER variable
546 # to work around the problems.
548 SET (_boost_COMPILER "-vc90")
550 SET (_boost_COMPILER "-vc80")
552 SET (_boost_COMPILER "-vc71")
553 elseif (MSVC70) # Good luck!
554 SET (_boost_COMPILER "-vc7") # yes, this is correct
555 elseif (MSVC60) # Good luck!
556 SET (_boost_COMPILER "-vc6") # yes, this is correct
558 SET (_boost_COMPILER "-bcb")
559 elseif("${CMAKE_CXX_COMPILER}" MATCHES "icl"
560 OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
562 set (_boost_COMPILER "-iw")
564 set (_boost_COMPILER "-il")
567 if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
568 SET(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34
570 _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
571 SET (_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}")
574 if (CMAKE_COMPILER_IS_GNUCXX)
575 if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
576 SET(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34
578 _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
579 # Determine which version of GCC we have.
581 IF(Boost_MINOR_VERSION)
582 IF(${Boost_MINOR_VERSION} GREATER 35)
583 # In Boost 1.36.0 and newer, the mangled compiler name used
584 # on Mac OS X/Darwin is "xgcc".
585 SET(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}")
586 ELSE(${Boost_MINOR_VERSION} GREATER 35)
587 # In Boost <= 1.35.0, there is no mangled compiler name for
588 # the Mac OS X/Darwin version of GCC.
589 SET(_boost_COMPILER "")
590 ENDIF(${Boost_MINOR_VERSION} GREATER 35)
591 ELSE(Boost_MINOR_VERSION)
592 # We don't know the Boost version, so assume it's
594 SET(_boost_COMPILER "")
595 ENDIF(Boost_MINOR_VERSION)
597 SET (_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}")
600 endif (CMAKE_COMPILER_IS_GNUCXX)
603 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
604 "guessed _boost_COMPILER = ${_boost_COMPILER}")
606 endif(Boost_COMPILER)
608 SET (_boost_MULTITHREADED "-mt")
609 if( NOT Boost_USE_MULTITHREADED )
610 set (_boost_MULTITHREADED "")
613 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
614 "_boost_MULTITHREADED = ${_boost_MULTITHREADED}")
617 SET( _boost_STATIC_TAG "")
618 set( _boost_ABI_TAG "")
621 SET (_boost_ABI_TAG "g")
623 IF( Boost_USE_STATIC_LIBS )
624 SET( _boost_STATIC_TAG "-s")
625 ENDIF( Boost_USE_STATIC_LIBS )
627 SET (_boost_ABI_TAG "${_boost_ABI_TAG}d")
629 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
630 "_boost_STATIC_TAG = ${_boost_STATIC_TAG}")
631 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
632 "_boost_ABI_TAG = ${_boost_ABI_TAG}")
635 # ------------------------------------------------------------------------
636 # Begin finding boost libraries
637 # ------------------------------------------------------------------------
639 SET(_boost_LIBRARIES_SEARCH_DIRS
640 ${Boost_INCLUDE_DIR}/lib
643 "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}_${Boost_SUBMINOR_VERSION}/lib"
644 "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}/lib"
645 "$ENV{ProgramFiles}/boost"
649 SET(_boost_LIBRARIES_SEARCH_DIRS
651 ${BOOST_ROOT}/stage/lib
652 ${_boost_LIBRARIES_SEARCH_DIRS})
655 IF( BOOST_LIBRARYDIR )
656 file(TO_CMAKE_PATH ${BOOST_LIBRARYDIR} BOOST_LIBRARYDIR)
657 SET(_boost_LIBRARIES_SEARCH_DIRS
658 ${BOOST_LIBRARYDIR} ${_boost_LIBRARIES_SEARCH_DIRS})
659 ENDIF( BOOST_LIBRARYDIR )
662 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
663 "_boost_LIBRARIES_SEARCH_DIRS = ${_boost_LIBRARIES_SEARCH_DIRS}")
666 FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
667 STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
668 SET( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" )
669 SET( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" )
670 SET( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND")
672 # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
673 IF( Boost_USE_STATIC_LIBS )
674 SET( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
676 SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
678 SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
680 ENDIF( Boost_USE_STATIC_LIBS )
682 FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE
683 NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${Boost_LIB_VERSION}
684 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION}
685 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${Boost_LIB_VERSION}
686 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION}
687 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}
688 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}
689 ${Boost_LIB_PREFIX}boost_${COMPONENT}
690 HINTS ${_boost_LIBRARIES_SEARCH_DIRS}
693 FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG
694 NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION}
695 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION}
696 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION}
697 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION}
698 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}
699 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}
700 ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_boost_ABI_TAG}
701 HINTS ${_boost_LIBRARIES_SEARCH_DIRS}
704 _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT})
705 IF( Boost_USE_STATIC_LIBS )
706 SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
707 ENDIF( Boost_USE_STATIC_LIBS )
708 ENDFOREACH(COMPONENT)
709 # ------------------------------------------------------------------------
710 # End finding boost libraries
711 # ------------------------------------------------------------------------
713 SET(Boost_INCLUDE_DIRS
717 SET(Boost_FOUND FALSE)
718 IF(Boost_INCLUDE_DIR)
719 SET( Boost_FOUND TRUE )
721 # Check the version of Boost against the requested version.
722 if (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
723 message(SEND_ERROR "When requesting a specific version of Boost, you must provide at least the major and minor version numbers, e.g., 1.34")
724 endif (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
725 if(Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
726 set( Boost_FOUND FALSE )
727 set(_Boost_VERSION_AGE "old")
728 elseif(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
729 if(Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
730 set( Boost_FOUND FALSE )
731 set(_Boost_VERSION_AGE "old")
732 elseif(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
733 if( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
734 set( Boost_FOUND FALSE )
735 set(_Boost_VERSION_AGE "old")
736 endif( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
737 endif( Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
738 endif( Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
740 if (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
741 # If the user requested an exact version of Boost, check
742 # that. We already know that the Boost version we have is >= the
744 set(_Boost_VERSION_AGE "new")
746 # If the user didn't specify a patchlevel, it's 0.
747 if (NOT Boost_FIND_VERSION_PATCH)
748 set(Boost_FIND_VERSION_PATCH 0)
749 endif (NOT Boost_FIND_VERSION_PATCH)
751 # We'll set Boost_FOUND true again if we have an exact version match.
752 set(Boost_FOUND FALSE)
753 if(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
754 if(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
755 if(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
756 set( Boost_FOUND TRUE )
757 endif(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
758 endif( Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
759 endif( Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
760 endif (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
763 # State that we found a version of Boost that is too new or too old.
764 set(Boost_ERROR_REASON
765 "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
766 if (Boost_FIND_VERSION_PATCH)
767 set(Boost_ERROR_REASON
768 "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}")
769 endif (Boost_FIND_VERSION_PATCH)
770 if (NOT Boost_FIND_VERSION_EXACT)
771 set(Boost_ERROR_REASON "${Boost_ERROR_REASON} (or newer)")
772 endif (NOT Boost_FIND_VERSION_EXACT)
773 set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.")
774 endif (NOT Boost_FOUND)
777 set(_boost_CHECKED_COMPONENT FALSE)
778 set(_Boost_MISSING_COMPONENTS)
779 foreach(COMPONENT ${Boost_FIND_COMPONENTS})
780 string(TOUPPER ${COMPONENT} COMPONENT)
781 set(_boost_CHECKED_COMPONENT TRUE)
782 if(NOT Boost_${COMPONENT}_FOUND)
783 string(TOLOWER ${COMPONENT} COMPONENT)
784 list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT})
785 set( Boost_FOUND FALSE)
786 endif(NOT Boost_${COMPONENT}_FOUND)
787 endforeach(COMPONENT)
791 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] Boost_FOUND = ${Boost_FOUND}")
794 if (_Boost_MISSING_COMPONENTS)
795 # We were unable to find some libraries, so generate a sensible
796 # error message that lists the libraries we were unable to find.
797 set(Boost_ERROR_REASON
798 "${Boost_ERROR_REASON}\nThe following Boost libraries could not be found:\n")
799 foreach(COMPONENT ${_Boost_MISSING_COMPONENTS})
800 set(Boost_ERROR_REASON
801 "${Boost_ERROR_REASON} boost_${COMPONENT}\n")
802 endforeach(COMPONENT)
804 list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED)
805 list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS)
806 if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
807 set(Boost_ERROR_REASON
808 "${Boost_ERROR_REASON}No Boost libraries were found. You may need to set Boost_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.")
809 else (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
810 set(Boost_ERROR_REASON
811 "${Boost_ERROR_REASON}Some (but not all) of the required Boost libraries were found. You may need to install these additional Boost libraries. Alternatively, set Boost_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.")
812 endif (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
813 endif (_Boost_MISSING_COMPONENTS)
815 IF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
816 # Compatibility Code for backwards compatibility with CMake
817 # 2.4's FindBoost module.
819 # Look for the boost library path.
820 # Note that the user may not have installed any libraries
821 # so it is quite possible the Boost_LIBRARY_PATH may not exist.
822 SET(_boost_LIB_DIR ${Boost_INCLUDE_DIR})
824 IF("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
825 GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
826 ENDIF ("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
828 IF("${_boost_LIB_DIR}" MATCHES "/include$")
829 # Strip off the trailing "/include" in the path.
830 GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
831 ENDIF("${_boost_LIB_DIR}" MATCHES "/include$")
833 IF(EXISTS "${_boost_LIB_DIR}/lib")
834 SET (_boost_LIB_DIR ${_boost_LIB_DIR}/lib)
835 ELSE(EXISTS "${_boost_LIB_DIR}/lib")
836 IF(EXISTS "${_boost_LIB_DIR}/stage/lib")
837 SET(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib)
838 ELSE(EXISTS "${_boost_LIB_DIR}/stage/lib")
839 SET(_boost_LIB_DIR "")
840 ENDIF(EXISTS "${_boost_LIB_DIR}/stage/lib")
841 ENDIF(EXISTS "${_boost_LIB_DIR}/lib")
843 IF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
844 SET(Boost_LIBRARY_DIRS ${_boost_LIB_DIR} CACHE FILEPATH "Boost library directory")
845 ENDIF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
847 ENDIF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
849 ELSE(Boost_INCLUDE_DIR)
850 SET( Boost_FOUND FALSE)
851 ENDIF(Boost_INCLUDE_DIR)
854 IF (NOT Boost_FIND_QUIETLY)
855 MESSAGE(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
856 ENDIF(NOT Boost_FIND_QUIETLY)
857 IF (NOT Boost_FIND_QUIETLY)
858 MESSAGE(STATUS "Found the following Boost libraries:")
859 ENDIF(NOT Boost_FIND_QUIETLY)
860 FOREACH ( COMPONENT ${Boost_FIND_COMPONENTS} )
861 STRING( TOUPPER ${COMPONENT} UPPERCOMPONENT )
862 IF ( Boost_${UPPERCOMPONENT}_FOUND )
863 IF (NOT Boost_FIND_QUIETLY)
864 MESSAGE (STATUS " ${COMPONENT}")
865 ENDIF(NOT Boost_FIND_QUIETLY)
866 SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${UPPERCOMPONENT}_LIBRARY})
867 ENDIF ( Boost_${UPPERCOMPONENT}_FOUND )
868 ENDFOREACH(COMPONENT)
870 IF (Boost_FIND_REQUIRED)
871 message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")
872 ENDIF(Boost_FIND_REQUIRED)
875 # show the Boost_INCLUDE_DIRS AND Boost_LIBRARIES variables only in the advanced view
876 MARK_AS_ADVANCED(Boost_INCLUDE_DIR
880 ENDIF(_boost_IN_CACHE)