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
62 # NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should
63 # add both 1.x and 1.x.0 as shown above. Official Boost include directories
64 # omit the 3rd version number from include paths if it is 0 although not all
65 # binary Boost releases do so.
67 # SET(Boost_ADDITIONAL_VERSIONS "0.99" "0.99.0" "1.78" "1.78.0")
69 # ============================================================================
71 # Variables used by this module, they can change the default behaviour and
72 # need to be set before calling find_package:
74 # Boost_USE_MULTITHREADED Can be set to OFF to use the non-multithreaded
75 # boost libraries. If not specified, defaults
78 # Boost_USE_STATIC_LIBS Can be set to ON to force the use of the static
79 # boost libraries. Defaults to OFF.
81 # Other Variables used by this module which you may want to set.
83 # Boost_ADDITIONAL_VERSIONS A list of version numbers to use for searching
84 # the boost include directory. Please see
85 # the documentation above regarding this
86 # annoying, but necessary variable :(
88 # Boost_DEBUG Set this to TRUE to enable debugging output
89 # of FindBoost.cmake if you are having problems.
90 # Please enable this before filing any bug
93 # Boost_COMPILER Set this to the compiler suffix used by Boost
94 # (e.g. "-gcc43") if FindBoost has problems finding
95 # the proper Boost installation
97 # These last three variables are available also as environment variables:
99 # BOOST_ROOT or BOOSTROOT The preferred installation prefix for searching for
100 # Boost. Set this if the module has problems finding
101 # the proper Boost installation.
103 # BOOST_INCLUDEDIR Set this to the include directory of Boost, if the
104 # module has problems finding the proper Boost installation
106 # BOOST_LIBRARYDIR Set this to the lib directory of Boost, if the
107 # module has problems finding the proper Boost installation
109 # Variables defined by this module:
111 # Boost_FOUND System has Boost, this means the include dir was
112 # found, as well as all the libraries specified in
113 # the COMPONENTS list.
115 # Boost_INCLUDE_DIRS Boost include directories: not cached
117 # Boost_INCLUDE_DIR This is almost the same as above, but this one is
118 # cached and may be modified by advanced users
120 # Boost_LIBRARIES Link to these to use the Boost libraries that you
121 # specified: not cached
123 # Boost_LIBRARY_DIRS The path to where the Boost library files are.
125 # Boost_VERSION The version number of the boost libraries that
126 # have been found, same as in version.hpp from Boost
128 # Boost_LIB_VERSION The version number in filename form as
129 # it's appended to the library filenames
131 # Boost_MAJOR_VERSION major version number of boost
132 # Boost_MINOR_VERSION minor version number of boost
133 # Boost_SUBMINOR_VERSION subminor version number of boost
135 # Boost_LIB_DIAGNOSTIC_DEFINITIONS [WIN32 Only] You can call
136 # add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINTIIONS})
137 # to have diagnostic information about Boost's
138 # automatic linking outputted during compilation time.
140 # For each component you specify in find_package(), the following (UPPER-CASE)
141 # variables are set. You can use these variables if you would like to pick and
142 # choose components for your targets instead of just using Boost_LIBRARIES.
144 # Boost_${COMPONENT}_FOUND True IF the Boost library "component" was found.
146 # Boost_${COMPONENT}_LIBRARY Contains the libraries for the specified Boost
147 # "component" (includes debug and optimized keywords
150 # =====================================================================
153 # Copyright (c) 2006-2008 Andreas Schneider <mail@cynapses.org>
154 # Copyright (c) 2007 Wengo
155 # Copyright (c) 2007 Mike Jackson
156 # Copyright (c) 2008 Andreas Pakulat <apaku@gmx.de>
158 # Redistribution AND use is allowed according to the terms of the New
160 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
165 #-------------------------------------------------------------------------------
166 # FindBoost functions & macros
168 ############################################
170 # Check the existence of the libraries.
172 ############################################
173 # This macro was taken directly from the FindQt4.cmake file that is included
174 # with the CMake distribution. This is NOT my work. All work was done by the
175 # original authors of the FindQt4.cmake file. Only minor modifications were
176 # made to remove references to Qt and make this file more generally applicable
177 # And ELSE/ENDIF pairs were removed for readability.
178 #########################################################################
180 MACRO (_Boost_ADJUST_LIB_VARS basename)
181 IF (Boost_INCLUDE_DIR )
182 IF (Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
183 # if the generator supports configuration types then set
184 # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
185 IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
186 SET(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
188 # if there are no configuration types and CMAKE_BUILD_TYPE has no value
189 # then just use the release libraries
190 SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
192 # FIXME: This probably should be set for both cases
193 SET(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
196 # if only the release version was found, set the debug variable also to the release version
197 IF (Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG)
198 SET(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE})
199 SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE})
200 SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE})
203 # if only the debug version was found, set the release variable also to the debug version
204 IF (Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE)
205 SET(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG})
206 SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG})
207 SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG})
210 IF (Boost_${basename}_LIBRARY)
211 set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library")
213 # Remove superfluous "debug" / "optimized" keywords from
215 FOREACH(_boost_my_lib ${Boost_${basename}_LIBRARY})
216 GET_FILENAME_COMPONENT(_boost_my_lib_path "${_boost_my_lib}" PATH)
217 LIST(APPEND Boost_LIBRARY_DIRS ${_boost_my_lib_path})
219 LIST(REMOVE_DUPLICATES Boost_LIBRARY_DIRS)
221 set(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS} CACHE FILEPATH "Boost library directory")
222 SET(Boost_${basename}_FOUND ON CACHE INTERNAL "Whether the Boost ${basename} library found")
223 ENDIF(Boost_${basename}_LIBRARY)
225 ENDIF (Boost_INCLUDE_DIR )
226 # Make variables changeble to the advanced user
228 Boost_${basename}_LIBRARY
229 Boost_${basename}_LIBRARY_RELEASE
230 Boost_${basename}_LIBRARY_DEBUG
232 ENDMACRO (_Boost_ADJUST_LIB_VARS)
234 #-------------------------------------------------------------------------------
237 # Runs compiler with "-dumpversion" and parses major/minor
238 # version with a regex.
240 FUNCTION(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION)
242 EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
243 ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
244 OUTPUT_VARIABLE _boost_COMPILER_VERSION
246 STRING(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
247 _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
249 SET(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE)
253 # End functions/macros
255 #-------------------------------------------------------------------------------
260 IF(NOT DEFINED Boost_USE_MULTITHREADED)
261 SET(Boost_USE_MULTITHREADED TRUE)
264 if(Boost_FIND_VERSION_EXACT)
265 # The version may appear in a directory with or without the patch
266 # level, even when the patch level is non-zero.
267 set(_boost_TEST_VERSIONS
268 "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.${Boost_FIND_VERSION_PATCH}"
269 "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
270 else(Boost_FIND_VERSION_EXACT)
271 # The user has not requested an exact version. Among known
272 # versions, find those that are acceptable to the user request.
273 set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
274 "1.38.0" "1.38" "1.37.0" "1.37"
275 "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0"
276 "1.34" "1.33.1" "1.33.0" "1.33")
277 set(_boost_TEST_VERSIONS)
278 if(Boost_FIND_VERSION)
279 set(_Boost_FIND_VERSION_SHORT "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
280 # Select acceptable versions.
281 foreach(version ${_Boost_KNOWN_VERSIONS})
282 if(NOT "${version}" VERSION_LESS "${Boost_FIND_VERSION}")
283 # This version is high enough.
284 list(APPEND _boost_TEST_VERSIONS "${version}")
285 elseif("${version}.99" VERSION_EQUAL "${_Boost_FIND_VERSION_SHORT}.99")
286 # This version is a short-form for the requested version with
287 # the patch level dropped.
288 list(APPEND _boost_TEST_VERSIONS "${version}")
291 else(Boost_FIND_VERSION)
292 # Any version is acceptable.
293 set(_boost_TEST_VERSIONS "${_Boost_KNOWN_VERSIONS}")
294 endif(Boost_FIND_VERSION)
295 endif(Boost_FIND_VERSION_EXACT)
297 # The reason that we failed to find Boost. This will be set to a
298 # user-friendly message when we fail to find some necessary piece of
300 set(Boost_ERROR_REASON)
302 SET( _boost_IN_CACHE TRUE)
303 IF(Boost_INCLUDE_DIR)
305 # On versions < 1.35, remove the System library from the considered list
306 # since it wasn't added until 1.35.
307 if(Boost_VERSION AND Boost_FIND_COMPONENTS)
308 math(EXPR _boost_maj "${Boost_VERSION} / 100000")
309 math(EXPR _boost_min "${Boost_VERSION} / 100 % 1000")
310 if(${_boost_maj}.${_boost_min} VERSION_LESS 1.35)
311 list(REMOVE_ITEM Boost_FIND_COMPONENTS system)
315 FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
316 STRING(TOUPPER ${COMPONENT} COMPONENT)
317 IF(NOT Boost_${COMPONENT}_FOUND)
318 SET( _boost_IN_CACHE FALSE)
319 ENDIF(NOT Boost_${COMPONENT}_FOUND)
320 ENDFOREACH(COMPONENT)
321 ELSE(Boost_INCLUDE_DIR)
322 SET( _boost_IN_CACHE FALSE)
323 ENDIF(Boost_INCLUDE_DIR)
327 SET(Boost_FOUND TRUE)
328 FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
329 STRING(TOUPPER ${COMPONENT} COMPONENT)
330 _Boost_ADJUST_LIB_VARS( ${COMPONENT} )
331 SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${COMPONENT}_LIBRARY})
332 ENDFOREACH(COMPONENT)
333 SET(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
334 IF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
335 MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
336 MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
337 MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
338 ENDIF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
340 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
341 "boost ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION} "
342 "is already in the cache. For debugging messages, please clear the cache.")
344 ELSE (_boost_IN_CACHE)
345 # Need to search for boost
347 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
348 "Boost not in cache")
349 # Output some of their choices
350 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
351 "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
352 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
353 "Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}")
354 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
355 "Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}")
359 # In windows, automatic linking is performed, so you do not have
360 # to specify the libraries. If you are linking to a dynamic
361 # runtime, then you can choose to link to either a static or a
362 # dynamic Boost library, the default is to do a static link. You
363 # can alter this for a specific library "whatever" by defining
364 # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be
365 # linked dynamically. Alternatively you can force all Boost
366 # libraries to dynamic link by defining BOOST_ALL_DYN_LINK.
368 # This feature can be disabled for Boost library "whatever" by
369 # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining
372 # If you want to observe which libraries are being linked against
373 # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking
374 # code to emit a #pragma message each time a library is selected
376 SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS
377 "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define")
380 SET(_boost_INCLUDE_SEARCH_DIRS
383 "$ENV{ProgramFiles}/boost"
387 # If BOOST_ROOT was defined in the environment, use it.
388 if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
389 set(BOOST_ROOT $ENV{BOOST_ROOT})
390 endif(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
392 # If BOOSTROOT was defined in the environment, use it.
393 if (NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
394 set(BOOST_ROOT $ENV{BOOSTROOT})
395 endif(NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
397 # If BOOST_INCLUDEDIR was defined in the environment, use it.
398 IF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
399 set(BOOST_INCLUDEDIR $ENV{BOOST_INCLUDEDIR})
400 ENDIF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
402 # If BOOST_LIBRARYDIR was defined in the environment, use it.
403 IF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
404 set(BOOST_LIBRARYDIR $ENV{BOOST_LIBRARYDIR})
405 ENDIF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
408 file(TO_CMAKE_PATH ${BOOST_ROOT} BOOST_ROOT)
412 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
413 "Declared as CMake or Environmental Variables:")
414 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
415 " BOOST_ROOT = ${BOOST_ROOT}")
416 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
417 " BOOST_INCLUDEDIR = ${BOOST_INCLUDEDIR}")
418 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
419 " BOOST_LIBRARYDIR = ${BOOST_LIBRARYDIR}")
420 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
421 "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
425 SET(_boost_INCLUDE_SEARCH_DIRS
426 ${BOOST_ROOT}/include
428 ${_boost_INCLUDE_SEARCH_DIRS})
431 IF( BOOST_INCLUDEDIR )
432 file(TO_CMAKE_PATH ${BOOST_INCLUDEDIR} BOOST_INCLUDEDIR)
433 SET(_boost_INCLUDE_SEARCH_DIRS
434 ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS})
435 ENDIF( BOOST_INCLUDEDIR )
437 # ------------------------------------------------------------------------
438 # Search for Boost include DIR
439 # ------------------------------------------------------------------------
440 # Try to find Boost by stepping backwards through the Boost versions
442 IF( NOT Boost_INCLUDE_DIR )
443 # Build a list of path suffixes for each version.
444 SET(_boost_PATH_SUFFIXES)
445 FOREACH(_boost_VER ${_boost_TEST_VERSIONS})
446 # Add in a path suffix, based on the required version, ideally
447 # we could read this from version.hpp, but for that to work we'd
448 # need to know the include dir already
449 set(_boost_BOOSTIFIED_VERSION)
451 # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0
452 IF(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
453 STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3"
454 _boost_BOOSTIFIED_VERSION ${_boost_VER})
455 ELSEIF(_boost_VER MATCHES "[0-9]+\\.[0-9]+")
456 STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2"
457 _boost_BOOSTIFIED_VERSION ${_boost_VER})
460 list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_BOOSTIFIED_VERSION}")
462 # For BoostPro's underscores (and others?)
463 list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_BOOSTIFIED_VERSION}")
466 ENDFOREACH(_boost_VER)
469 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
470 "Include debugging info:")
471 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
472 " _boost_INCLUDE_SEARCH_DIRS = ${_boost_INCLUDE_SEARCH_DIRS}")
473 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
474 " _boost_PATH_SUFFIXES = ${_boost_PATH_SUFFIXES}")
477 # Look for a standard boost header file.
478 FIND_PATH(Boost_INCLUDE_DIR
479 NAMES boost/config.hpp
480 HINTS ${_boost_INCLUDE_SEARCH_DIRS}
481 PATH_SUFFIXES ${_boost_PATH_SUFFIXES}
483 ENDIF( NOT Boost_INCLUDE_DIR )
485 # ------------------------------------------------------------------------
486 # Extract version information from version.hpp
487 # ------------------------------------------------------------------------
489 IF(Boost_INCLUDE_DIR)
490 # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp
491 # Read the whole file:
494 SET(BOOST_LIB_VERSION "")
495 FILE(READ "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS)
497 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
498 "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp")
501 STRING(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}")
502 STRING(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}")
504 SET(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE INTERNAL "The library version string for boost libraries")
505 SET(Boost_VERSION ${Boost_VERSION} CACHE INTERNAL "The version number for boost libraries")
507 IF(NOT "${Boost_VERSION}" STREQUAL "0")
508 MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
509 MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
510 MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
512 set(Boost_ERROR_REASON
513 "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}")
514 ENDIF(NOT "${Boost_VERSION}" STREQUAL "0")
516 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
517 "version.hpp reveals boost "
518 "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
520 ELSE(Boost_INCLUDE_DIR)
521 set(Boost_ERROR_REASON
522 "${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.")
523 ENDIF(Boost_INCLUDE_DIR)
525 # ------------------------------------------------------------------------
526 # Suffix initialization and compiler suffix detection.
527 # ------------------------------------------------------------------------
529 # Setting some more suffixes for the library
530 SET (Boost_LIB_PREFIX "")
531 if ( WIN32 AND Boost_USE_STATIC_LIBS )
532 SET (Boost_LIB_PREFIX "lib")
536 set(_boost_COMPILER ${Boost_COMPILER})
538 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
539 "using user-specified Boost_COMPILER = ${_boost_COMPILER}")
542 # Attempt to guess the compiler suffix
543 # NOTE: this is not perfect yet, if you experience any issues
544 # please report them and use the Boost_COMPILER variable
545 # to work around the problems.
547 SET (_boost_COMPILER "-vc90")
549 SET (_boost_COMPILER "-vc80")
551 SET (_boost_COMPILER "-vc71")
552 elseif (MSVC70) # Good luck!
553 SET (_boost_COMPILER "-vc7") # yes, this is correct
554 elseif (MSVC60) # Good luck!
555 SET (_boost_COMPILER "-vc6") # yes, this is correct
557 SET (_boost_COMPILER "-bcb")
558 elseif("${CMAKE_CXX_COMPILER}" MATCHES "icl"
559 OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
561 set (_boost_COMPILER "-iw")
563 set (_boost_COMPILER "-il")
566 if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
567 SET(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34
569 _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
570 SET (_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}")
573 if (CMAKE_COMPILER_IS_GNUCXX)
574 if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
575 SET(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34
577 _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
578 # Determine which version of GCC we have.
580 IF(Boost_MINOR_VERSION)
581 IF(${Boost_MINOR_VERSION} GREATER 35)
582 # In Boost 1.36.0 and newer, the mangled compiler name used
583 # on Mac OS X/Darwin is "xgcc".
584 SET(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}")
585 ELSE(${Boost_MINOR_VERSION} GREATER 35)
586 # In Boost <= 1.35.0, there is no mangled compiler name for
587 # the Mac OS X/Darwin version of GCC.
588 SET(_boost_COMPILER "")
589 ENDIF(${Boost_MINOR_VERSION} GREATER 35)
590 ELSE(Boost_MINOR_VERSION)
591 # We don't know the Boost version, so assume it's
593 SET(_boost_COMPILER "")
594 ENDIF(Boost_MINOR_VERSION)
596 SET (_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}")
599 endif (CMAKE_COMPILER_IS_GNUCXX)
602 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
603 "guessed _boost_COMPILER = ${_boost_COMPILER}")
605 endif(Boost_COMPILER)
607 SET (_boost_MULTITHREADED "-mt")
608 if( NOT Boost_USE_MULTITHREADED )
609 set (_boost_MULTITHREADED "")
612 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
613 "_boost_MULTITHREADED = ${_boost_MULTITHREADED}")
616 SET( _boost_STATIC_TAG "")
617 set( _boost_ABI_TAG "")
620 SET (_boost_ABI_TAG "g")
622 IF( Boost_USE_STATIC_LIBS )
623 SET( _boost_STATIC_TAG "-s")
624 ENDIF( Boost_USE_STATIC_LIBS )
626 SET (_boost_ABI_TAG "${_boost_ABI_TAG}d")
628 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
629 "_boost_STATIC_TAG = ${_boost_STATIC_TAG}")
630 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
631 "_boost_ABI_TAG = ${_boost_ABI_TAG}")
634 # ------------------------------------------------------------------------
635 # Begin finding boost libraries
636 # ------------------------------------------------------------------------
638 SET(_boost_LIBRARIES_SEARCH_DIRS
641 "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}_${Boost_SUBMINOR_VERSION}/lib"
642 "$ENV{ProgramFiles}/boost"
646 SET(_boost_LIBRARIES_SEARCH_DIRS
648 ${BOOST_ROOT}/stage/lib
649 ${_boost_LIBRARIES_SEARCH_DIRS})
652 IF( BOOST_LIBRARYDIR )
653 file(TO_CMAKE_PATH ${BOOST_LIBRARYDIR} BOOST_LIBRARYDIR)
654 SET(_boost_LIBRARIES_SEARCH_DIRS
655 ${BOOST_LIBRARYDIR} ${_boost_LIBRARIES_SEARCH_DIRS})
656 ENDIF( BOOST_LIBRARYDIR )
659 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
660 "_boost_LIBRARIES_SEARCH_DIRS = ${_boost_LIBRARIES_SEARCH_DIRS}")
663 FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
664 STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
665 SET( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" )
666 SET( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" )
667 SET( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND")
669 # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
670 IF( Boost_USE_STATIC_LIBS )
671 SET( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
673 SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
675 SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
677 ENDIF( Boost_USE_STATIC_LIBS )
679 FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE
680 NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${Boost_LIB_VERSION}
681 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION}
682 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${Boost_LIB_VERSION}
683 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION}
684 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}
685 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}
686 ${Boost_LIB_PREFIX}boost_${COMPONENT}
687 HINTS ${_boost_LIBRARIES_SEARCH_DIRS}
690 FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG
691 NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION}
692 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION}
693 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION}
694 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION}
695 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}
696 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}
697 ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_boost_ABI_TAG}
698 HINTS ${_boost_LIBRARIES_SEARCH_DIRS}
701 _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT})
702 IF( Boost_USE_STATIC_LIBS )
703 SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
704 ENDIF( Boost_USE_STATIC_LIBS )
705 ENDFOREACH(COMPONENT)
706 # ------------------------------------------------------------------------
707 # End finding boost libraries
708 # ------------------------------------------------------------------------
710 SET(Boost_INCLUDE_DIRS
714 SET(Boost_FOUND FALSE)
715 IF(Boost_INCLUDE_DIR)
716 SET( Boost_FOUND TRUE )
718 # Check the version of Boost against the requested version.
719 if (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
720 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")
721 endif (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
722 if(Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
723 set( Boost_FOUND FALSE )
724 set(_Boost_VERSION_AGE "old")
725 elseif(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
726 if(Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
727 set( Boost_FOUND FALSE )
728 set(_Boost_VERSION_AGE "old")
729 elseif(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
730 if( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
731 set( Boost_FOUND FALSE )
732 set(_Boost_VERSION_AGE "old")
733 endif( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
734 endif( Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
735 endif( Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
737 if (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
738 # If the user requested an exact version of Boost, check
739 # that. We already know that the Boost version we have is >= the
741 set(_Boost_VERSION_AGE "new")
743 # If the user didn't specify a patchlevel, it's 0.
744 if (NOT Boost_FIND_VERSION_PATCH)
745 set(Boost_FIND_VERSION_PATCH 0)
746 endif (NOT Boost_FIND_VERSION_PATCH)
748 # We'll set Boost_FOUND true again if we have an exact version match.
749 set(Boost_FOUND FALSE)
750 if(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
751 if(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
752 if(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
753 set( Boost_FOUND TRUE )
754 endif(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
755 endif( Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
756 endif( Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
757 endif (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
760 # State that we found a version of Boost that is too new or too old.
761 set(Boost_ERROR_REASON
762 "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
763 if (Boost_FIND_VERSION_PATCH)
764 set(Boost_ERROR_REASON
765 "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}")
766 endif (Boost_FIND_VERSION_PATCH)
767 if (NOT Boost_FIND_VERSION_EXACT)
768 set(Boost_ERROR_REASON "${Boost_ERROR_REASON} (or newer)")
769 endif (NOT Boost_FIND_VERSION_EXACT)
770 set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.")
771 endif (NOT Boost_FOUND)
774 set(_boost_CHECKED_COMPONENT FALSE)
775 set(_Boost_MISSING_COMPONENTS)
776 foreach(COMPONENT ${Boost_FIND_COMPONENTS})
777 string(TOUPPER ${COMPONENT} COMPONENT)
778 set(_boost_CHECKED_COMPONENT TRUE)
779 if(NOT Boost_${COMPONENT}_FOUND)
780 string(TOLOWER ${COMPONENT} COMPONENT)
781 list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT})
782 set( Boost_FOUND FALSE)
783 endif(NOT Boost_${COMPONENT}_FOUND)
784 endforeach(COMPONENT)
788 message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] Boost_FOUND = ${Boost_FOUND}")
791 if (_Boost_MISSING_COMPONENTS)
792 # We were unable to find some libraries, so generate a sensible
793 # error message that lists the libraries we were unable to find.
794 set(Boost_ERROR_REASON
795 "${Boost_ERROR_REASON}\nThe following Boost libraries could not be found:\n")
796 foreach(COMPONENT ${_Boost_MISSING_COMPONENTS})
797 set(Boost_ERROR_REASON
798 "${Boost_ERROR_REASON} boost_${COMPONENT}\n")
799 endforeach(COMPONENT)
801 list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED)
802 list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS)
803 if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
804 set(Boost_ERROR_REASON
805 "${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.")
806 else (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
807 set(Boost_ERROR_REASON
808 "${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.")
809 endif (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
810 endif (_Boost_MISSING_COMPONENTS)
812 IF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
813 # Compatibility Code for backwards compatibility with CMake
814 # 2.4's FindBoost module.
816 # Look for the boost library path.
817 # Note that the user may not have installed any libraries
818 # so it is quite possible the Boost_LIBRARY_PATH may not exist.
819 SET(_boost_LIB_DIR ${Boost_INCLUDE_DIR})
821 IF("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
822 GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
823 ENDIF ("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
825 IF("${_boost_LIB_DIR}" MATCHES "/include$")
826 # Strip off the trailing "/include" in the path.
827 GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
828 ENDIF("${_boost_LIB_DIR}" MATCHES "/include$")
830 IF(EXISTS "${_boost_LIB_DIR}/lib")
831 SET (_boost_LIB_DIR ${_boost_LIB_DIR}/lib)
832 ELSE(EXISTS "${_boost_LIB_DIR}/lib")
833 IF(EXISTS "${_boost_LIB_DIR}/stage/lib")
834 SET(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib)
835 ELSE(EXISTS "${_boost_LIB_DIR}/stage/lib")
836 SET(_boost_LIB_DIR "")
837 ENDIF(EXISTS "${_boost_LIB_DIR}/stage/lib")
838 ENDIF(EXISTS "${_boost_LIB_DIR}/lib")
840 IF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
841 SET(Boost_LIBRARY_DIRS ${_boost_LIB_DIR} CACHE FILEPATH "Boost library directory")
842 ENDIF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
844 ENDIF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
846 ELSE(Boost_INCLUDE_DIR)
847 SET( Boost_FOUND FALSE)
848 ENDIF(Boost_INCLUDE_DIR)
851 IF (NOT Boost_FIND_QUIETLY)
852 MESSAGE(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
853 ENDIF(NOT Boost_FIND_QUIETLY)
854 IF (NOT Boost_FIND_QUIETLY)
855 MESSAGE(STATUS "Found the following Boost libraries:")
856 ENDIF(NOT Boost_FIND_QUIETLY)
857 FOREACH ( COMPONENT ${Boost_FIND_COMPONENTS} )
858 STRING( TOUPPER ${COMPONENT} UPPERCOMPONENT )
859 IF ( Boost_${UPPERCOMPONENT}_FOUND )
860 IF (NOT Boost_FIND_QUIETLY)
861 MESSAGE (STATUS " ${COMPONENT}")
862 ENDIF(NOT Boost_FIND_QUIETLY)
863 SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${UPPERCOMPONENT}_LIBRARY})
864 ENDIF ( Boost_${UPPERCOMPONENT}_FOUND )
865 ENDFOREACH(COMPONENT)
867 IF (Boost_FIND_REQUIRED)
868 message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")
869 ENDIF(Boost_FIND_REQUIRED)
872 # show the Boost_INCLUDE_DIRS AND Boost_LIBRARIES variables only in the advanced view
873 MARK_AS_ADVANCED(Boost_INCLUDE_DIR
877 ENDIF(_boost_IN_CACHE)