FindBoost.cmake 48 KB

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