FindBoost.cmake 51 KB

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