FindBoost.cmake 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153
  1. # - Try to find Boost include dirs and libraries
  2. # Usage of this module as follows:
  3. #
  4. # NOTE: Take note of the Boost_ADDITIONAL_VERSIONS variable below.
  5. # Due to Boost naming conventions and limitations in CMake this find
  6. # module is NOT future safe with respect to Boost version numbers,
  7. # and may break.
  8. #
  9. # == Using Header-Only libraries from within Boost: ==
  10. #
  11. # find_package( Boost 1.36.0 )
  12. # if(Boost_FOUND)
  13. # include_directories(${Boost_INCLUDE_DIRS})
  14. # add_executable(foo foo.cc)
  15. # endif()
  16. #
  17. #
  18. # == Using actual libraries from within Boost: ==
  19. #
  20. # set(Boost_USE_STATIC_LIBS ON)
  21. # set(Boost_USE_MULTITHREADED ON)
  22. # set(Boost_USE_STATIC_RUNTIME OFF)
  23. # set(Boost_COMPAT_STATIC_RUNTIME OFF)
  24. # find_package( Boost 1.36.0 COMPONENTS date_time filesystem system ... )
  25. #
  26. # if(Boost_FOUND)
  27. # include_directories(${Boost_INCLUDE_DIRS})
  28. # add_executable(foo foo.cc)
  29. # target_link_libraries(foo ${Boost_LIBRARIES})
  30. # endif()
  31. #
  32. #
  33. # The components list needs to contain actual names of boost libraries only,
  34. # such as "date_time" for "libboost_date_time". If you're using parts of
  35. # Boost that contain header files only (e.g. foreach) you do not need to
  36. # specify COMPONENTS.
  37. #
  38. # You should provide a minimum version number that should be used. If you provide this
  39. # version number and specify the REQUIRED attribute, this module will fail if it
  40. # can't find the specified or a later version. If you specify a version number this is
  41. # automatically put into the considered list of version numbers and thus doesn't need
  42. # to be specified in the Boost_ADDITIONAL_VERSIONS variable (see below).
  43. #
  44. # NOTE for Visual Studio Users:
  45. # Automatic linking is used on MSVC & Borland compilers by default when
  46. # #including things in Boost. It's important to note that setting
  47. # Boost_USE_STATIC_LIBS to OFF is NOT enough to get you dynamic linking,
  48. # should you need this feature. Automatic linking typically uses static
  49. # libraries with a few exceptions (Boost.Python is one).
  50. #
  51. # Please see the section below near Boost_LIB_DIAGNOSTIC_DEFINITIONS for
  52. # more details. Adding a TARGET_LINK_LIBRARIES() as shown in the example
  53. # above appears to cause VS to link dynamically if Boost_USE_STATIC_LIBS
  54. # gets set to OFF. It is suggested you avoid automatic linking since it
  55. # will make your application less portable.
  56. #
  57. # =========== The mess that is Boost_ADDITIONAL_VERSIONS (sorry?) ============
  58. #
  59. # OK, so the Boost_ADDITIONAL_VERSIONS variable can be used to specify a list of
  60. # boost version numbers that should be taken into account when searching
  61. # for Boost. Unfortunately boost puts the version number into the
  62. # actual filename for the libraries, so this variable will certainly be needed
  63. # in the future when new Boost versions are released.
  64. #
  65. # Currently this module searches for the following version numbers:
  66. # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1,
  67. # 1.36, 1.36.0, 1.36.1, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0,
  68. # 1.40, 1.40.0, 1.41, 1.41.0, 1.42, 1.42.0, 1.43, 1.43.0, 1.44, 1.44.0
  69. #
  70. # NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should
  71. # add both 1.x and 1.x.0 as shown above. Official Boost include directories
  72. # omit the 3rd version number from include paths if it is 0 although not all
  73. # binary Boost releases do so.
  74. #
  75. # SET(Boost_ADDITIONAL_VERSIONS "1.78" "1.78.0" "1.79" "1.79.0")
  76. #
  77. # ===================================== ============= ========================
  78. #
  79. # Variables used by this module, they can change the default behaviour and
  80. # need to be set before calling find_package:
  81. #
  82. # Boost_USE_MULTITHREADED Can be set to OFF to use the non-multithreaded
  83. # boost libraries. If not specified, defaults
  84. # to ON.
  85. #
  86. # Boost_USE_STATIC_LIBS Can be set to ON to force the use of the static
  87. # boost libraries. Defaults to OFF.
  88. #
  89. # Boost_NO_SYSTEM_PATHS Set to TRUE to suppress searching in system
  90. # paths (or other locations outside of BOOST_ROOT
  91. # or BOOST_INCLUDEDIR). Useful when specifying
  92. # BOOST_ROOT. Defaults to OFF.
  93. # [Since CMake 2.8.3]
  94. #
  95. # Boost_USE_STATIC_RUNTIME If enabled, searches for boost libraries
  96. # linked against a static C++ standard library
  97. # ('s' ABI tag). Defaults to OFF.
  98. # [Since CMake 2.8.3]
  99. #
  100. # Boost_USE_DEBUG_PYTHON If enabled, searches for boost libraries
  101. # compiled against a special debug build of
  102. # Python ('y' ABI tag). Defaults to OFF.
  103. # [Since CMake 2.8.3]
  104. #
  105. # Boost_USE_STLPORT If enabled, searches for boost libraries
  106. # compiled against the STLPort standard
  107. # library ('p' ABI tag). Defaults to OFF.
  108. # [Since CMake 2.8.3]
  109. #
  110. # Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS
  111. # If enabled, searches for boost libraries
  112. # compiled against the deprecated STLPort
  113. # "native iostreams" feature ('n' ABI tag).
  114. # Defaults to OFF.
  115. # [Since CMake 2.8.3]
  116. #
  117. # Boost_COMPAT_STATIC_RUNTIME Set to OFF to disable backwards compatible
  118. # searching for libraries with the 's' ABI
  119. # tag on WIN32 after normal searches. You
  120. # should set this to OFF and also set
  121. # Boost_USE_STATIC_RUNTIME appropriately.
  122. # If not specified, defaults to ON.
  123. # [Since CMake 2.8.3]
  124. #
  125. # Other Variables used by this module which you may want to set.
  126. #
  127. # Boost_ADDITIONAL_VERSIONS A list of version numbers to use for searching
  128. # the boost include directory. Please see
  129. # the documentation above regarding this
  130. # annoying, but necessary variable :(
  131. #
  132. # Boost_DEBUG Set this to TRUE to enable debugging output
  133. # of FindBoost.cmake if you are having problems.
  134. # Please enable this before filing any bug
  135. # reports.
  136. #
  137. # Boost_DETAILED_FAILURE_MSG FindBoost doesn't output detailed information
  138. # about why it failed or how to fix the problem
  139. # unless this is set to TRUE or the REQUIRED
  140. # keyword is specified in find_package().
  141. # [Since CMake 2.8.0]
  142. #
  143. # Boost_COMPILER Set this to the compiler suffix used by Boost
  144. # (e.g. "-gcc43") if FindBoost has problems finding
  145. # the proper Boost installation
  146. #
  147. # Boost_THREADAPI When building boost.thread, sometimes the name of the
  148. # library contains an additional "pthread" or "win32"
  149. # string known as the threadapi. This can happen when
  150. # compiling against pthreads on Windows or win32 threads
  151. # on Cygwin. You may specify this variable and if set
  152. # when FindBoost searches for the Boost threading library
  153. # it will first try to match the threadapi you specify.
  154. # For Example: libboost_thread_win32-mgw45-mt-1_43.a
  155. # might be found if you specified "win32" here before
  156. # falling back on libboost_thread-mgw45-mt-1_43.a.
  157. # [Since CMake 2.8.3]
  158. #
  159. # Boost_REALPATH Resolves symbolic links for discovered boost libraries
  160. # to assist with packaging. For example, instead of
  161. # Boost_SYSTEM_LIBRARY_RELEASE being resolved to
  162. # "/usr/lib/libboost_system.so" it would be
  163. # "/usr/lib/libboost_system.so.1.42.0" instead.
  164. # This does not affect linking and should not be
  165. # enabled unless the user needs this information.
  166. # [Since CMake 2.8.3]
  167. #
  168. #
  169. # These last three variables are available also as environment variables:
  170. #
  171. # BOOST_ROOT or BOOSTROOT The preferred installation prefix for searching for
  172. # Boost. Set this if the module has problems finding
  173. # the proper Boost installation. To prevent falling
  174. # back on the system paths, set Boost_NO_SYSTEM_PATHS
  175. # to true.
  176. #
  177. # BOOST_INCLUDEDIR Set this to the include directory of Boost, if the
  178. # module has problems finding the proper Boost installation
  179. #
  180. # BOOST_LIBRARYDIR Set this to the lib directory of Boost, if the
  181. # module has problems finding the proper Boost installation
  182. #
  183. # Variables defined by this module:
  184. #
  185. # Boost_FOUND System has Boost, this means the include dir was
  186. # found, as well as all the libraries specified in
  187. # the COMPONENTS list.
  188. #
  189. # Boost_INCLUDE_DIRS Boost include directories: not cached
  190. #
  191. # Boost_INCLUDE_DIR This is almost the same as above, but this one is
  192. # cached and may be modified by advanced users
  193. #
  194. # Boost_LIBRARIES Link to these to use the Boost libraries that you
  195. # specified: not cached
  196. #
  197. # Boost_LIBRARY_DIRS The path to where the Boost library files are.
  198. #
  199. # Boost_VERSION The version number of the boost libraries that
  200. # have been found, same as in version.hpp from Boost
  201. #
  202. # Boost_LIB_VERSION The version number in filename form as
  203. # it's appended to the library filenames
  204. #
  205. # Boost_MAJOR_VERSION major version number of boost
  206. # Boost_MINOR_VERSION minor version number of boost
  207. # Boost_SUBMINOR_VERSION subminor version number of boost
  208. #
  209. # Boost_LIB_DIAGNOSTIC_DEFINITIONS [WIN32 Only] You can call
  210. # add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
  211. # to have diagnostic information about Boost's
  212. # automatic linking outputted during compilation time.
  213. #
  214. # For each component you specify in find_package(), the following (UPPER-CASE)
  215. # variables are set. You can use these variables if you would like to pick and
  216. # choose components for your targets instead of just using Boost_LIBRARIES.
  217. #
  218. # Boost_${COMPONENT}_FOUND True IF the Boost library "component" was found.
  219. #
  220. # Boost_${COMPONENT}_LIBRARY Contains the libraries for the specified Boost
  221. # "component" (includes debug and optimized keywords
  222. # when needed).
  223. #=============================================================================
  224. # Copyright 2006-2009 Kitware, Inc.
  225. # Copyright 2006-2008 Andreas Schneider <[email protected]>
  226. # Copyright 2007 Wengo
  227. # Copyright 2007 Mike Jackson
  228. # Copyright 2008 Andreas Pakulat <[email protected]>
  229. # Copyright 2008-2010 Philip Lowman <[email protected]>
  230. #
  231. # Distributed under the OSI-approved BSD License (the "License");
  232. # see accompanying file Copyright.txt for details.
  233. #
  234. # This software is distributed WITHOUT ANY WARRANTY; without even the
  235. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  236. # See the License for more information.
  237. #=============================================================================
  238. # (To distribute this file outside of CMake, substitute the full
  239. # License text for the above reference.)
  240. #-------------------------------------------------------------------------------
  241. # FindBoost functions & macros
  242. #
  243. ############################################
  244. #
  245. # Check the existence of the libraries.
  246. #
  247. ############################################
  248. # This macro was taken directly from the FindQt4.cmake file that is included
  249. # with the CMake distribution. This is NOT my work. All work was done by the
  250. # original authors of the FindQt4.cmake file. Only minor modifications were
  251. # made to remove references to Qt and make this file more generally applicable
  252. # And ELSE/ENDIF pairs were removed for readability.
  253. #########################################################################
  254. MACRO (_Boost_ADJUST_LIB_VARS basename)
  255. IF (Boost_INCLUDE_DIR )
  256. IF (Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
  257. # if the generator supports configuration types then set
  258. # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
  259. IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
  260. SET(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
  261. ELSE()
  262. # if there are no configuration types and CMAKE_BUILD_TYPE has no value
  263. # then just use the release libraries
  264. SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
  265. ENDIF()
  266. # FIXME: This probably should be set for both cases
  267. SET(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
  268. ENDIF()
  269. # if only the release version was found, set the debug variable also to the release version
  270. IF (Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG)
  271. SET(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE})
  272. SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE})
  273. SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE})
  274. ENDIF()
  275. # if only the debug version was found, set the release variable also to the debug version
  276. IF (Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE)
  277. SET(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG})
  278. SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG})
  279. SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG})
  280. ENDIF()
  281. IF (Boost_${basename}_LIBRARY)
  282. set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library")
  283. # Remove superfluous "debug" / "optimized" keywords from
  284. # Boost_LIBRARY_DIRS
  285. FOREACH(_boost_my_lib ${Boost_${basename}_LIBRARY})
  286. GET_FILENAME_COMPONENT(_boost_my_lib_path "${_boost_my_lib}" PATH)
  287. LIST(APPEND Boost_LIBRARY_DIRS ${_boost_my_lib_path})
  288. ENDFOREACH()
  289. LIST(REMOVE_DUPLICATES Boost_LIBRARY_DIRS)
  290. set(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS} CACHE FILEPATH "Boost library directory")
  291. SET(Boost_${basename}_FOUND ON CACHE INTERNAL "Whether the Boost ${basename} library found")
  292. ENDIF(Boost_${basename}_LIBRARY)
  293. ENDIF (Boost_INCLUDE_DIR )
  294. # Make variables changeble to the advanced user
  295. MARK_AS_ADVANCED(
  296. Boost_${basename}_LIBRARY
  297. Boost_${basename}_LIBRARY_RELEASE
  298. Boost_${basename}_LIBRARY_DEBUG
  299. )
  300. ENDMACRO (_Boost_ADJUST_LIB_VARS)
  301. #-------------------------------------------------------------------------------
  302. #
  303. # Runs compiler with "-dumpversion" and parses major/minor
  304. # version with a regex.
  305. #
  306. FUNCTION(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION)
  307. EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
  308. ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
  309. OUTPUT_VARIABLE _boost_COMPILER_VERSION
  310. )
  311. STRING(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
  312. _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
  313. SET(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE)
  314. ENDFUNCTION()
  315. #
  316. # A convenience function for marking desired components
  317. # as found or not
  318. #
  319. function(_Boost_MARK_COMPONENTS_FOUND _yes_or_no)
  320. foreach(COMPONENT ${Boost_FIND_COMPONENTS})
  321. string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  322. set(Boost_${UPPERCOMPONENT}_FOUND ${_yes_or_no} CACHE INTERNAL "Whether the Boost ${COMPONENT} library found" FORCE)
  323. endforeach()
  324. endfunction()
  325. #
  326. # Take a list of libraries with "thread" in it
  327. # and prepend duplicates with "thread_${Boost_THREADAPI}"
  328. # at the front of the list
  329. #
  330. function(_Boost_PREPEND_LIST_WITH_THREADAPI _output)
  331. set(_orig_libnames ${ARGN})
  332. string(REPLACE "thread" "thread_${Boost_THREADAPI}" _threadapi_libnames ${_orig_libnames})
  333. set(${_output} ${_threadapi_libnames} ${_orig_libnames} PARENT_SCOPE)
  334. endfunction()
  335. #
  336. # If a library is found, replace its cache entry with its REALPATH
  337. #
  338. function(_Boost_SWAP_WITH_REALPATH _library _docstring)
  339. if(${_library})
  340. get_filename_component(_boost_filepathreal ${${_library}} REALPATH)
  341. unset(${_library} CACHE)
  342. set(${_library} ${_boost_filepathreal} CACHE FILEPATH "${_docstring}")
  343. endif()
  344. endfunction()
  345. #
  346. # End functions/macros
  347. #
  348. #-------------------------------------------------------------------------------
  349. IF(NOT DEFINED Boost_USE_MULTITHREADED)
  350. SET(Boost_USE_MULTITHREADED TRUE)
  351. ENDIF()
  352. if(NOT DEFINED Boost_COMPAT_STATIC_RUNTIME)
  353. set(Boost_COMPAT_STATIC_RUNTIME TRUE)
  354. endif()
  355. if(Boost_FIND_VERSION_EXACT)
  356. # The version may appear in a directory with or without the patch
  357. # level, even when the patch level is non-zero.
  358. set(_boost_TEST_VERSIONS
  359. "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.${Boost_FIND_VERSION_PATCH}"
  360. "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  361. else(Boost_FIND_VERSION_EXACT)
  362. # The user has not requested an exact version. Among known
  363. # versions, find those that are acceptable to the user request.
  364. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
  365. "1.44.0" "1.44" "1.43.0" "1.43" "1.42.0" "1.42"
  366. "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37"
  367. "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0"
  368. "1.34" "1.33.1" "1.33.0" "1.33")
  369. set(_boost_TEST_VERSIONS)
  370. if(Boost_FIND_VERSION)
  371. set(_Boost_FIND_VERSION_SHORT "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  372. # Select acceptable versions.
  373. foreach(version ${_Boost_KNOWN_VERSIONS})
  374. if(NOT "${version}" VERSION_LESS "${Boost_FIND_VERSION}")
  375. # This version is high enough.
  376. list(APPEND _boost_TEST_VERSIONS "${version}")
  377. elseif("${version}.99" VERSION_EQUAL "${_Boost_FIND_VERSION_SHORT}.99")
  378. # This version is a short-form for the requested version with
  379. # the patch level dropped.
  380. list(APPEND _boost_TEST_VERSIONS "${version}")
  381. endif()
  382. endforeach(version)
  383. else(Boost_FIND_VERSION)
  384. # Any version is acceptable.
  385. set(_boost_TEST_VERSIONS "${_Boost_KNOWN_VERSIONS}")
  386. endif(Boost_FIND_VERSION)
  387. endif(Boost_FIND_VERSION_EXACT)
  388. # The reason that we failed to find Boost. This will be set to a
  389. # user-friendly message when we fail to find some necessary piece of
  390. # Boost.
  391. set(Boost_ERROR_REASON)
  392. SET( _boost_IN_CACHE TRUE)
  393. IF(Boost_INCLUDE_DIR)
  394. # On versions < 1.35, remove the System library from the considered list
  395. # since it wasn't added until 1.35.
  396. if(Boost_VERSION AND Boost_FIND_COMPONENTS)
  397. math(EXPR _boost_maj "${Boost_VERSION} / 100000")
  398. math(EXPR _boost_min "${Boost_VERSION} / 100 % 1000")
  399. if(${_boost_maj}.${_boost_min} VERSION_LESS 1.35)
  400. list(REMOVE_ITEM Boost_FIND_COMPONENTS system)
  401. endif()
  402. endif()
  403. FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
  404. STRING(TOUPPER ${COMPONENT} COMPONENT)
  405. IF(NOT Boost_${COMPONENT}_FOUND)
  406. SET( _boost_IN_CACHE FALSE)
  407. ENDIF(NOT Boost_${COMPONENT}_FOUND)
  408. ENDFOREACH(COMPONENT)
  409. ELSE(Boost_INCLUDE_DIR)
  410. SET( _boost_IN_CACHE FALSE)
  411. ENDIF(Boost_INCLUDE_DIR)
  412. IF (_boost_IN_CACHE)
  413. # in cache already
  414. SET(Boost_FOUND TRUE)
  415. FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
  416. STRING(TOUPPER ${COMPONENT} COMPONENT)
  417. _Boost_ADJUST_LIB_VARS( ${COMPONENT} )
  418. SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${COMPONENT}_LIBRARY})
  419. ENDFOREACH(COMPONENT)
  420. SET(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
  421. IF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
  422. MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
  423. MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
  424. MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
  425. ENDIF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
  426. if(Boost_DEBUG)
  427. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  428. "boost ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION} "
  429. "is already in the cache. To view debugging messages, please clear the cache.")
  430. endif()
  431. ELSE (_boost_IN_CACHE)
  432. # Need to search for boost
  433. if(Boost_DEBUG)
  434. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  435. "Boost not in cache")
  436. # Output some of their choices
  437. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  438. "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
  439. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  440. "Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}")
  441. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  442. "Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}")
  443. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  444. "Boost_USE_STATIC_RUNTIME = ${Boost_USE_STATIC_RUNTIME}")
  445. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  446. "Boost_ADDITIONAL_VERSIONS = ${Boost_ADDITIONAL_VERSIONS}")
  447. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  448. "Boost_NO_SYSTEM_PATHS = ${Boost_NO_SYSTEM_PATHS}")
  449. endif()
  450. IF(WIN32)
  451. # In windows, automatic linking is performed, so you do not have
  452. # to specify the libraries. If you are linking to a dynamic
  453. # runtime, then you can choose to link to either a static or a
  454. # dynamic Boost library, the default is to do a static link. You
  455. # can alter this for a specific library "whatever" by defining
  456. # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be
  457. # linked dynamically. Alternatively you can force all Boost
  458. # libraries to dynamic link by defining BOOST_ALL_DYN_LINK.
  459. # This feature can be disabled for Boost library "whatever" by
  460. # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining
  461. # BOOST_ALL_NO_LIB.
  462. # If you want to observe which libraries are being linked against
  463. # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking
  464. # code to emit a #pragma message each time a library is selected
  465. # for linking.
  466. SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS
  467. "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define")
  468. ENDIF(WIN32)
  469. SET(_boost_INCLUDE_SEARCH_DIRS
  470. C:/boost/include
  471. C:/boost
  472. "$ENV{ProgramFiles}/boost/include"
  473. "$ENV{ProgramFiles}/boost"
  474. /sw/local/include
  475. )
  476. # If Boost_ROOT was defined, gently correct the user
  477. if(Boost_ROOT)
  478. message("WARNING: Boost_ROOT was set which is incorrect and is being ignored. "
  479. "You need to use BOOST_ROOT instead. "
  480. "Also, we suggest setting Boost_NO_SYSTEM_PATHS.")
  481. endif()
  482. # If BOOST_ROOT was defined in the environment, use it.
  483. if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
  484. set(BOOST_ROOT $ENV{BOOST_ROOT})
  485. endif(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
  486. # If BOOSTROOT was defined in the environment, use it.
  487. if (NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
  488. set(BOOST_ROOT $ENV{BOOSTROOT})
  489. endif(NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
  490. # If BOOST_INCLUDEDIR was defined in the environment, use it.
  491. IF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
  492. set(BOOST_INCLUDEDIR $ENV{BOOST_INCLUDEDIR})
  493. ENDIF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
  494. # If BOOST_LIBRARYDIR was defined in the environment, use it.
  495. IF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
  496. set(BOOST_LIBRARYDIR $ENV{BOOST_LIBRARYDIR})
  497. ENDIF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
  498. IF( BOOST_ROOT )
  499. file(TO_CMAKE_PATH ${BOOST_ROOT} BOOST_ROOT)
  500. ENDIF( BOOST_ROOT )
  501. if(Boost_DEBUG)
  502. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  503. "Declared as CMake or Environmental Variables:")
  504. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  505. " BOOST_ROOT = ${BOOST_ROOT}")
  506. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  507. " BOOST_INCLUDEDIR = ${BOOST_INCLUDEDIR}")
  508. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  509. " BOOST_LIBRARYDIR = ${BOOST_LIBRARYDIR}")
  510. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  511. "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
  512. endif()
  513. if( BOOST_ROOT )
  514. if( Boost_NO_SYSTEM_PATHS )
  515. set(_boost_INCLUDE_SEARCH_DIRS
  516. ${BOOST_ROOT}/include
  517. ${BOOST_ROOT})
  518. set(_boost_FIND_OPTIONS NO_CMAKE_SYSTEM_PATH)
  519. else()
  520. set(_boost_INCLUDE_SEARCH_DIRS
  521. ${BOOST_ROOT}/include
  522. ${BOOST_ROOT}
  523. ${_boost_INCLUDE_SEARCH_DIRS})
  524. endif()
  525. endif( BOOST_ROOT )
  526. # prepend BOOST_INCLUDEDIR to search path if specified
  527. if( BOOST_INCLUDEDIR )
  528. file(TO_CMAKE_PATH ${BOOST_INCLUDEDIR} BOOST_INCLUDEDIR)
  529. set(_boost_INCLUDE_SEARCH_DIRS
  530. ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS})
  531. endif( BOOST_INCLUDEDIR )
  532. # ------------------------------------------------------------------------
  533. # Search for Boost include DIR
  534. # ------------------------------------------------------------------------
  535. # Try to find Boost by stepping backwards through the Boost versions
  536. # we know about.
  537. IF( NOT Boost_INCLUDE_DIR )
  538. # Build a list of path suffixes for each version.
  539. SET(_boost_PATH_SUFFIXES)
  540. FOREACH(_boost_VER ${_boost_TEST_VERSIONS})
  541. # Add in a path suffix, based on the required version, ideally
  542. # we could read this from version.hpp, but for that to work we'd
  543. # need to know the include dir already
  544. set(_boost_BOOSTIFIED_VERSION)
  545. # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0
  546. IF(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
  547. STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3"
  548. _boost_BOOSTIFIED_VERSION ${_boost_VER})
  549. ELSEIF(_boost_VER MATCHES "[0-9]+\\.[0-9]+")
  550. STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2"
  551. _boost_BOOSTIFIED_VERSION ${_boost_VER})
  552. ENDIF()
  553. list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_BOOSTIFIED_VERSION}")
  554. list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_BOOSTIFIED_VERSION}")
  555. ENDFOREACH(_boost_VER)
  556. if(Boost_DEBUG)
  557. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  558. "Include debugging info:")
  559. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  560. " _boost_INCLUDE_SEARCH_DIRS = ${_boost_INCLUDE_SEARCH_DIRS}")
  561. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  562. " _boost_PATH_SUFFIXES = ${_boost_PATH_SUFFIXES}")
  563. endif()
  564. # Look for a standard boost header file.
  565. FIND_PATH(Boost_INCLUDE_DIR
  566. NAMES boost/config.hpp
  567. HINTS ${_boost_INCLUDE_SEARCH_DIRS}
  568. PATH_SUFFIXES ${_boost_PATH_SUFFIXES}
  569. ${_boost_FIND_OPTIONS}
  570. )
  571. ENDIF( NOT Boost_INCLUDE_DIR )
  572. # ------------------------------------------------------------------------
  573. # Extract version information from version.hpp
  574. # ------------------------------------------------------------------------
  575. IF(Boost_INCLUDE_DIR)
  576. # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp
  577. # Read the whole file:
  578. #
  579. SET(BOOST_VERSION 0)
  580. SET(BOOST_LIB_VERSION "")
  581. FILE(READ "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS)
  582. if(Boost_DEBUG)
  583. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  584. "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp")
  585. endif()
  586. STRING(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}")
  587. STRING(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}")
  588. SET(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE INTERNAL "The library version string for boost libraries")
  589. SET(Boost_VERSION ${Boost_VERSION} CACHE INTERNAL "The version number for boost libraries")
  590. IF(NOT "${Boost_VERSION}" STREQUAL "0")
  591. MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
  592. MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
  593. MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
  594. set(Boost_ERROR_REASON
  595. "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}")
  596. ENDIF(NOT "${Boost_VERSION}" STREQUAL "0")
  597. if(Boost_DEBUG)
  598. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  599. "version.hpp reveals boost "
  600. "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
  601. endif()
  602. ELSE(Boost_INCLUDE_DIR)
  603. set(Boost_ERROR_REASON
  604. "${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.")
  605. ENDIF(Boost_INCLUDE_DIR)
  606. # ------------------------------------------------------------------------
  607. # Suffix initialization and compiler suffix detection.
  608. # ------------------------------------------------------------------------
  609. # Setting some more suffixes for the library
  610. SET (Boost_LIB_PREFIX "")
  611. if ( WIN32 AND Boost_USE_STATIC_LIBS AND NOT CYGWIN)
  612. SET (Boost_LIB_PREFIX "lib")
  613. endif()
  614. if (Boost_COMPILER)
  615. set(_boost_COMPILER ${Boost_COMPILER})
  616. if(Boost_DEBUG)
  617. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  618. "using user-specified Boost_COMPILER = ${_boost_COMPILER}")
  619. endif()
  620. else(Boost_COMPILER)
  621. # Attempt to guess the compiler suffix
  622. # NOTE: this is not perfect yet, if you experience any issues
  623. # please report them and use the Boost_COMPILER variable
  624. # to work around the problems.
  625. if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel"
  626. OR "${CMAKE_CXX_COMPILER}" MATCHES "icl"
  627. OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
  628. if(WIN32)
  629. set (_boost_COMPILER "-iw")
  630. else()
  631. set (_boost_COMPILER "-il")
  632. endif()
  633. elseif (MSVC90)
  634. SET (_boost_COMPILER "-vc90")
  635. elseif (MSVC10)
  636. SET (_boost_COMPILER "-vc100")
  637. elseif (MSVC80)
  638. SET (_boost_COMPILER "-vc80")
  639. elseif (MSVC71)
  640. SET (_boost_COMPILER "-vc71")
  641. elseif (MSVC70) # Good luck!
  642. SET (_boost_COMPILER "-vc7") # yes, this is correct
  643. elseif (MSVC60) # Good luck!
  644. SET (_boost_COMPILER "-vc6") # yes, this is correct
  645. elseif (BORLAND)
  646. SET (_boost_COMPILER "-bcb")
  647. elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "SunPro")
  648. set(_boost_COMPILER "-sw")
  649. elseif (MINGW)
  650. if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
  651. SET(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34
  652. else()
  653. _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
  654. SET (_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}")
  655. endif()
  656. elseif (UNIX)
  657. if (CMAKE_COMPILER_IS_GNUCXX)
  658. if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
  659. SET(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34
  660. else()
  661. _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
  662. # Determine which version of GCC we have.
  663. IF(APPLE)
  664. IF(Boost_MINOR_VERSION)
  665. IF(${Boost_MINOR_VERSION} GREATER 35)
  666. # In Boost 1.36.0 and newer, the mangled compiler name used
  667. # on Mac OS X/Darwin is "xgcc".
  668. SET(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}")
  669. ELSE(${Boost_MINOR_VERSION} GREATER 35)
  670. # In Boost <= 1.35.0, there is no mangled compiler name for
  671. # the Mac OS X/Darwin version of GCC.
  672. SET(_boost_COMPILER "")
  673. ENDIF(${Boost_MINOR_VERSION} GREATER 35)
  674. ELSE(Boost_MINOR_VERSION)
  675. # We don't know the Boost version, so assume it's
  676. # pre-1.36.0.
  677. SET(_boost_COMPILER "")
  678. ENDIF(Boost_MINOR_VERSION)
  679. ELSE()
  680. SET (_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}")
  681. ENDIF()
  682. endif()
  683. endif (CMAKE_COMPILER_IS_GNUCXX)
  684. endif()
  685. if(Boost_DEBUG)
  686. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  687. "guessed _boost_COMPILER = ${_boost_COMPILER}")
  688. endif()
  689. endif(Boost_COMPILER)
  690. set (_boost_MULTITHREADED "-mt")
  691. if( NOT Boost_USE_MULTITHREADED )
  692. set (_boost_MULTITHREADED "")
  693. endif()
  694. if(Boost_DEBUG)
  695. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  696. "_boost_MULTITHREADED = ${_boost_MULTITHREADED}")
  697. endif()
  698. #======================
  699. # Systematically build up the Boost ABI tag
  700. # http://boost.org/doc/libs/1_41_0/more/getting_started/windows.html#library-naming
  701. set( _boost_RELEASE_ABI_TAG "-")
  702. set( _boost_DEBUG_ABI_TAG "-")
  703. # Key Use this library when:
  704. # s linking statically to the C++ standard library and
  705. # compiler runtime support libraries.
  706. if(Boost_USE_STATIC_RUNTIME)
  707. set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}s")
  708. set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}s")
  709. endif()
  710. # g using debug versions of the standard and runtime
  711. # support libraries
  712. if(WIN32)
  713. if(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl"
  714. OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
  715. set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}g")
  716. endif()
  717. endif()
  718. # y using special debug build of python
  719. if(Boost_USE_DEBUG_PYTHON)
  720. set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}y")
  721. endif()
  722. # d using a debug version of your code
  723. set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}d")
  724. # p using the STLport standard library rather than the
  725. # default one supplied with your compiler
  726. if(Boost_USE_STLPORT)
  727. set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}p")
  728. set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}p")
  729. endif()
  730. # n using the STLport deprecated "native iostreams" feature
  731. if(Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS)
  732. set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}n")
  733. set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}n")
  734. endif()
  735. if(Boost_DEBUG)
  736. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  737. "_boost_RELEASE_ABI_TAG = ${_boost_RELEASE_ABI_TAG}")
  738. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  739. "_boost_DEBUG_ABI_TAG = ${_boost_DEBUG_ABI_TAG}")
  740. endif()
  741. # ------------------------------------------------------------------------
  742. # Begin finding boost libraries
  743. # ------------------------------------------------------------------------
  744. set(_boost_LIBRARY_SEARCH_DIRS_ALWAYS
  745. ${BOOST_ROOT}/lib
  746. ${BOOST_ROOT}/stage/lib
  747. ${Boost_INCLUDE_DIR}/lib
  748. ${Boost_INCLUDE_DIR}/../lib
  749. ${Boost_INCLUDE_DIR}/stage/lib
  750. )
  751. set(_boost_LIBRARY_SEARCH_DIRS_SYSTEM
  752. C:/boost/lib
  753. C:/boost
  754. "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}_${Boost_SUBMINOR_VERSION}/lib"
  755. "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}/lib"
  756. "$ENV{ProgramFiles}/boost/lib"
  757. "$ENV{ProgramFiles}/boost"
  758. /sw/local/lib
  759. )
  760. if( BOOST_ROOT )
  761. set(_boost_LIBRARY_SEARCH_DIRS ${_boost_LIBRARY_SEARCH_DIRS_ALWAYS})
  762. if( Boost_NO_SYSTEM_PATHS )
  763. set(_boost_FIND_OPTIONS NO_CMAKE_SYSTEM_PATH)
  764. else()
  765. list(APPEND _boost_LIBRARY_SEARCH_DIRS ${_boost_LIBRARY_SEARCH_DIRS_SYSTEM})
  766. endif()
  767. endif( BOOST_ROOT )
  768. # prepend BOOST_LIBRARYDIR to search path if specified
  769. if( BOOST_LIBRARYDIR )
  770. file(TO_CMAKE_PATH ${BOOST_LIBRARYDIR} BOOST_LIBRARYDIR)
  771. set(_boost_LIBRARY_SEARCH_DIRS
  772. ${BOOST_LIBRARYDIR} ${_boost_LIBRARY_SEARCH_DIRS})
  773. endif()
  774. if(Boost_DEBUG)
  775. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  776. "_boost_LIBRARY_SEARCH_DIRS = ${_boost_LIBRARY_SEARCH_DIRS}")
  777. endif()
  778. # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
  779. if( Boost_USE_STATIC_LIBS )
  780. set( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
  781. if(WIN32)
  782. set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
  783. else()
  784. set(CMAKE_FIND_LIBRARY_SUFFIXES .a )
  785. endif()
  786. endif()
  787. # We want to use the tag inline below without risking double dashes
  788. if(_boost_RELEASE_ABI_TAG)
  789. if(${_boost_RELEASE_ABI_TAG} STREQUAL "-")
  790. set(_boost_RELEASE_ABI_TAG "")
  791. endif()
  792. endif()
  793. if(_boost_DEBUG_ABI_TAG)
  794. if(${_boost_DEBUG_ABI_TAG} STREQUAL "-")
  795. set(_boost_DEBUG_ABI_TAG "")
  796. endif()
  797. endif()
  798. # The previous behavior of FindBoost when Boost_USE_STATIC_LIBS was enabled
  799. # on WIN32 was to:
  800. # 1. Search for static libs compiled against a SHARED C++ standard runtime library (use if found)
  801. # 2. Search for static libs compiled against a STATIC C++ standard runtime library (use if found)
  802. # We maintain this behavior since changing it could break people's builds.
  803. # To disable the ambiguous behavior, the user can
  804. # set Boost_COMPAT_STATIC_RUNTIME to FALSE
  805. set(_boost_STATIC_RUNTIME_WORKAROUND false)
  806. if(Boost_COMPAT_STATIC_RUNTIME AND WIN32 AND Boost_USE_STATIC_LIBS)
  807. if(NOT Boost_USE_STATIC_RUNTIME)
  808. set(_boost_STATIC_RUNTIME_WORKAROUND true)
  809. endif()
  810. endif()
  811. foreach(COMPONENT ${Boost_FIND_COMPONENTS})
  812. string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  813. set( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" )
  814. set( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" )
  815. set( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND")
  816. set( _boost_docstring_release "Boost ${COMPONENT} library (release)")
  817. set( _boost_docstring_debug "Boost ${COMPONENT} library (debug)")
  818. #
  819. # Find RELEASE libraries
  820. #
  821. set(_boost_RELEASE_NAMES
  822. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
  823. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
  824. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
  825. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
  826. ${Boost_LIB_PREFIX}boost_${COMPONENT} )
  827. if(_boost_STATIC_RUNTIME_WORKAROUND)
  828. set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}")
  829. list(APPEND _boost_RELEASE_NAMES
  830. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
  831. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}
  832. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
  833. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} )
  834. endif()
  835. if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread")
  836. _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_RELEASE_NAMES ${_boost_RELEASE_NAMES})
  837. endif()
  838. if(Boost_DEBUG)
  839. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  840. "Searching for ${UPPERCOMPONENT}_LIBRARY_RELEASE: ${_boost_RELEASE_NAMES}")
  841. endif()
  842. find_library(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE
  843. NAMES ${_boost_RELEASE_NAMES}
  844. HINTS ${_boost_LIBRARY_SEARCH_DIRS}
  845. ${_boost_FIND_OPTIONS}
  846. DOC "${_boost_docstring_release}"
  847. )
  848. #
  849. # Find DEBUG libraries
  850. #
  851. set(_boost_DEBUG_NAMES
  852. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
  853. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
  854. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
  855. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}
  856. ${Boost_LIB_PREFIX}boost_${COMPONENT} )
  857. if(_boost_STATIC_RUNTIME_WORKAROUND)
  858. set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}")
  859. list(APPEND _boost_DEBUG_NAMES
  860. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
  861. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}
  862. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
  863. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} )
  864. endif()
  865. if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread")
  866. _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_DEBUG_NAMES ${_boost_DEBUG_NAMES})
  867. endif()
  868. if(Boost_DEBUG)
  869. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  870. "Searching for ${UPPERCOMPONENT}_LIBRARY_DEBUG: ${_boost_DEBUG_NAMES}")
  871. endif()
  872. find_library(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG
  873. NAMES ${_boost_DEBUG_NAMES}
  874. HINTS ${_boost_LIBRARY_SEARCH_DIRS}
  875. ${_boost_FIND_OPTIONS}
  876. DOC "${_boost_docstring_debug}"
  877. )
  878. if(Boost_REALPATH)
  879. _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "${_boost_docstring_release}")
  880. _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "${_boost_docstring_debug}" )
  881. endif()
  882. _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT})
  883. endforeach(COMPONENT)
  884. # Restore the original find library ordering
  885. if( Boost_USE_STATIC_LIBS )
  886. set(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
  887. endif()
  888. # ------------------------------------------------------------------------
  889. # End finding boost libraries
  890. # ------------------------------------------------------------------------
  891. SET(Boost_INCLUDE_DIRS
  892. ${Boost_INCLUDE_DIR}
  893. )
  894. SET(Boost_FOUND FALSE)
  895. IF(Boost_INCLUDE_DIR)
  896. SET( Boost_FOUND TRUE )
  897. # Check the version of Boost against the requested version.
  898. if (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
  899. 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")
  900. endif (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
  901. if(Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
  902. set( Boost_FOUND FALSE )
  903. set(_Boost_VERSION_AGE "old")
  904. elseif(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
  905. if(Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
  906. set( Boost_FOUND FALSE )
  907. set(_Boost_VERSION_AGE "old")
  908. elseif(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
  909. if( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
  910. set( Boost_FOUND FALSE )
  911. set(_Boost_VERSION_AGE "old")
  912. endif( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
  913. endif( Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
  914. endif( Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
  915. if (NOT Boost_FOUND)
  916. _Boost_MARK_COMPONENTS_FOUND(OFF)
  917. endif()
  918. if (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
  919. # If the user requested an exact version of Boost, check
  920. # that. We already know that the Boost version we have is >= the
  921. # requested version.
  922. set(_Boost_VERSION_AGE "new")
  923. # If the user didn't specify a patchlevel, it's 0.
  924. if (NOT Boost_FIND_VERSION_PATCH)
  925. set(Boost_FIND_VERSION_PATCH 0)
  926. endif (NOT Boost_FIND_VERSION_PATCH)
  927. # We'll set Boost_FOUND true again if we have an exact version match.
  928. set(Boost_FOUND FALSE)
  929. _Boost_MARK_COMPONENTS_FOUND(OFF)
  930. if(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
  931. if(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
  932. if(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
  933. set( Boost_FOUND TRUE )
  934. _Boost_MARK_COMPONENTS_FOUND(ON)
  935. endif(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
  936. endif( Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
  937. endif( Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
  938. endif (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
  939. if(NOT Boost_FOUND)
  940. # State that we found a version of Boost that is too new or too old.
  941. set(Boost_ERROR_REASON
  942. "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  943. if (Boost_FIND_VERSION_PATCH)
  944. set(Boost_ERROR_REASON
  945. "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}")
  946. endif (Boost_FIND_VERSION_PATCH)
  947. if (NOT Boost_FIND_VERSION_EXACT)
  948. set(Boost_ERROR_REASON "${Boost_ERROR_REASON} (or newer)")
  949. endif (NOT Boost_FIND_VERSION_EXACT)
  950. set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.")
  951. endif (NOT Boost_FOUND)
  952. # Always check for missing components
  953. set(_boost_CHECKED_COMPONENT FALSE)
  954. set(_Boost_MISSING_COMPONENTS "")
  955. foreach(COMPONENT ${Boost_FIND_COMPONENTS})
  956. string(TOUPPER ${COMPONENT} COMPONENT)
  957. set(_boost_CHECKED_COMPONENT TRUE)
  958. if(NOT Boost_${COMPONENT}_FOUND)
  959. string(TOLOWER ${COMPONENT} COMPONENT)
  960. list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT})
  961. set( Boost_FOUND FALSE)
  962. endif(NOT Boost_${COMPONENT}_FOUND)
  963. endforeach(COMPONENT)
  964. if(Boost_DEBUG)
  965. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] Boost_FOUND = ${Boost_FOUND}")
  966. endif()
  967. if (_Boost_MISSING_COMPONENTS)
  968. # We were unable to find some libraries, so generate a sensible
  969. # error message that lists the libraries we were unable to find.
  970. set(Boost_ERROR_REASON
  971. "${Boost_ERROR_REASON}\nThe following Boost libraries could not be found:\n")
  972. foreach(COMPONENT ${_Boost_MISSING_COMPONENTS})
  973. set(Boost_ERROR_REASON
  974. "${Boost_ERROR_REASON} boost_${COMPONENT}\n")
  975. endforeach(COMPONENT)
  976. list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED)
  977. list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS)
  978. if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
  979. set(Boost_ERROR_REASON
  980. "${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.")
  981. else (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
  982. set(Boost_ERROR_REASON
  983. "${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.")
  984. endif (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
  985. endif (_Boost_MISSING_COMPONENTS)
  986. IF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
  987. # Compatibility Code for backwards compatibility with CMake
  988. # 2.4's FindBoost module.
  989. # Look for the boost library path.
  990. # Note that the user may not have installed any libraries
  991. # so it is quite possible the Boost_LIBRARY_PATH may not exist.
  992. SET(_boost_LIB_DIR ${Boost_INCLUDE_DIR})
  993. IF("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
  994. GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
  995. ENDIF ("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
  996. IF("${_boost_LIB_DIR}" MATCHES "/include$")
  997. # Strip off the trailing "/include" in the path.
  998. GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
  999. ENDIF("${_boost_LIB_DIR}" MATCHES "/include$")
  1000. IF(EXISTS "${_boost_LIB_DIR}/lib")
  1001. SET (_boost_LIB_DIR ${_boost_LIB_DIR}/lib)
  1002. ELSE(EXISTS "${_boost_LIB_DIR}/lib")
  1003. IF(EXISTS "${_boost_LIB_DIR}/stage/lib")
  1004. SET(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib)
  1005. ELSE(EXISTS "${_boost_LIB_DIR}/stage/lib")
  1006. SET(_boost_LIB_DIR "")
  1007. ENDIF(EXISTS "${_boost_LIB_DIR}/stage/lib")
  1008. ENDIF(EXISTS "${_boost_LIB_DIR}/lib")
  1009. IF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
  1010. SET(Boost_LIBRARY_DIRS ${_boost_LIB_DIR} CACHE FILEPATH "Boost library directory")
  1011. ENDIF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
  1012. ENDIF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
  1013. ELSE(Boost_INCLUDE_DIR)
  1014. SET( Boost_FOUND FALSE)
  1015. ENDIF(Boost_INCLUDE_DIR)
  1016. IF (Boost_FOUND)
  1017. IF (NOT Boost_FIND_QUIETLY)
  1018. MESSAGE(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
  1019. if(Boost_FIND_COMPONENTS)
  1020. message(STATUS "Found the following Boost libraries:")
  1021. endif()
  1022. ENDIF(NOT Boost_FIND_QUIETLY)
  1023. FOREACH ( COMPONENT ${Boost_FIND_COMPONENTS} )
  1024. STRING( TOUPPER ${COMPONENT} UPPERCOMPONENT )
  1025. IF ( Boost_${UPPERCOMPONENT}_FOUND )
  1026. IF (NOT Boost_FIND_QUIETLY)
  1027. MESSAGE (STATUS " ${COMPONENT}")
  1028. ENDIF(NOT Boost_FIND_QUIETLY)
  1029. SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${UPPERCOMPONENT}_LIBRARY})
  1030. ENDIF ( Boost_${UPPERCOMPONENT}_FOUND )
  1031. ENDFOREACH(COMPONENT)
  1032. else()
  1033. if(Boost_FIND_REQUIRED)
  1034. message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")
  1035. else()
  1036. if(NOT Boost_FIND_QUIETLY)
  1037. # we opt not to automatically output Boost_ERROR_REASON here as
  1038. # it could be quite lengthy and somewhat imposing in it's requests
  1039. # Since Boost is not always a required dependency we'll leave this
  1040. # up to the end-user.
  1041. if(Boost_DEBUG OR Boost_DETAILED_FAILURE_MSG)
  1042. message(STATUS "Could NOT find Boost\n${Boost_ERROR_REASON}")
  1043. else()
  1044. message(STATUS "Could NOT find Boost")
  1045. endif()
  1046. endif()
  1047. endif(Boost_FIND_REQUIRED)
  1048. endif()
  1049. # show the Boost_INCLUDE_DIRS AND Boost_LIBRARIES variables only in the advanced view
  1050. MARK_AS_ADVANCED(Boost_INCLUDE_DIR
  1051. Boost_INCLUDE_DIRS
  1052. Boost_LIBRARY_DIRS
  1053. )
  1054. ENDIF(_boost_IN_CACHE)