FindBoost.cmake 51 KB

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