1 # - Try to find Boost include dirs and libraries
2 # Usage of this module as follows:
4 # SET(Boost_USE_STATIC_LIBS ON)
5 # SET(Boost_USE_MULTITHREAD OFF)
6 # FIND_PACKAGE( Boost 1.34.1 COMPONENTS date_time filesystem iostreams ... )
8 # The Boost_ADDITIONAL_VERSIONS variable can be used to specify a list of
9 # boost version numbers that should be taken into account when searching
10 # for the libraries. Unfortunately boost puts the version number into the
11 # actual filename for the libraries, so this might be needed in the future
12 # when new Boost versions are released.
14 # Currently this module searches for the following version numbers:
15 # 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,
18 # The components list needs to be the actual names of boost libraries, that is
19 # the part of the actual library files that differ on different libraries. So
20 # its "date_time" for "libboost_date_time...". Anything else will result in
23 # You can provide a minimum version number that should be used. If you provide this
24 # version number and specify the REQUIRED attribute, this module will fail if it
25 # can't find the specified or a later version. If you specify a version number this is
26 # automatically put into the considered list of version numbers and thus doesn't need
27 # to be specified in the Boost_ADDITIONAL_VERSIONS variable
29 # Variables used by this module, they can change the default behaviour and need to be set
30 # before calling find_package:
31 # Boost_USE_MULTITHREAD Can be set to OFF to use the non-multithreaded
32 # boost libraries. Defaults to ON.
33 # Boost_USE_STATIC_LIBS Can be set to ON to force the use of the static
34 # boost libraries. Defaults to OFF.
35 # Boost_ADDITIONAL_VERSIONS A list of version numbers to use for searching
36 # the boost include directory. The default list
37 # of version numbers is:
38 # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1,
39 # 1.35, 1.35.0, 1.35.1, 1.36, 1.36.0, 1.36.1
40 # If you want to look for an older or newer
41 # version set this variable to a list of
42 # strings, where each string contains a number, i.e.
43 # SET(Boost_ADDITIONAL_VERSIONS "0.99.0" "1.35.0")
44 # BOOST_ROOT or BOOSTROOT Preferred installation prefix for searching for Boost,
45 # set this if the module has problems finding the proper Boost installation
46 # BOOST_INCLUDEDIR Set this to the include directory of Boost, if the
47 # module has problems finding the proper Boost installation
48 # BOOST_LIBRARYDIR Set this to the lib directory of Boost, if the
49 # module has problems finding the proper Boost installation
51 # The last three variables are available also as environment variables
54 # Variables defined by this module:
56 # Boost_FOUND System has Boost, this means the include dir was found,
57 # as well as all the libraries specified in the COMPONENTS list
58 # Boost_INCLUDE_DIRS Boost include directories, not cached
59 # Boost_INCLUDE_DIR This is almost the same as above, but this one is cached and may be
60 # modified by advanced users
61 # Boost_LIBRARIES Link these to use the Boost libraries that you specified, not cached
62 # Boost_LIBRARY_DIRS The path to where the Boost library files are.
63 # Boost_VERSION The version number of the boost libraries that have been found,
64 # same as in version.hpp from Boost
65 # Boost_LIB_VERSION The version number in filename form as its appended to the library filenames
66 # Boost_MAJOR_VERSION major version number of boost
67 # Boost_MINOR_VERSION minor version number of boost
68 # Boost_SUBMINOR_VERSION subminor version number of boost
69 # Boost_LIB_DIAGNOSTIC_DEFINITIONS Only set on windows. Can be used with add_definitions
70 # to print diagnostic information about the automatic
71 # linking done on windows.
73 # For each component you list the following variables are set.
74 # ATTENTION: The component names need to be in lower case, just as the boost
75 # library names however the cmake variables use upper case for the component
76 # part. So you'd get Boost_SERIALIZATION_FOUND for example.
78 # Boost_${COMPONENT}_FOUND True IF the Boost library "component" was found.
79 # Boost_${COMPONENT}_LIBRARY The absolute path of the Boost library "component".
80 # Boost_${COMPONENT}_LIBRARY_DEBUG The absolute path of the debug version of the
81 # Boost library "component".
82 # Boost_${COMPONENT}_LIBRARY_RELEASE The absolute path of the release version of the
83 # Boost library "component"
85 # Copyright (c) 2006-2008 Andreas Schneider <mail@cynapses.org>
86 # Copyright (c) 2007 Wengo
87 # Copyright (c) 2007 Mike Jackson
88 # Copyright (c) 2008 Andreas Pakulat <apaku@gmx.de>
90 # Redistribution AND use is allowed according to the terms of the New
92 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
94 OPTION(Boost_USE_MULTITHREADED
95 "Use the multithreaded versions of the Boost libraries" ON)
97 if (Boost_FIND_VERSION_EXACT)
98 if (Boost_FIND_VERSION_PATCH)
99 set( _boost_TEST_VERSIONS
100 "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.${Boost_FIND_VERSION_PATCH}")
101 else (Boost_FIND_VERSION_PATCH)
102 set( _boost_TEST_VERSIONS
103 "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.0"
104 "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
105 endif (Boost_FIND_VERSION_PATCH)
106 else (Boost_FIND_VERSION_EXACT)
107 set( _boost_TEST_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
108 "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0"
109 "1.34" "1.33.1" "1.33.0" "1.33" )
110 endif (Boost_FIND_VERSION_EXACT)
112 # The reason that we failed to find Boost. This will be set to a
113 # user-friendly message when we fail to find some necessary piece of
115 set(Boost_ERROR_REASON)
117 ############################################
119 # Check the existence of the libraries.
121 ############################################
122 # This macro was taken directly from the FindQt4.cmake file that is included
123 # with the CMake distribution. This is NOT my work. All work was done by the
124 # original authors of the FindQt4.cmake file. Only minor modifications were
125 # made to remove references to Qt and make this file more generally applicable
126 #########################################################################
128 MACRO (_Boost_ADJUST_LIB_VARS basename)
129 IF (Boost_INCLUDE_DIR )
130 IF (Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
131 # if the generator supports configuration types then set
132 # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
133 IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
134 SET(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
135 ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
136 # if there are no configuration types and CMAKE_BUILD_TYPE has no value
137 # then just use the release libraries
138 SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
139 ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
140 SET(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
141 ENDIF (Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
143 # if only the release version was found, set the debug variable also to the release version
144 IF (Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG)
145 SET(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE})
146 SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE})
147 SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE})
148 ENDIF (Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG)
150 # if only the debug version was found, set the release variable also to the debug version
151 IF (Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE)
152 SET(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG})
153 SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG})
154 SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG})
155 ENDIF (Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE)
157 IF (Boost_${basename}_LIBRARY)
158 SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library")
159 GET_FILENAME_COMPONENT(Boost_LIBRARY_DIRS "${Boost_${basename}_LIBRARY}" PATH)
160 SET(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS} CACHE FILEPATH "Boost library directory")
161 SET(Boost_${basename}_FOUND ON CACHE INTERNAL "Whether the Boost ${basename} library found")
162 ENDIF (Boost_${basename}_LIBRARY)
164 ENDIF (Boost_INCLUDE_DIR )
165 # Make variables changeble to the advanced user
167 Boost_${basename}_LIBRARY
168 Boost_${basename}_LIBRARY_RELEASE
169 Boost_${basename}_LIBRARY_DEBUG
171 ENDMACRO (_Boost_ADJUST_LIB_VARS)
173 #-------------------------------------------------------------------------------
176 SET( _boost_IN_CACHE TRUE)
177 IF(Boost_INCLUDE_DIR)
178 FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
179 STRING(TOUPPER ${COMPONENT} COMPONENT)
180 IF(NOT Boost_${COMPONENT}_FOUND)
181 SET( _boost_IN_CACHE FALSE)
182 ENDIF(NOT Boost_${COMPONENT}_FOUND)
183 ENDFOREACH(COMPONENT)
184 ELSE(Boost_INCLUDE_DIR)
185 SET( _boost_IN_CACHE FALSE)
186 ENDIF(Boost_INCLUDE_DIR)
190 SET(Boost_FOUND TRUE)
191 FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
192 STRING(TOUPPER ${COMPONENT} COMPONENT)
193 _Boost_ADJUST_LIB_VARS( ${COMPONENT} )
194 SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${COMPONENT}_LIBRARY})
195 ENDFOREACH(COMPONENT)
196 SET(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
197 IF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
198 MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
199 MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
200 MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
201 ENDIF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
202 ELSE (_boost_IN_CACHE)
203 # Need to search for boost
206 # In windows, automatic linking is performed, so you do not have
207 # to specify the libraries. If you are linking to a dynamic
208 # runtime, then you can choose to link to either a static or a
209 # dynamic Boost library, the default is to do a static link. You
210 # can alter this for a specific library "whatever" by defining
211 # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be
212 # linked dynamically. Alternatively you can force all Boost
213 # libraries to dynamic link by defining BOOST_ALL_DYN_LINK.
215 # This feature can be disabled for Boost library "whatever" by
216 # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining
219 # If you want to observe which libraries are being linked against
220 # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking
221 # code to emit a #pragma message each time a library is selected
223 SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS
224 "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define")
227 SET(_boost_INCLUDE_SEARCH_DIRS
230 "$ENV{ProgramFiles}/boost/boost_${Boost_FIND_VERSION_MAJOR}_${Boost_FIND_VERSION_MINOR}_${Boost_FIND_VERSION_PATCH}"
231 "$ENV{ProgramFiles}/Boost"
235 SET(_boost_LIBRARIES_SEARCH_DIRS
238 "$ENV{ProgramFiles}/boost/boost_${Boost_FIND_VERSION_MAJOR}_${Boost_FIND_VERSION_MINOR}_${Boost_FIND_VERSION_PATCH}/lib"
239 "$ENV{ProgramFiles}/Boost"
243 # If BOOST_ROOT was defined in the environment, use it.
244 if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
245 set(BOOST_ROOT $ENV{BOOST_ROOT})
246 endif(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
248 # If BOOSTROOT was defined in the environment, use it.
249 if (NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
250 set(BOOST_ROOT $ENV{BOOSTROOT})
251 endif(NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
253 # If BOOST_INCLUDEDIR was defined in the environment, use it.
254 IF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
255 set(BOOST_INCLUDEDIR $ENV{BOOST_INCLUDEDIR})
256 ENDIF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
258 # If BOOST_LIBRARYDIR was defined in the environment, use it.
259 IF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
260 set(BOOST_LIBRARYDIR $ENV{BOOST_LIBRARYDIR})
261 ENDIF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
264 file(TO_CMAKE_PATH ${BOOST_ROOT} BOOST_ROOT)
265 SET(_boost_INCLUDE_SEARCH_DIRS
266 ${BOOST_ROOT}/include
268 ${_boost_INCLUDE_SEARCH_DIRS})
269 SET(_boost_LIBRARIES_SEARCH_DIRS
271 ${BOOST_ROOT}/stage/lib
272 ${_boost_LIBRARIES_SEARCH_DIRS})
275 IF( BOOST_INCLUDEDIR )
276 file(TO_CMAKE_PATH ${BOOST_INCLUDEDIR} BOOST_INCLUDEDIR)
277 SET(_boost_INCLUDE_SEARCH_DIRS
278 ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS})
279 ENDIF( BOOST_INCLUDEDIR )
281 IF( BOOST_LIBRARYDIR )
282 file(TO_CMAKE_PATH ${BOOST_LIBRARYDIR} BOOST_LIBRARYDIR)
283 SET(_boost_LIBRARIES_SEARCH_DIRS
284 ${BOOST_LIBRARYDIR} ${_boost_LIBRARIES_SEARCH_DIRS})
285 ENDIF( BOOST_LIBRARYDIR )
287 # Try to find Boost by stepping backwards through the Boost versions
289 IF( NOT Boost_INCLUDE_DIR )
290 # Build a list of path suffixes for each version.
291 SET(_boost_PATH_SUFFIXES)
292 FOREACH(_boost_VER ${_boost_TEST_VERSIONS})
293 # Add in a path suffix, based on the required version, ideally
294 # we could read this from version.hpp, but for that to work we'd
295 # need to know the include dir already
296 if (WIN32 AND NOT CYGWIN)
297 set(_boost_PATH_SUFFIX boost_${_boost_VER})
298 else (WIN32 AND NOT CYGWIN)
299 set(_boost_PATH_SUFFIX boost-${_boost_VER})
300 endif (WIN32 AND NOT CYGWIN)
302 IF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
303 STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3"
304 _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX})
305 ELSEIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+")
306 STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2"
307 _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX})
308 ENDIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
309 LIST(APPEND _boost_PATH_SUFFIXES "${_boost_PATH_SUFFIX}")
310 ENDFOREACH(_boost_VER)
312 # Look for a standard boost header file.
313 FIND_PATH(Boost_INCLUDE_DIR
314 NAMES boost/config.hpp
315 HINTS ${_boost_INCLUDE_SEARCH_DIRS}
316 PATH_SUFFIXES ${_boost_PATH_SUFFIXES}
318 ENDIF( NOT Boost_INCLUDE_DIR )
320 IF(Boost_INCLUDE_DIR)
321 # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp
322 # Read the whole file:
325 SET(BOOST_LIB_VERSION "")
326 FILE(READ "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS)
328 STRING(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}")
329 STRING(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}")
331 SET(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE INTERNAL "The library version string for boost libraries")
332 SET(Boost_VERSION ${Boost_VERSION} CACHE INTERNAL "The version number for boost libraries")
334 IF(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")
339 set(Boost_ERROR_REASON
340 "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}")
341 ENDIF(NOT "${Boost_VERSION}" STREQUAL "0")
342 ELSE(Boost_INCLUDE_DIR)
343 set(Boost_ERROR_REASON
344 "${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.")
345 ENDIF(Boost_INCLUDE_DIR)
347 # Setting some more suffixes for the library
348 SET (Boost_LIB_PREFIX "")
349 IF ( WIN32 AND Boost_USE_STATIC_LIBS )
350 SET (Boost_LIB_PREFIX "lib")
351 ENDIF ( WIN32 AND Boost_USE_STATIC_LIBS )
352 SET (_boost_COMPILER "-gcc")
354 SET (_boost_COMPILER "-vc90")
356 SET (_boost_COMPILER "-vc80")
358 SET (_boost_COMPILER "-vc71")
361 EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
363 OUTPUT_VARIABLE _boost_COMPILER_VERSION
365 STRING(REGEX REPLACE "([0-9])\\.([0-9])\\.[0-9]" "\\1\\2"
366 _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
367 SET (_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}")
370 IF (NOT CMAKE_COMPILER_IS_GNUCC)
371 # We assume that we have the Intel compiler.
372 SET (_boost_COMPILER "-il")
373 ELSE (NOT CMAKE_COMPILER_IS_GNUCC)
374 # Determine which version of GCC we have.
375 EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
377 OUTPUT_VARIABLE _boost_COMPILER_VERSION
379 STRING(REGEX REPLACE "([0-9])\\.([0-9])\\.[0-9]" "\\1\\2"
380 _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
382 IF(Boost_MINOR_VERSION)
383 IF(${Boost_MINOR_VERSION} GREATER 35)
384 # In Boost 1.36.0 and newer, the mangled compiler name used
385 # on Mac OS X/Darwin is "xgcc".
386 SET(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}")
387 ELSE(${Boost_MINOR_VERSION} GREATER 35)
388 # In Boost <= 1.35.0, there is no mangled compiler name for
389 # the Mac OS X/Darwin version of GCC.
390 SET(_boost_COMPILER "")
391 ENDIF(${Boost_MINOR_VERSION} GREATER 35)
392 ELSE(Boost_MINOR_VERSION)
393 # We don't know the Boost version, so assume it's
395 SET(_boost_COMPILER "")
396 ENDIF(Boost_MINOR_VERSION)
398 SET (_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}")
400 ENDIF (NOT CMAKE_COMPILER_IS_GNUCC)
403 SET (_boost_MULTITHREADED "-mt")
405 IF( NOT Boost_USE_MULTITHREADED )
406 SET (_boost_MULTITHREADED "")
407 ENDIF( NOT Boost_USE_MULTITHREADED )
409 SET( _boost_STATIC_TAG "")
412 SET (_boost_ABI_TAG "g")
414 IF( Boost_USE_STATIC_LIBS )
415 SET( _boost_STATIC_TAG "-s")
416 ENDIF( Boost_USE_STATIC_LIBS )
418 SET (_boost_ABI_TAG "${_boost_ABI_TAG}d")
420 # ------------------------------------------------------------------------
421 # Begin finding boost libraries
422 # ------------------------------------------------------------------------
423 FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
424 STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
425 SET( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" )
426 SET( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" )
427 SET( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND")
429 # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
430 IF( Boost_USE_STATIC_LIBS )
431 SET( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
433 SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
435 SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
437 ENDIF( Boost_USE_STATIC_LIBS )
439 FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE
440 NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${Boost_LIB_VERSION}
441 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION}
442 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}
443 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}
444 ${Boost_LIB_PREFIX}boost_${COMPONENT}
445 HINTS ${_boost_LIBRARIES_SEARCH_DIRS}
448 FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG
449 NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION}
450 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION}
451 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}
452 ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}
453 ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_boost_ABI_TAG}
454 HINTS ${_boost_LIBRARIES_SEARCH_DIRS}
457 _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT})
458 IF( Boost_USE_STATIC_LIBS )
459 SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
460 ENDIF( Boost_USE_STATIC_LIBS )
461 ENDFOREACH(COMPONENT)
462 # ------------------------------------------------------------------------
463 # End finding boost libraries
464 # ------------------------------------------------------------------------
466 SET(Boost_INCLUDE_DIRS
470 SET(Boost_FOUND FALSE)
471 IF(Boost_INCLUDE_DIR)
472 SET( Boost_FOUND TRUE )
474 # Check the version of Boost against the requested version.
475 if (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
476 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")
477 endif (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
478 if(Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
479 set( Boost_FOUND FALSE )
480 set(_Boost_VERSION_AGE "old")
481 elseif(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
482 if(Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
483 set( Boost_FOUND FALSE )
484 set(_Boost_VERSION_AGE "old")
485 elseif(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
486 if( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
487 set( Boost_FOUND FALSE )
488 set(_Boost_VERSION_AGE "old")
489 endif( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
490 endif( Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
491 endif( Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
493 if (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
494 # If the user requested an exact version of Boost, check
495 # that. We already know that the Boost version we have is >= the
497 set(_Boost_VERSION_AGE "new")
499 # If the user didn't specify a patchlevel, it's 0.
500 if (NOT Boost_FIND_VERSION_PATCH)
501 set(Boost_FIND_VERSION_PATCH 0)
502 endif (NOT Boost_FIND_VERSION_PATCH)
504 # We'll set Boost_FOUND true again if we have an exact version match.
505 set(Boost_FOUND FALSE)
506 if(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
507 if(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
508 if(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
509 set( Boost_FOUND TRUE )
510 endif(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
511 endif( Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
512 endif( Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
513 endif (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
516 # State that we found a version of Boost that is too new or too old.
517 set(Boost_ERROR_REASON
518 "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
519 if (Boost_FIND_VERSION_PATCH)
520 set(Boost_ERROR_REASON
521 "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}")
522 endif (Boost_FIND_VERSION_PATCH)
523 if (NOT Boost_FIND_VERSION_EXACT)
524 set(Boost_ERROR_REASON "${Boost_ERROR_REASON} (or newer)")
525 endif (NOT Boost_FIND_VERSION_EXACT)
526 set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.")
527 endif (NOT Boost_FOUND)
530 set(_boost_CHECKED_COMPONENT FALSE)
531 set(_Boost_MISSING_COMPONENTS)
532 foreach(COMPONENT ${Boost_FIND_COMPONENTS})
533 string(TOUPPER ${COMPONENT} COMPONENT)
534 set(_boost_CHECKED_COMPONENT TRUE)
535 if(NOT Boost_${COMPONENT}_FOUND)
536 string(TOLOWER ${COMPONENT} COMPONENT)
537 list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT})
538 set( Boost_FOUND FALSE)
539 endif(NOT Boost_${COMPONENT}_FOUND)
540 endforeach(COMPONENT)
543 if (_Boost_MISSING_COMPONENTS)
544 # We were unable to find some libraries, so generate a sensible
545 # error message that lists the libraries we were unable to find.
546 set(Boost_ERROR_REASON
547 "${Boost_ERROR_REASON}\nThe following Boost libraries could not be found:\n")
548 foreach(COMPONENT ${_Boost_MISSING_COMPONENTS})
549 set(Boost_ERROR_REASON
550 "${Boost_ERROR_REASON} boost_${COMPONENT}\n")
551 endforeach(COMPONENT)
553 list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED)
554 list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS)
555 if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
556 set(Boost_ERROR_REASON
557 "${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.")
558 else (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
559 set(Boost_ERROR_REASON
560 "${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.")
561 endif (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
562 endif (_Boost_MISSING_COMPONENTS)
564 IF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
565 # Compatibility Code for backwards compatibility with CMake
566 # 2.4's FindBoost module.
568 # Look for the boost library path.
569 # Note that the user may not have installed any libraries
570 # so it is quite possible the Boost_LIBRARY_PATH may not exist.
571 SET(_boost_LIB_DIR ${Boost_INCLUDE_DIR})
573 IF("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
574 GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
575 ENDIF ("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
577 IF("${_boost_LIB_DIR}" MATCHES "/include$")
578 # Strip off the trailing "/include" in the path.
579 GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
580 ENDIF("${_boost_LIB_DIR}" MATCHES "/include$")
582 IF(EXISTS "${_boost_LIB_DIR}/lib")
583 SET (_boost_LIB_DIR ${_boost_LIB_DIR}/lib)
584 ELSE(EXISTS "${_boost_LIB_DIR}/lib")
585 IF(EXISTS "${_boost_LIB_DIR}/stage/lib")
586 SET(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib)
587 ELSE(EXISTS "${_boost_LIB_DIR}/stage/lib")
588 SET(_boost_LIB_DIR "")
589 ENDIF(EXISTS "${_boost_LIB_DIR}/stage/lib")
590 ENDIF(EXISTS "${_boost_LIB_DIR}/lib")
592 IF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
593 SET(Boost_LIBRARY_DIRS ${_boost_LIB_DIR} CACHE FILEPATH "Boost library directory")
594 ENDIF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
596 ENDIF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
598 ELSE(Boost_INCLUDE_DIR)
599 SET( Boost_FOUND FALSE)
600 ENDIF(Boost_INCLUDE_DIR)
603 IF (NOT Boost_FIND_QUIETLY)
604 MESSAGE(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
605 ENDIF(NOT Boost_FIND_QUIETLY)
606 IF (NOT Boost_FIND_QUIETLY)
607 MESSAGE(STATUS "Found the following Boost libraries:")
608 ENDIF(NOT Boost_FIND_QUIETLY)
609 FOREACH ( COMPONENT ${Boost_FIND_COMPONENTS} )
610 STRING( TOUPPER ${COMPONENT} UPPERCOMPONENT )
611 IF ( Boost_${UPPERCOMPONENT}_FOUND )
612 IF (NOT Boost_FIND_QUIETLY)
613 MESSAGE (STATUS " ${COMPONENT}")
614 ENDIF(NOT Boost_FIND_QUIETLY)
615 SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${UPPERCOMPONENT}_LIBRARY})
616 ENDIF ( Boost_${UPPERCOMPONENT}_FOUND )
617 ENDFOREACH(COMPONENT)
619 IF (Boost_FIND_REQUIRED)
620 message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")
621 ENDIF(Boost_FIND_REQUIRED)
624 # Under Windows, automatic linking is performed, so no need to specify the libraries.
627 SET(Boost_LIBRARIES "")
631 # show the Boost_INCLUDE_DIRS AND Boost_LIBRARIES variables only in the advanced view
632 MARK_AS_ADVANCED(Boost_INCLUDE_DIR
635 Boost_USE_MULTITHREADED
637 ENDIF(_boost_IN_CACHE)