FindBoost.cmake 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218
  1. #.rst:
  2. # FindBoost
  3. # ---------
  4. #
  5. # Find Boost include dirs and libraries
  6. #
  7. # Use this module by invoking find_package with the form::
  8. #
  9. # find_package(Boost
  10. # [version] [EXACT] # Minimum or EXACT version e.g. 1.36.0
  11. # [REQUIRED] # Fail with error if Boost is not found
  12. # [COMPONENTS <libs>...] # Boost libraries by their canonical name
  13. # ) # e.g. "date_time" for "libboost_date_time"
  14. #
  15. # This module finds headers and requested component libraries OR a CMake
  16. # package configuration file provided by a "Boost CMake" build. For the
  17. # latter case skip to the "Boost CMake" section below. For the former
  18. # case results are reported in variables::
  19. #
  20. # Boost_FOUND - True if headers and requested libraries were found
  21. # Boost_INCLUDE_DIRS - Boost include directories
  22. # Boost_LIBRARY_DIRS - Link directories for Boost libraries
  23. # Boost_LIBRARIES - Boost component libraries to be linked
  24. # Boost_<C>_FOUND - True if component <C> was found (<C> is upper-case)
  25. # Boost_<C>_LIBRARY - Libraries to link for component <C> (may include
  26. # target_link_libraries debug/optimized keywords)
  27. # Boost_VERSION - BOOST_VERSION value from boost/version.hpp
  28. # Boost_LIB_VERSION - Version string appended to library filenames
  29. # Boost_MAJOR_VERSION - Boost major version number (X in X.y.z)
  30. # Boost_MINOR_VERSION - Boost minor version number (Y in x.Y.z)
  31. # Boost_SUBMINOR_VERSION - Boost subminor version number (Z in x.y.Z)
  32. # Boost_LIB_DIAGNOSTIC_DEFINITIONS (Windows)
  33. # - Pass to add_definitions() to have diagnostic
  34. # information about Boost's automatic linking
  35. # displayed during compilation
  36. #
  37. # This module reads hints about search locations from variables::
  38. #
  39. # BOOST_ROOT - Preferred installation prefix
  40. # (or BOOSTROOT)
  41. # BOOST_INCLUDEDIR - Preferred include directory e.g. <prefix>/include
  42. # BOOST_LIBRARYDIR - Preferred library directory e.g. <prefix>/lib
  43. # Boost_NO_SYSTEM_PATHS - Set to ON to disable searching in locations not
  44. # specified by these hint variables. Default is OFF.
  45. # Boost_ADDITIONAL_VERSIONS
  46. # - List of Boost versions not known to this module
  47. # (Boost install locations may contain the version)
  48. #
  49. # and saves search results persistently in CMake cache entries::
  50. #
  51. # Boost_INCLUDE_DIR - Directory containing Boost headers
  52. # Boost_LIBRARY_DIR - Directory containing Boost libraries
  53. # Boost_<C>_LIBRARY_DEBUG - Component <C> library debug variant
  54. # Boost_<C>_LIBRARY_RELEASE - Component <C> library release variant
  55. #
  56. # Users may set these hints or results as cache entries. Projects
  57. # should not read these entries directly but instead use the above
  58. # result variables. Note that some hint names start in upper-case
  59. # "BOOST". One may specify these as environment variables if they are
  60. # not specified as CMake variables or cache entries.
  61. #
  62. # This module first searches for the Boost header files using the above
  63. # hint variables (excluding BOOST_LIBRARYDIR) and saves the result in
  64. # Boost_INCLUDE_DIR. Then it searches for requested component libraries
  65. # using the above hints (excluding BOOST_INCLUDEDIR and
  66. # Boost_ADDITIONAL_VERSIONS), "lib" directories near Boost_INCLUDE_DIR,
  67. # and the library name configuration settings below. It saves the
  68. # library directory in Boost_LIBRARY_DIR and individual library
  69. # locations in Boost_<C>_LIBRARY_DEBUG and Boost_<C>_LIBRARY_RELEASE.
  70. # When one changes settings used by previous searches in the same build
  71. # tree (excluding environment variables) this module discards previous
  72. # search results affected by the changes and searches again.
  73. #
  74. # Boost libraries come in many variants encoded in their file name.
  75. # Users or projects may tell this module which variant to find by
  76. # setting variables::
  77. #
  78. # Boost_USE_MULTITHREADED - Set to OFF to use the non-multithreaded
  79. # libraries ('mt' tag). Default is ON.
  80. # Boost_USE_STATIC_LIBS - Set to ON to force the use of the static
  81. # libraries. Default is OFF.
  82. # Boost_USE_STATIC_RUNTIME - Set to ON or OFF to specify whether to use
  83. # libraries linked statically to the C++ runtime
  84. # ('s' tag). Default is platform dependent.
  85. # Boost_USE_DEBUG_RUNTIME - Set to ON or OFF to specify whether to use
  86. # libraries linked to the MS debug C++ runtime
  87. # ('g' tag). Default is ON.
  88. # Boost_USE_DEBUG_PYTHON - Set to ON to use libraries compiled with a
  89. # debug Python build ('y' tag). Default is OFF.
  90. # Boost_USE_STLPORT - Set to ON to use libraries compiled with
  91. # STLPort ('p' tag). Default is OFF.
  92. # Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS
  93. # - Set to ON to use libraries compiled with
  94. # STLPort deprecated "native iostreams"
  95. # ('n' tag). Default is OFF.
  96. # Boost_COMPILER - Set to the compiler-specific library suffix
  97. # (e.g. "-gcc43"). Default is auto-computed
  98. # for the C++ compiler in use.
  99. # Boost_THREADAPI - Suffix for "thread" component library name,
  100. # such as "pthread" or "win32". Names with
  101. # and without this suffix will both be tried.
  102. #
  103. # Other variables one may set to control this module are::
  104. #
  105. # Boost_DEBUG - Set to ON to enable debug output from FindBoost.
  106. # Please enable this before filing any bug report.
  107. # Boost_DETAILED_FAILURE_MSG
  108. # - Set to ON to add detailed information to the
  109. # failure message even when the REQUIRED option
  110. # is not given to the find_package call.
  111. # Boost_REALPATH - Set to ON to resolve symlinks for discovered
  112. # libraries to assist with packaging. For example,
  113. # the "system" component library may be resolved to
  114. # "/usr/lib/libboost_system.so.1.42.0" instead of
  115. # "/usr/lib/libboost_system.so". This does not
  116. # affect linking and should not be enabled unless
  117. # the user needs this information.
  118. #
  119. # On Visual Studio and Borland compilers Boost headers request automatic
  120. # linking to corresponding libraries. This requires matching libraries
  121. # to be linked explicitly or available in the link library search path.
  122. # In this case setting Boost_USE_STATIC_LIBS to OFF may not achieve
  123. # dynamic linking. Boost automatic linking typically requests static
  124. # libraries with a few exceptions (such as Boost.Python). Use::
  125. #
  126. # add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
  127. #
  128. # to ask Boost to report information about automatic linking requests.
  129. #
  130. # Example to find Boost headers only::
  131. #
  132. # find_package(Boost 1.36.0)
  133. # if(Boost_FOUND)
  134. # include_directories(${Boost_INCLUDE_DIRS})
  135. # add_executable(foo foo.cc)
  136. # endif()
  137. #
  138. # Example to find Boost headers and some *static* libraries::
  139. #
  140. # set(Boost_USE_STATIC_LIBS ON) # only find static libs
  141. # set(Boost_USE_MULTITHREADED ON)
  142. # set(Boost_USE_STATIC_RUNTIME OFF)
  143. # find_package(Boost 1.36.0 COMPONENTS date_time filesystem system ...)
  144. # if(Boost_FOUND)
  145. # include_directories(${Boost_INCLUDE_DIRS})
  146. # add_executable(foo foo.cc)
  147. # target_link_libraries(foo ${Boost_LIBRARIES})
  148. # endif()
  149. #
  150. # Boost CMake
  151. # ^^^^^^^^^^^
  152. #
  153. # If Boost was built using the boost-cmake project it provides a package
  154. # configuration file for use with find_package's Config mode. This
  155. # module looks for the package configuration file called
  156. # BoostConfig.cmake or boost-config.cmake and stores the result in cache
  157. # entry "Boost_DIR". If found, the package configuration file is loaded
  158. # and this module returns with no further action. See documentation of
  159. # the Boost CMake package configuration for details on what it provides.
  160. #
  161. # Set Boost_NO_BOOST_CMAKE to ON to disable the search for boost-cmake.
  162. #=============================================================================
  163. # Copyright 2006-2012 Kitware, Inc.
  164. # Copyright 2006-2008 Andreas Schneider <[email protected]>
  165. # Copyright 2007 Wengo
  166. # Copyright 2007 Mike Jackson
  167. # Copyright 2008 Andreas Pakulat <[email protected]>
  168. # Copyright 2008-2012 Philip Lowman <[email protected]>
  169. #
  170. # Distributed under the OSI-approved BSD License (the "License");
  171. # see accompanying file Copyright.txt for details.
  172. #
  173. # This software is distributed WITHOUT ANY WARRANTY; without even the
  174. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  175. # See the License for more information.
  176. #=============================================================================
  177. # (To distribute this file outside of CMake, substitute the full
  178. # License text for the above reference.)
  179. #-------------------------------------------------------------------------------
  180. # Before we go searching, check whether boost-cmake is available, unless the
  181. # user specifically asked NOT to search for boost-cmake.
  182. #
  183. # If Boost_DIR is set, this behaves as any find_package call would. If not,
  184. # it looks at BOOST_ROOT and BOOSTROOT to find Boost.
  185. #
  186. if (NOT Boost_NO_BOOST_CMAKE)
  187. # If Boost_DIR is not set, look for BOOSTROOT and BOOST_ROOT as alternatives,
  188. # since these are more conventional for Boost.
  189. if ("$ENV{Boost_DIR}" STREQUAL "")
  190. if (NOT "$ENV{BOOST_ROOT}" STREQUAL "")
  191. set(ENV{Boost_DIR} $ENV{BOOST_ROOT})
  192. elseif (NOT "$ENV{BOOSTROOT}" STREQUAL "")
  193. set(ENV{Boost_DIR} $ENV{BOOSTROOT})
  194. endif()
  195. endif()
  196. # Do the same find_package call but look specifically for the CMake version.
  197. # Note that args are passed in the Boost_FIND_xxxxx variables, so there is no
  198. # need to delegate them to this find_package call.
  199. find_package(Boost QUIET NO_MODULE)
  200. mark_as_advanced(Boost_DIR)
  201. # If we found boost-cmake, then we're done. Print out what we found.
  202. # Otherwise let the rest of the module try to find it.
  203. if (Boost_FOUND)
  204. message("Boost ${Boost_FIND_VERSION} found.")
  205. if (Boost_FIND_COMPONENTS)
  206. message("Found Boost components:")
  207. message(" ${Boost_FIND_COMPONENTS}")
  208. endif()
  209. return()
  210. endif()
  211. endif()
  212. #-------------------------------------------------------------------------------
  213. # FindBoost functions & macros
  214. #
  215. ############################################
  216. #
  217. # Check the existence of the libraries.
  218. #
  219. ############################################
  220. # This macro was taken directly from the FindQt4.cmake file that is included
  221. # with the CMake distribution. This is NOT my work. All work was done by the
  222. # original authors of the FindQt4.cmake file. Only minor modifications were
  223. # made to remove references to Qt and make this file more generally applicable
  224. # And ELSE/ENDIF pairs were removed for readability.
  225. #########################################################################
  226. macro(_Boost_ADJUST_LIB_VARS basename)
  227. if(Boost_INCLUDE_DIR )
  228. if(Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
  229. # if the generator supports configuration types then set
  230. # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
  231. if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
  232. set(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
  233. else()
  234. # if there are no configuration types and CMAKE_BUILD_TYPE has no value
  235. # then just use the release libraries
  236. set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
  237. endif()
  238. # FIXME: This probably should be set for both cases
  239. set(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
  240. endif()
  241. # if only the release version was found, set the debug variable also to the release version
  242. if(Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG)
  243. set(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE})
  244. set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE})
  245. set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE})
  246. endif()
  247. # if only the debug version was found, set the release variable also to the debug version
  248. if(Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE)
  249. set(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG})
  250. set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG})
  251. set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG})
  252. endif()
  253. # If the debug & release library ends up being the same, omit the keywords
  254. if(${Boost_${basename}_LIBRARY_RELEASE} STREQUAL ${Boost_${basename}_LIBRARY_DEBUG})
  255. set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
  256. set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE} )
  257. endif()
  258. if(Boost_${basename}_LIBRARY)
  259. set(Boost_${basename}_FOUND ON)
  260. endif()
  261. endif()
  262. # Make variables changeable to the advanced user
  263. mark_as_advanced(
  264. Boost_${basename}_LIBRARY_RELEASE
  265. Boost_${basename}_LIBRARY_DEBUG
  266. )
  267. endmacro()
  268. macro(_Boost_CHANGE_DETECT changed_var)
  269. set(${changed_var} 0)
  270. foreach(v ${ARGN})
  271. if(DEFINED _Boost_COMPONENTS_SEARCHED)
  272. if(${v})
  273. if(_${v}_LAST)
  274. string(COMPARE NOTEQUAL "${${v}}" "${_${v}_LAST}" _${v}_CHANGED)
  275. else()
  276. set(_${v}_CHANGED 1)
  277. endif()
  278. elseif(_${v}_LAST)
  279. set(_${v}_CHANGED 1)
  280. endif()
  281. if(_${v}_CHANGED)
  282. set(${changed_var} 1)
  283. endif()
  284. else()
  285. set(_${v}_CHANGED 0)
  286. endif()
  287. endforeach()
  288. endmacro()
  289. macro(_Boost_FIND_LIBRARY var)
  290. find_library(${var} ${ARGN})
  291. if(${var})
  292. # If this is the first library found then save Boost_LIBRARY_DIR.
  293. if(NOT Boost_LIBRARY_DIR)
  294. get_filename_component(_dir "${${var}}" PATH)
  295. set(Boost_LIBRARY_DIR "${_dir}" CACHE PATH "Boost library directory" FORCE)
  296. endif()
  297. elseif(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT)
  298. # Try component-specific hints but do not save Boost_LIBRARY_DIR.
  299. find_library(${var} HINTS ${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT} ${ARGN})
  300. endif()
  301. # If Boost_LIBRARY_DIR is known then search only there.
  302. if(Boost_LIBRARY_DIR)
  303. set(_boost_LIBRARY_SEARCH_DIRS ${Boost_LIBRARY_DIR} NO_DEFAULT_PATH)
  304. endif()
  305. endmacro()
  306. #-------------------------------------------------------------------------------
  307. #
  308. # Runs compiler with "-dumpversion" and parses major/minor
  309. # version with a regex.
  310. #
  311. function(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION)
  312. exec_program(${CMAKE_CXX_COMPILER}
  313. ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
  314. OUTPUT_VARIABLE _boost_COMPILER_VERSION
  315. )
  316. string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
  317. _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
  318. set(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE)
  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. function(_Boost_CHECK_SPELLING _var)
  341. if(${_var})
  342. string(TOUPPER ${_var} _var_UC)
  343. message(FATAL_ERROR "ERROR: ${_var} is not the correct spelling. The proper spelling is ${_var_UC}.")
  344. endif()
  345. endfunction()
  346. # Guesses Boost's compiler prefix used in built library names
  347. # Returns the guess by setting the variable pointed to by _ret
  348. function(_Boost_GUESS_COMPILER_PREFIX _ret)
  349. if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel"
  350. OR "${CMAKE_CXX_COMPILER}" MATCHES "icl"
  351. OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
  352. if(WIN32)
  353. set (_boost_COMPILER "-iw")
  354. else()
  355. set (_boost_COMPILER "-il")
  356. endif()
  357. elseif (MSVC12)
  358. set(_boost_COMPILER "-vc120")
  359. elseif (MSVC11)
  360. set(_boost_COMPILER "-vc110")
  361. elseif (MSVC10)
  362. set(_boost_COMPILER "-vc100")
  363. elseif (MSVC90)
  364. set(_boost_COMPILER "-vc90")
  365. elseif (MSVC80)
  366. set(_boost_COMPILER "-vc80")
  367. elseif (MSVC71)
  368. set(_boost_COMPILER "-vc71")
  369. elseif (MSVC70) # Good luck!
  370. set(_boost_COMPILER "-vc7") # yes, this is correct
  371. elseif (MSVC60) # Good luck!
  372. set(_boost_COMPILER "-vc6") # yes, this is correct
  373. elseif (BORLAND)
  374. set(_boost_COMPILER "-bcb")
  375. elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "SunPro")
  376. set(_boost_COMPILER "-sw")
  377. elseif (MINGW)
  378. if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
  379. set(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34
  380. else()
  381. _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
  382. set(_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}")
  383. endif()
  384. elseif (UNIX)
  385. if (CMAKE_COMPILER_IS_GNUCXX)
  386. if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
  387. set(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34
  388. else()
  389. _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
  390. # Determine which version of GCC we have.
  391. if(APPLE)
  392. if(Boost_MINOR_VERSION)
  393. if(${Boost_MINOR_VERSION} GREATER 35)
  394. # In Boost 1.36.0 and newer, the mangled compiler name used
  395. # on Mac OS X/Darwin is "xgcc".
  396. set(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}")
  397. else()
  398. # In Boost <= 1.35.0, there is no mangled compiler name for
  399. # the Mac OS X/Darwin version of GCC.
  400. set(_boost_COMPILER "")
  401. endif()
  402. else()
  403. # We don't know the Boost version, so assume it's
  404. # pre-1.36.0.
  405. set(_boost_COMPILER "")
  406. endif()
  407. else()
  408. set(_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}")
  409. endif()
  410. endif()
  411. endif ()
  412. else()
  413. # TODO at least Boost_DEBUG here?
  414. set(_boost_COMPILER "")
  415. endif()
  416. set(${_ret} ${_boost_COMPILER} PARENT_SCOPE)
  417. endfunction()
  418. #
  419. # End functions/macros
  420. #
  421. #-------------------------------------------------------------------------------
  422. #-------------------------------------------------------------------------------
  423. # main.
  424. #-------------------------------------------------------------------------------
  425. if(NOT DEFINED Boost_USE_MULTITHREADED)
  426. set(Boost_USE_MULTITHREADED TRUE)
  427. endif()
  428. if(NOT DEFINED Boost_USE_DEBUG_RUNTIME)
  429. set(Boost_USE_DEBUG_RUNTIME TRUE)
  430. endif()
  431. # Check the version of Boost against the requested version.
  432. if(Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
  433. 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")
  434. endif()
  435. if(Boost_FIND_VERSION_EXACT)
  436. # The version may appear in a directory with or without the patch
  437. # level, even when the patch level is non-zero.
  438. set(_boost_TEST_VERSIONS
  439. "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.${Boost_FIND_VERSION_PATCH}"
  440. "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  441. else()
  442. # The user has not requested an exact version. Among known
  443. # versions, find those that are acceptable to the user request.
  444. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
  445. "1.56.0" "1.56" "1.55.0" "1.55" "1.54.0" "1.54"
  446. "1.53.0" "1.53" "1.52.0" "1.52" "1.51.0" "1.51"
  447. "1.50.0" "1.50" "1.49.0" "1.49" "1.48.0" "1.48" "1.47.0" "1.47" "1.46.1"
  448. "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"
  449. "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"
  450. "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0"
  451. "1.34" "1.33.1" "1.33.0" "1.33")
  452. set(_boost_TEST_VERSIONS)
  453. if(Boost_FIND_VERSION)
  454. set(_Boost_FIND_VERSION_SHORT "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  455. # Select acceptable versions.
  456. foreach(version ${_Boost_KNOWN_VERSIONS})
  457. if(NOT "${version}" VERSION_LESS "${Boost_FIND_VERSION}")
  458. # This version is high enough.
  459. list(APPEND _boost_TEST_VERSIONS "${version}")
  460. elseif("${version}.99" VERSION_EQUAL "${_Boost_FIND_VERSION_SHORT}.99")
  461. # This version is a short-form for the requested version with
  462. # the patch level dropped.
  463. list(APPEND _boost_TEST_VERSIONS "${version}")
  464. endif()
  465. endforeach()
  466. else()
  467. # Any version is acceptable.
  468. set(_boost_TEST_VERSIONS "${_Boost_KNOWN_VERSIONS}")
  469. endif()
  470. endif()
  471. # The reason that we failed to find Boost. This will be set to a
  472. # user-friendly message when we fail to find some necessary piece of
  473. # Boost.
  474. set(Boost_ERROR_REASON)
  475. if(Boost_DEBUG)
  476. # Output some of their choices
  477. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  478. "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
  479. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  480. "Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}")
  481. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  482. "Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}")
  483. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  484. "Boost_USE_STATIC_RUNTIME = ${Boost_USE_STATIC_RUNTIME}")
  485. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  486. "Boost_ADDITIONAL_VERSIONS = ${Boost_ADDITIONAL_VERSIONS}")
  487. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  488. "Boost_NO_SYSTEM_PATHS = ${Boost_NO_SYSTEM_PATHS}")
  489. endif()
  490. if(WIN32)
  491. # In windows, automatic linking is performed, so you do not have
  492. # to specify the libraries. If you are linking to a dynamic
  493. # runtime, then you can choose to link to either a static or a
  494. # dynamic Boost library, the default is to do a static link. You
  495. # can alter this for a specific library "whatever" by defining
  496. # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be
  497. # linked dynamically. Alternatively you can force all Boost
  498. # libraries to dynamic link by defining BOOST_ALL_DYN_LINK.
  499. # This feature can be disabled for Boost library "whatever" by
  500. # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining
  501. # BOOST_ALL_NO_LIB.
  502. # If you want to observe which libraries are being linked against
  503. # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking
  504. # code to emit a #pragma message each time a library is selected
  505. # for linking.
  506. set(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC")
  507. endif()
  508. _Boost_CHECK_SPELLING(Boost_ROOT)
  509. _Boost_CHECK_SPELLING(Boost_LIBRARYDIR)
  510. _Boost_CHECK_SPELLING(Boost_INCLUDEDIR)
  511. # Collect environment variable inputs as hints. Do not consider changes.
  512. foreach(v BOOSTROOT BOOST_ROOT BOOST_INCLUDEDIR BOOST_LIBRARYDIR)
  513. set(_env $ENV{${v}})
  514. if(_env)
  515. file(TO_CMAKE_PATH "${_env}" _ENV_${v})
  516. else()
  517. set(_ENV_${v} "")
  518. endif()
  519. endforeach()
  520. if(NOT _ENV_BOOST_ROOT AND _ENV_BOOSTROOT)
  521. set(_ENV_BOOST_ROOT "${_ENV_BOOSTROOT}")
  522. endif()
  523. # Collect inputs and cached results. Detect changes since the last run.
  524. if(NOT BOOST_ROOT AND BOOSTROOT)
  525. set(BOOST_ROOT "${BOOSTROOT}")
  526. endif()
  527. set(_Boost_VARS_DIR
  528. BOOST_ROOT
  529. Boost_NO_SYSTEM_PATHS
  530. )
  531. if(Boost_DEBUG)
  532. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  533. "Declared as CMake or Environmental Variables:")
  534. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  535. " BOOST_ROOT = ${BOOST_ROOT}")
  536. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  537. " BOOST_INCLUDEDIR = ${BOOST_INCLUDEDIR}")
  538. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  539. " BOOST_LIBRARYDIR = ${BOOST_LIBRARYDIR}")
  540. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  541. "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
  542. endif()
  543. # ------------------------------------------------------------------------
  544. # Search for Boost include DIR
  545. # ------------------------------------------------------------------------
  546. set(_Boost_VARS_INC BOOST_INCLUDEDIR Boost_INCLUDE_DIR Boost_ADDITIONAL_VERSIONS)
  547. _Boost_CHANGE_DETECT(_Boost_CHANGE_INCDIR ${_Boost_VARS_DIR} ${_Boost_VARS_INC})
  548. # Clear Boost_INCLUDE_DIR if it did not change but other input affecting the
  549. # location did. We will find a new one based on the new inputs.
  550. if(_Boost_CHANGE_INCDIR AND NOT _Boost_INCLUDE_DIR_CHANGED)
  551. unset(Boost_INCLUDE_DIR CACHE)
  552. endif()
  553. if(NOT Boost_INCLUDE_DIR)
  554. set(_boost_INCLUDE_SEARCH_DIRS "")
  555. if(BOOST_INCLUDEDIR)
  556. list(APPEND _boost_INCLUDE_SEARCH_DIRS ${BOOST_INCLUDEDIR})
  557. elseif(_ENV_BOOST_INCLUDEDIR)
  558. list(APPEND _boost_INCLUDE_SEARCH_DIRS ${_ENV_BOOST_INCLUDEDIR})
  559. endif()
  560. if( BOOST_ROOT )
  561. list(APPEND _boost_INCLUDE_SEARCH_DIRS ${BOOST_ROOT}/include ${BOOST_ROOT})
  562. elseif( _ENV_BOOST_ROOT )
  563. list(APPEND _boost_INCLUDE_SEARCH_DIRS ${_ENV_BOOST_ROOT}/include ${_ENV_BOOST_ROOT})
  564. endif()
  565. if( Boost_NO_SYSTEM_PATHS)
  566. list(APPEND _boost_INCLUDE_SEARCH_DIRS NO_CMAKE_SYSTEM_PATH)
  567. else()
  568. list(APPEND _boost_INCLUDE_SEARCH_DIRS PATHS
  569. C:/boost/include
  570. C:/boost
  571. /sw/local/include
  572. )
  573. endif()
  574. # Try to find Boost by stepping backwards through the Boost versions
  575. # we know about.
  576. # Build a list of path suffixes for each version.
  577. set(_boost_PATH_SUFFIXES)
  578. foreach(_boost_VER ${_boost_TEST_VERSIONS})
  579. # Add in a path suffix, based on the required version, ideally
  580. # we could read this from version.hpp, but for that to work we'd
  581. # need to know the include dir already
  582. set(_boost_BOOSTIFIED_VERSION)
  583. # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0
  584. if(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
  585. string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3"
  586. _boost_BOOSTIFIED_VERSION ${_boost_VER})
  587. elseif(_boost_VER MATCHES "[0-9]+\\.[0-9]+")
  588. string(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2"
  589. _boost_BOOSTIFIED_VERSION ${_boost_VER})
  590. endif()
  591. list(APPEND _boost_PATH_SUFFIXES
  592. "boost-${_boost_BOOSTIFIED_VERSION}"
  593. "boost_${_boost_BOOSTIFIED_VERSION}"
  594. "boost/boost-${_boost_BOOSTIFIED_VERSION}"
  595. "boost/boost_${_boost_BOOSTIFIED_VERSION}"
  596. )
  597. endforeach()
  598. if(Boost_DEBUG)
  599. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  600. "Include debugging info:")
  601. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  602. " _boost_INCLUDE_SEARCH_DIRS = ${_boost_INCLUDE_SEARCH_DIRS}")
  603. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  604. " _boost_PATH_SUFFIXES = ${_boost_PATH_SUFFIXES}")
  605. endif()
  606. # Look for a standard boost header file.
  607. find_path(Boost_INCLUDE_DIR
  608. NAMES boost/config.hpp
  609. HINTS ${_boost_INCLUDE_SEARCH_DIRS}
  610. PATH_SUFFIXES ${_boost_PATH_SUFFIXES}
  611. )
  612. endif()
  613. # ------------------------------------------------------------------------
  614. # Extract version information from version.hpp
  615. # ------------------------------------------------------------------------
  616. # Set Boost_FOUND based only on header location and version.
  617. # It will be updated below for component libraries.
  618. if(Boost_INCLUDE_DIR)
  619. if(Boost_DEBUG)
  620. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  621. "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp")
  622. endif()
  623. # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp
  624. set(Boost_VERSION 0)
  625. set(Boost_LIB_VERSION "")
  626. file(STRINGS "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS REGEX "#define BOOST_(LIB_)?VERSION ")
  627. set(_Boost_VERSION_REGEX "([0-9]+)")
  628. set(_Boost_LIB_VERSION_REGEX "\"([0-9_]+)\"")
  629. foreach(v VERSION LIB_VERSION)
  630. if("${_boost_VERSION_HPP_CONTENTS}" MATCHES ".*#define BOOST_${v} ${_Boost_${v}_REGEX}.*")
  631. set(Boost_${v} "${CMAKE_MATCH_1}")
  632. endif()
  633. endforeach()
  634. unset(_boost_VERSION_HPP_CONTENTS)
  635. math(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
  636. math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
  637. math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
  638. set(Boost_ERROR_REASON
  639. "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}")
  640. if(Boost_DEBUG)
  641. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  642. "version.hpp reveals boost "
  643. "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
  644. endif()
  645. if(Boost_FIND_VERSION)
  646. # Set Boost_FOUND based on requested version.
  647. set(_Boost_VERSION "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
  648. if("${_Boost_VERSION}" VERSION_LESS "${Boost_FIND_VERSION}")
  649. set(Boost_FOUND 0)
  650. set(_Boost_VERSION_AGE "old")
  651. elseif(Boost_FIND_VERSION_EXACT AND
  652. NOT "${_Boost_VERSION}" VERSION_EQUAL "${Boost_FIND_VERSION}")
  653. set(Boost_FOUND 0)
  654. set(_Boost_VERSION_AGE "new")
  655. else()
  656. set(Boost_FOUND 1)
  657. endif()
  658. if(NOT Boost_FOUND)
  659. # State that we found a version of Boost that is too new or too old.
  660. set(Boost_ERROR_REASON
  661. "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  662. if (Boost_FIND_VERSION_PATCH)
  663. set(Boost_ERROR_REASON
  664. "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}")
  665. endif ()
  666. if (NOT Boost_FIND_VERSION_EXACT)
  667. set(Boost_ERROR_REASON "${Boost_ERROR_REASON} (or newer)")
  668. endif ()
  669. set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.")
  670. endif ()
  671. else()
  672. # Caller will accept any Boost version.
  673. set(Boost_FOUND 1)
  674. endif()
  675. else()
  676. set(Boost_FOUND 0)
  677. set(Boost_ERROR_REASON
  678. "${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.")
  679. endif()
  680. # ------------------------------------------------------------------------
  681. # Suffix initialization and compiler suffix detection.
  682. # ------------------------------------------------------------------------
  683. set(_Boost_VARS_NAME
  684. Boost_COMPILER
  685. Boost_THREADAPI
  686. Boost_USE_DEBUG_PYTHON
  687. Boost_USE_MULTITHREADED
  688. Boost_USE_STATIC_LIBS
  689. Boost_USE_STATIC_RUNTIME
  690. Boost_USE_STLPORT
  691. Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS
  692. )
  693. _Boost_CHANGE_DETECT(_Boost_CHANGE_LIBNAME ${_Boost_VARS_NAME})
  694. # Setting some more suffixes for the library
  695. set(Boost_LIB_PREFIX "")
  696. if ( WIN32 AND Boost_USE_STATIC_LIBS AND NOT CYGWIN)
  697. set(Boost_LIB_PREFIX "lib")
  698. endif()
  699. if (Boost_COMPILER)
  700. set(_boost_COMPILER ${Boost_COMPILER})
  701. if(Boost_DEBUG)
  702. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  703. "using user-specified Boost_COMPILER = ${_boost_COMPILER}")
  704. endif()
  705. else()
  706. # Attempt to guess the compiler suffix
  707. # NOTE: this is not perfect yet, if you experience any issues
  708. # please report them and use the Boost_COMPILER variable
  709. # to work around the problems.
  710. _Boost_GUESS_COMPILER_PREFIX(_boost_COMPILER)
  711. if(Boost_DEBUG)
  712. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  713. "guessed _boost_COMPILER = ${_boost_COMPILER}")
  714. endif()
  715. endif()
  716. set (_boost_MULTITHREADED "-mt")
  717. if( NOT Boost_USE_MULTITHREADED )
  718. set (_boost_MULTITHREADED "")
  719. endif()
  720. if(Boost_DEBUG)
  721. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  722. "_boost_MULTITHREADED = ${_boost_MULTITHREADED}")
  723. endif()
  724. #======================
  725. # Systematically build up the Boost ABI tag
  726. # http://boost.org/doc/libs/1_41_0/more/getting_started/windows.html#library-naming
  727. set( _boost_RELEASE_ABI_TAG "-")
  728. set( _boost_DEBUG_ABI_TAG "-")
  729. # Key Use this library when:
  730. # s linking statically to the C++ standard library and
  731. # compiler runtime support libraries.
  732. if(Boost_USE_STATIC_RUNTIME)
  733. set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}s")
  734. set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}s")
  735. endif()
  736. # g using debug versions of the standard and runtime
  737. # support libraries
  738. if(WIN32 AND Boost_USE_DEBUG_RUNTIME)
  739. if(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl"
  740. OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
  741. set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}g")
  742. endif()
  743. endif()
  744. # y using special debug build of python
  745. if(Boost_USE_DEBUG_PYTHON)
  746. set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}y")
  747. endif()
  748. # d using a debug version of your code
  749. set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}d")
  750. # p using the STLport standard library rather than the
  751. # default one supplied with your compiler
  752. if(Boost_USE_STLPORT)
  753. set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}p")
  754. set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}p")
  755. endif()
  756. # n using the STLport deprecated "native iostreams" feature
  757. if(Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS)
  758. set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}n")
  759. set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}n")
  760. endif()
  761. if(Boost_DEBUG)
  762. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  763. "_boost_RELEASE_ABI_TAG = ${_boost_RELEASE_ABI_TAG}")
  764. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  765. "_boost_DEBUG_ABI_TAG = ${_boost_DEBUG_ABI_TAG}")
  766. endif()
  767. # ------------------------------------------------------------------------
  768. # Begin finding boost libraries
  769. # ------------------------------------------------------------------------
  770. set(_Boost_VARS_LIB BOOST_LIBRARYDIR Boost_LIBRARY_DIR)
  771. _Boost_CHANGE_DETECT(_Boost_CHANGE_LIBDIR ${_Boost_VARS_DIR} ${_Boost_VARS_LIB} Boost_INCLUDE_DIR)
  772. # Clear Boost_LIBRARY_DIR if it did not change but other input affecting the
  773. # location did. We will find a new one based on the new inputs.
  774. if(_Boost_CHANGE_LIBDIR AND NOT _Boost_LIBRARY_DIR_CHANGED)
  775. unset(Boost_LIBRARY_DIR CACHE)
  776. endif()
  777. if(Boost_LIBRARY_DIR)
  778. set(_boost_LIBRARY_SEARCH_DIRS ${Boost_LIBRARY_DIR} NO_DEFAULT_PATH)
  779. else()
  780. set(_boost_LIBRARY_SEARCH_DIRS "")
  781. if(BOOST_LIBRARYDIR)
  782. list(APPEND _boost_LIBRARY_SEARCH_DIRS ${BOOST_LIBRARYDIR})
  783. elseif(_ENV_BOOST_LIBRARYDIR)
  784. list(APPEND _boost_LIBRARY_SEARCH_DIRS ${_ENV_BOOST_LIBRARYDIR})
  785. endif()
  786. if(BOOST_ROOT)
  787. list(APPEND _boost_LIBRARY_SEARCH_DIRS ${BOOST_ROOT}/lib ${BOOST_ROOT}/stage/lib)
  788. elseif(_ENV_BOOST_ROOT)
  789. list(APPEND _boost_LIBRARY_SEARCH_DIRS ${_ENV_BOOST_ROOT}/lib ${_ENV_BOOST_ROOT}/stage/lib)
  790. endif()
  791. list(APPEND _boost_LIBRARY_SEARCH_DIRS
  792. ${Boost_INCLUDE_DIR}/lib
  793. ${Boost_INCLUDE_DIR}/../lib
  794. ${Boost_INCLUDE_DIR}/stage/lib
  795. )
  796. if( Boost_NO_SYSTEM_PATHS )
  797. list(APPEND _boost_LIBRARY_SEARCH_DIRS NO_CMAKE_SYSTEM_PATH)
  798. else()
  799. list(APPEND _boost_LIBRARY_SEARCH_DIRS PATHS
  800. C:/boost/lib
  801. C:/boost
  802. /sw/local/lib
  803. )
  804. endif()
  805. endif()
  806. if(Boost_DEBUG)
  807. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  808. "_boost_LIBRARY_SEARCH_DIRS = ${_boost_LIBRARY_SEARCH_DIRS}")
  809. endif()
  810. # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
  811. if( Boost_USE_STATIC_LIBS )
  812. set( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
  813. if(WIN32)
  814. set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
  815. else()
  816. set(CMAKE_FIND_LIBRARY_SUFFIXES .a )
  817. endif()
  818. endif()
  819. # We want to use the tag inline below without risking double dashes
  820. if(_boost_RELEASE_ABI_TAG)
  821. if(${_boost_RELEASE_ABI_TAG} STREQUAL "-")
  822. set(_boost_RELEASE_ABI_TAG "")
  823. endif()
  824. endif()
  825. if(_boost_DEBUG_ABI_TAG)
  826. if(${_boost_DEBUG_ABI_TAG} STREQUAL "-")
  827. set(_boost_DEBUG_ABI_TAG "")
  828. endif()
  829. endif()
  830. # The previous behavior of FindBoost when Boost_USE_STATIC_LIBS was enabled
  831. # on WIN32 was to:
  832. # 1. Search for static libs compiled against a SHARED C++ standard runtime library (use if found)
  833. # 2. Search for static libs compiled against a STATIC C++ standard runtime library (use if found)
  834. # We maintain this behavior since changing it could break people's builds.
  835. # To disable the ambiguous behavior, the user need only
  836. # set Boost_USE_STATIC_RUNTIME either ON or OFF.
  837. set(_boost_STATIC_RUNTIME_WORKAROUND false)
  838. if(WIN32 AND Boost_USE_STATIC_LIBS)
  839. if(NOT DEFINED Boost_USE_STATIC_RUNTIME)
  840. set(_boost_STATIC_RUNTIME_WORKAROUND true)
  841. endif()
  842. endif()
  843. # On versions < 1.35, remove the System library from the considered list
  844. # since it wasn't added until 1.35.
  845. if(Boost_VERSION AND Boost_FIND_COMPONENTS)
  846. if(Boost_VERSION LESS 103500)
  847. list(REMOVE_ITEM Boost_FIND_COMPONENTS system)
  848. endif()
  849. endif()
  850. # If the user changed any of our control inputs flush previous results.
  851. if(_Boost_CHANGE_LIBDIR OR _Boost_CHANGE_LIBNAME)
  852. foreach(COMPONENT ${_Boost_COMPONENTS_SEARCHED})
  853. string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  854. foreach(c DEBUG RELEASE)
  855. set(_var Boost_${UPPERCOMPONENT}_LIBRARY_${c})
  856. unset(${_var} CACHE)
  857. set(${_var} "${_var}-NOTFOUND")
  858. endforeach()
  859. endforeach()
  860. set(_Boost_COMPONENTS_SEARCHED "")
  861. endif()
  862. foreach(COMPONENT ${Boost_FIND_COMPONENTS})
  863. string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  864. set( _boost_docstring_release "Boost ${COMPONENT} library (release)")
  865. set( _boost_docstring_debug "Boost ${COMPONENT} library (debug)")
  866. # Compute component-specific hints.
  867. set(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT "")
  868. if(${COMPONENT} STREQUAL "mpi" OR ${COMPONENT} STREQUAL "mpi_python")
  869. foreach(lib ${MPI_CXX_LIBRARIES} ${MPI_C_LIBRARIES})
  870. if(IS_ABSOLUTE "${lib}")
  871. get_filename_component(libdir "${lib}" PATH)
  872. string(REPLACE "\\" "/" libdir "${libdir}")
  873. list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT ${libdir})
  874. endif()
  875. endforeach()
  876. endif()
  877. # Consolidate and report component-specific hints.
  878. if(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT)
  879. list(REMOVE_DUPLICATES _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT)
  880. if(Boost_DEBUG)
  881. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  882. "Component-specific library search paths for ${COMPONENT}: "
  883. "${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT}")
  884. endif()
  885. endif()
  886. #
  887. # Find RELEASE libraries
  888. #
  889. set(_boost_RELEASE_NAMES
  890. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
  891. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
  892. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
  893. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
  894. ${Boost_LIB_PREFIX}boost_${COMPONENT} )
  895. if(_boost_STATIC_RUNTIME_WORKAROUND)
  896. set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}")
  897. list(APPEND _boost_RELEASE_NAMES
  898. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
  899. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}
  900. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
  901. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} )
  902. endif()
  903. if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread")
  904. _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_RELEASE_NAMES ${_boost_RELEASE_NAMES})
  905. endif()
  906. if(Boost_DEBUG)
  907. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  908. "Searching for ${UPPERCOMPONENT}_LIBRARY_RELEASE: ${_boost_RELEASE_NAMES}")
  909. endif()
  910. # Avoid passing backslashes to _Boost_FIND_LIBRARY due to macro re-parsing.
  911. string(REPLACE "\\" "/" _boost_LIBRARY_SEARCH_DIRS_tmp "${_boost_LIBRARY_SEARCH_DIRS}")
  912. _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE
  913. NAMES ${_boost_RELEASE_NAMES}
  914. HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp}
  915. NAMES_PER_DIR
  916. DOC "${_boost_docstring_release}"
  917. )
  918. #
  919. # Find DEBUG libraries
  920. #
  921. set(_boost_DEBUG_NAMES
  922. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
  923. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
  924. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
  925. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
  926. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}
  927. ${Boost_LIB_PREFIX}boost_${COMPONENT} )
  928. if(_boost_STATIC_RUNTIME_WORKAROUND)
  929. set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}")
  930. list(APPEND _boost_DEBUG_NAMES
  931. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
  932. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}
  933. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
  934. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} )
  935. endif()
  936. if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread")
  937. _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_DEBUG_NAMES ${_boost_DEBUG_NAMES})
  938. endif()
  939. if(Boost_DEBUG)
  940. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  941. "Searching for ${UPPERCOMPONENT}_LIBRARY_DEBUG: ${_boost_DEBUG_NAMES}")
  942. endif()
  943. # Avoid passing backslashes to _Boost_FIND_LIBRARY due to macro re-parsing.
  944. string(REPLACE "\\" "/" _boost_LIBRARY_SEARCH_DIRS_tmp "${_boost_LIBRARY_SEARCH_DIRS}")
  945. _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG
  946. NAMES ${_boost_DEBUG_NAMES}
  947. HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp}
  948. NAMES_PER_DIR
  949. DOC "${_boost_docstring_debug}"
  950. )
  951. if(Boost_REALPATH)
  952. _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "${_boost_docstring_release}")
  953. _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "${_boost_docstring_debug}" )
  954. endif()
  955. _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT})
  956. endforeach()
  957. # Restore the original find library ordering
  958. if( Boost_USE_STATIC_LIBS )
  959. set(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
  960. endif()
  961. # ------------------------------------------------------------------------
  962. # End finding boost libraries
  963. # ------------------------------------------------------------------------
  964. set(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
  965. set(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIR})
  966. # The above setting of Boost_FOUND was based only on the header files.
  967. # Update it for the requested component libraries.
  968. if(Boost_FOUND)
  969. # The headers were found. Check for requested component libs.
  970. set(_boost_CHECKED_COMPONENT FALSE)
  971. set(_Boost_MISSING_COMPONENTS "")
  972. foreach(COMPONENT ${Boost_FIND_COMPONENTS})
  973. string(TOUPPER ${COMPONENT} COMPONENT)
  974. set(_boost_CHECKED_COMPONENT TRUE)
  975. if(NOT Boost_${COMPONENT}_FOUND)
  976. string(TOLOWER ${COMPONENT} COMPONENT)
  977. list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT})
  978. endif()
  979. endforeach()
  980. if(Boost_DEBUG)
  981. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] Boost_FOUND = ${Boost_FOUND}")
  982. endif()
  983. if (_Boost_MISSING_COMPONENTS)
  984. set(Boost_FOUND 0)
  985. # We were unable to find some libraries, so generate a sensible
  986. # error message that lists the libraries we were unable to find.
  987. set(Boost_ERROR_REASON
  988. "${Boost_ERROR_REASON}\nCould not find the following")
  989. if(Boost_USE_STATIC_LIBS)
  990. set(Boost_ERROR_REASON "${Boost_ERROR_REASON} static")
  991. endif()
  992. set(Boost_ERROR_REASON
  993. "${Boost_ERROR_REASON} Boost libraries:\n")
  994. foreach(COMPONENT ${_Boost_MISSING_COMPONENTS})
  995. set(Boost_ERROR_REASON
  996. "${Boost_ERROR_REASON} boost_${COMPONENT}\n")
  997. endforeach()
  998. list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED)
  999. list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS)
  1000. if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
  1001. set(Boost_ERROR_REASON
  1002. "${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.")
  1003. else ()
  1004. set(Boost_ERROR_REASON
  1005. "${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.")
  1006. endif ()
  1007. endif ()
  1008. if( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
  1009. # Compatibility Code for backwards compatibility with CMake
  1010. # 2.4's FindBoost module.
  1011. # Look for the boost library path.
  1012. # Note that the user may not have installed any libraries
  1013. # so it is quite possible the Boost_LIBRARY_DIRS may not exist.
  1014. set(_boost_LIB_DIR ${Boost_INCLUDE_DIR})
  1015. if("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
  1016. get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
  1017. endif()
  1018. if("${_boost_LIB_DIR}" MATCHES "/include$")
  1019. # Strip off the trailing "/include" in the path.
  1020. get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
  1021. endif()
  1022. if(EXISTS "${_boost_LIB_DIR}/lib")
  1023. set(_boost_LIB_DIR ${_boost_LIB_DIR}/lib)
  1024. else()
  1025. if(EXISTS "${_boost_LIB_DIR}/stage/lib")
  1026. set(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib)
  1027. else()
  1028. set(_boost_LIB_DIR "")
  1029. endif()
  1030. endif()
  1031. if(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
  1032. set(Boost_LIBRARY_DIRS ${_boost_LIB_DIR})
  1033. endif()
  1034. endif()
  1035. else()
  1036. # Boost headers were not found so no components were found.
  1037. foreach(COMPONENT ${Boost_FIND_COMPONENTS})
  1038. string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  1039. set(Boost_${UPPERCOMPONENT}_FOUND 0)
  1040. endforeach()
  1041. endif()
  1042. # ------------------------------------------------------------------------
  1043. # Notification to end user about what was found
  1044. # ------------------------------------------------------------------------
  1045. set(Boost_LIBRARIES "")
  1046. if(Boost_FOUND)
  1047. if(NOT Boost_FIND_QUIETLY)
  1048. message(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
  1049. if(Boost_FIND_COMPONENTS)
  1050. message(STATUS "Found the following Boost libraries:")
  1051. endif()
  1052. endif()
  1053. foreach( COMPONENT ${Boost_FIND_COMPONENTS} )
  1054. string( TOUPPER ${COMPONENT} UPPERCOMPONENT )
  1055. if( Boost_${UPPERCOMPONENT}_FOUND )
  1056. if(NOT Boost_FIND_QUIETLY)
  1057. message (STATUS " ${COMPONENT}")
  1058. endif()
  1059. list(APPEND Boost_LIBRARIES ${Boost_${UPPERCOMPONENT}_LIBRARY})
  1060. endif()
  1061. endforeach()
  1062. else()
  1063. if(Boost_FIND_REQUIRED)
  1064. message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")
  1065. else()
  1066. if(NOT Boost_FIND_QUIETLY)
  1067. # we opt not to automatically output Boost_ERROR_REASON here as
  1068. # it could be quite lengthy and somewhat imposing in its requests
  1069. # Since Boost is not always a required dependency we'll leave this
  1070. # up to the end-user.
  1071. if(Boost_DEBUG OR Boost_DETAILED_FAILURE_MSG)
  1072. message(STATUS "Could NOT find Boost\n${Boost_ERROR_REASON}")
  1073. else()
  1074. message(STATUS "Could NOT find Boost")
  1075. endif()
  1076. endif()
  1077. endif()
  1078. endif()
  1079. # Configure display of cache entries in GUI.
  1080. foreach(v BOOSTROOT BOOST_ROOT ${_Boost_VARS_INC} ${_Boost_VARS_LIB})
  1081. get_property(_type CACHE ${v} PROPERTY TYPE)
  1082. if(_type)
  1083. set_property(CACHE ${v} PROPERTY ADVANCED 1)
  1084. if("x${_type}" STREQUAL "xUNINITIALIZED")
  1085. if("x${v}" STREQUAL "xBoost_ADDITIONAL_VERSIONS")
  1086. set_property(CACHE ${v} PROPERTY TYPE STRING)
  1087. else()
  1088. set_property(CACHE ${v} PROPERTY TYPE PATH)
  1089. endif()
  1090. endif()
  1091. endif()
  1092. endforeach()
  1093. # Record last used values of input variables so we can
  1094. # detect on the next run if the user changed them.
  1095. foreach(v
  1096. ${_Boost_VARS_INC} ${_Boost_VARS_LIB}
  1097. ${_Boost_VARS_DIR} ${_Boost_VARS_NAME}
  1098. )
  1099. if(DEFINED ${v})
  1100. set(_${v}_LAST "${${v}}" CACHE INTERNAL "Last used ${v} value.")
  1101. else()
  1102. unset(_${v}_LAST CACHE)
  1103. endif()
  1104. endforeach()
  1105. # Maintain a persistent list of components requested anywhere since
  1106. # the last flush.
  1107. set(_Boost_COMPONENTS_SEARCHED "${_Boost_COMPONENTS_SEARCHED}")
  1108. list(APPEND _Boost_COMPONENTS_SEARCHED ${Boost_FIND_COMPONENTS})
  1109. list(REMOVE_DUPLICATES _Boost_COMPONENTS_SEARCHED)
  1110. list(SORT _Boost_COMPONENTS_SEARCHED)
  1111. set(_Boost_COMPONENTS_SEARCHED "${_Boost_COMPONENTS_SEARCHED}"
  1112. CACHE INTERNAL "Components requested for this build tree.")