FindBoost.cmake 83 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #.rst:
  4. # FindBoost
  5. # ---------
  6. #
  7. # Find Boost include dirs and libraries
  8. #
  9. # Use this module by invoking find_package with the form::
  10. #
  11. # find_package(Boost
  12. # [version] [EXACT] # Minimum or EXACT version e.g. 1.36.0
  13. # [REQUIRED] # Fail with error if Boost is not found
  14. # [COMPONENTS <libs>...] # Boost libraries by their canonical name
  15. # ) # e.g. "date_time" for "libboost_date_time"
  16. #
  17. # This module finds headers and requested component libraries OR a CMake
  18. # package configuration file provided by a "Boost CMake" build. For the
  19. # latter case skip to the "Boost CMake" section below. For the former
  20. # case results are reported in variables::
  21. #
  22. # Boost_FOUND - True if headers and requested libraries were found
  23. # Boost_INCLUDE_DIRS - Boost include directories
  24. # Boost_LIBRARY_DIRS - Link directories for Boost libraries
  25. # Boost_LIBRARIES - Boost component libraries to be linked
  26. # Boost_<C>_FOUND - True if component <C> was found (<C> is upper-case)
  27. # Boost_<C>_LIBRARY - Libraries to link for component <C> (may include
  28. # target_link_libraries debug/optimized keywords)
  29. # Boost_VERSION - BOOST_VERSION value from boost/version.hpp
  30. # Boost_LIB_VERSION - Version string appended to library filenames
  31. # Boost_MAJOR_VERSION - Boost major version number (X in X.y.z)
  32. # Boost_MINOR_VERSION - Boost minor version number (Y in x.Y.z)
  33. # Boost_SUBMINOR_VERSION - Boost subminor version number (Z in x.y.Z)
  34. # Boost_LIB_DIAGNOSTIC_DEFINITIONS (Windows)
  35. # - Pass to add_definitions() to have diagnostic
  36. # information about Boost's automatic linking
  37. # displayed during compilation
  38. #
  39. # This module reads hints about search locations from variables::
  40. #
  41. # BOOST_ROOT - Preferred installation prefix
  42. # (or BOOSTROOT)
  43. # BOOST_INCLUDEDIR - Preferred include directory e.g. <prefix>/include
  44. # BOOST_LIBRARYDIR - Preferred library directory e.g. <prefix>/lib
  45. # Boost_NO_SYSTEM_PATHS - Set to ON to disable searching in locations not
  46. # specified by these hint variables. Default is OFF.
  47. # Boost_ADDITIONAL_VERSIONS
  48. # - List of Boost versions not known to this module
  49. # (Boost install locations may contain the version)
  50. #
  51. # and saves search results persistently in CMake cache entries::
  52. #
  53. # Boost_INCLUDE_DIR - Directory containing Boost headers
  54. # Boost_LIBRARY_DIR_RELEASE - Directory containing release Boost libraries
  55. # Boost_LIBRARY_DIR_DEBUG - Directory containing debug Boost libraries
  56. # Boost_<C>_LIBRARY_DEBUG - Component <C> library debug variant
  57. # Boost_<C>_LIBRARY_RELEASE - Component <C> library release variant
  58. #
  59. # The following :prop_tgt:`IMPORTED` targets are also defined::
  60. #
  61. # Boost::boost - Target for header-only dependencies
  62. # (Boost include directory)
  63. # Boost::<C> - Target for specific component dependency
  64. # (shared or static library); <C> is lower-
  65. # case
  66. # Boost::diagnostic_definitions - interface target to enable diagnostic
  67. # information about Boost's automatic linking
  68. # during compilation (adds BOOST_LIB_DIAGNOSTIC)
  69. # Boost::disable_autolinking - interface target to disable automatic
  70. # linking with MSVC (adds BOOST_ALL_NO_LIB)
  71. # Boost::dynamic_linking - interface target to enable dynamic linking
  72. # linking with MSVC (adds BOOST_ALL_DYN_LINK)
  73. #
  74. # Implicit dependencies such as Boost::filesystem requiring
  75. # Boost::system will be automatically detected and satisfied, even
  76. # if system is not specified when using find_package and if
  77. # Boost::system is not added to target_link_libraries. If using
  78. # Boost::thread, then Thread::Thread will also be added automatically.
  79. #
  80. # It is important to note that the imported targets behave differently
  81. # than variables created by this module: multiple calls to
  82. # find_package(Boost) in the same directory or sub-directories with
  83. # different options (e.g. static or shared) will not override the
  84. # values of the targets created by the first call.
  85. #
  86. # Users may set these hints or results as cache entries. Projects
  87. # should not read these entries directly but instead use the above
  88. # result variables. Note that some hint names start in upper-case
  89. # "BOOST". One may specify these as environment variables if they are
  90. # not specified as CMake variables or cache entries.
  91. #
  92. # This module first searches for the Boost header files using the above
  93. # hint variables (excluding BOOST_LIBRARYDIR) and saves the result in
  94. # Boost_INCLUDE_DIR. Then it searches for requested component libraries
  95. # using the above hints (excluding BOOST_INCLUDEDIR and
  96. # Boost_ADDITIONAL_VERSIONS), "lib" directories near Boost_INCLUDE_DIR,
  97. # and the library name configuration settings below. It saves the
  98. # library directories in Boost_LIBRARY_DIR_DEBUG and
  99. # Boost_LIBRARY_DIR_RELEASE and individual library
  100. # locations in Boost_<C>_LIBRARY_DEBUG and Boost_<C>_LIBRARY_RELEASE.
  101. # When one changes settings used by previous searches in the same build
  102. # tree (excluding environment variables) this module discards previous
  103. # search results affected by the changes and searches again.
  104. #
  105. # Boost libraries come in many variants encoded in their file name.
  106. # Users or projects may tell this module which variant to find by
  107. # setting variables::
  108. #
  109. # Boost_USE_MULTITHREADED - Set to OFF to use the non-multithreaded
  110. # libraries ('mt' tag). Default is ON.
  111. # Boost_USE_STATIC_LIBS - Set to ON to force the use of the static
  112. # libraries. Default is OFF.
  113. # Boost_USE_STATIC_RUNTIME - Set to ON or OFF to specify whether to use
  114. # libraries linked statically to the C++ runtime
  115. # ('s' tag). Default is platform dependent.
  116. # Boost_USE_DEBUG_RUNTIME - Set to ON or OFF to specify whether to use
  117. # libraries linked to the MS debug C++ runtime
  118. # ('g' tag). Default is ON.
  119. # Boost_USE_DEBUG_PYTHON - Set to ON to use libraries compiled with a
  120. # debug Python build ('y' tag). Default is OFF.
  121. # Boost_USE_STLPORT - Set to ON to use libraries compiled with
  122. # STLPort ('p' tag). Default is OFF.
  123. # Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS
  124. # - Set to ON to use libraries compiled with
  125. # STLPort deprecated "native iostreams"
  126. # ('n' tag). Default is OFF.
  127. # Boost_COMPILER - Set to the compiler-specific library suffix
  128. # (e.g. "-gcc43"). Default is auto-computed
  129. # for the C++ compiler in use.
  130. # Boost_THREADAPI - Suffix for "thread" component library name,
  131. # such as "pthread" or "win32". Names with
  132. # and without this suffix will both be tried.
  133. # Boost_NAMESPACE - Alternate namespace used to build boost with
  134. # e.g. if set to "myboost", will search for
  135. # myboost_thread instead of boost_thread.
  136. #
  137. # Other variables one may set to control this module are::
  138. #
  139. # Boost_DEBUG - Set to ON to enable debug output from FindBoost.
  140. # Please enable this before filing any bug report.
  141. # Boost_DETAILED_FAILURE_MSG
  142. # - Set to ON to add detailed information to the
  143. # failure message even when the REQUIRED option
  144. # is not given to the find_package call.
  145. # Boost_REALPATH - Set to ON to resolve symlinks for discovered
  146. # libraries to assist with packaging. For example,
  147. # the "system" component library may be resolved to
  148. # "/usr/lib/libboost_system.so.1.42.0" instead of
  149. # "/usr/lib/libboost_system.so". This does not
  150. # affect linking and should not be enabled unless
  151. # the user needs this information.
  152. # Boost_LIBRARY_DIR - Default value for Boost_LIBRARY_DIR_RELEASE and
  153. # Boost_LIBRARY_DIR_DEBUG.
  154. #
  155. # On Visual Studio and Borland compilers Boost headers request automatic
  156. # linking to corresponding libraries. This requires matching libraries
  157. # to be linked explicitly or available in the link library search path.
  158. # In this case setting Boost_USE_STATIC_LIBS to OFF may not achieve
  159. # dynamic linking. Boost automatic linking typically requests static
  160. # libraries with a few exceptions (such as Boost.Python). Use::
  161. #
  162. # add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
  163. #
  164. # to ask Boost to report information about automatic linking requests.
  165. #
  166. # Example to find Boost headers only::
  167. #
  168. # find_package(Boost 1.36.0)
  169. # if(Boost_FOUND)
  170. # include_directories(${Boost_INCLUDE_DIRS})
  171. # add_executable(foo foo.cc)
  172. # endif()
  173. #
  174. # Example to find Boost libraries and use imported targets::
  175. #
  176. # find_package(Boost 1.56 REQUIRED COMPONENTS
  177. # date_time filesystem iostreams)
  178. # add_executable(foo foo.cc)
  179. # target_link_libraries(foo Boost::date_time Boost::filesystem
  180. # Boost::iostreams)
  181. #
  182. # Example to find Boost headers and some *static* libraries::
  183. #
  184. # set(Boost_USE_STATIC_LIBS ON) # only find static libs
  185. # set(Boost_USE_MULTITHREADED ON)
  186. # set(Boost_USE_STATIC_RUNTIME OFF)
  187. # find_package(Boost 1.36.0 COMPONENTS date_time filesystem system ...)
  188. # if(Boost_FOUND)
  189. # include_directories(${Boost_INCLUDE_DIRS})
  190. # add_executable(foo foo.cc)
  191. # target_link_libraries(foo ${Boost_LIBRARIES})
  192. # endif()
  193. #
  194. # Boost CMake
  195. # ^^^^^^^^^^^
  196. #
  197. # If Boost was built using the boost-cmake project it provides a package
  198. # configuration file for use with find_package's Config mode. This
  199. # module looks for the package configuration file called
  200. # BoostConfig.cmake or boost-config.cmake and stores the result in cache
  201. # entry "Boost_DIR". If found, the package configuration file is loaded
  202. # and this module returns with no further action. See documentation of
  203. # the Boost CMake package configuration for details on what it provides.
  204. #
  205. # Set Boost_NO_BOOST_CMAKE to ON to disable the search for boost-cmake.
  206. #-------------------------------------------------------------------------------
  207. # Before we go searching, check whether boost-cmake is available, unless the
  208. # user specifically asked NOT to search for boost-cmake.
  209. #
  210. # If Boost_DIR is set, this behaves as any find_package call would. If not,
  211. # it looks at BOOST_ROOT and BOOSTROOT to find Boost.
  212. #
  213. if (NOT Boost_NO_BOOST_CMAKE)
  214. # If Boost_DIR is not set, look for BOOSTROOT and BOOST_ROOT as alternatives,
  215. # since these are more conventional for Boost.
  216. if ("$ENV{Boost_DIR}" STREQUAL "")
  217. if (NOT "$ENV{BOOST_ROOT}" STREQUAL "")
  218. set(ENV{Boost_DIR} $ENV{BOOST_ROOT})
  219. elseif (NOT "$ENV{BOOSTROOT}" STREQUAL "")
  220. set(ENV{Boost_DIR} $ENV{BOOSTROOT})
  221. endif()
  222. endif()
  223. # Do the same find_package call but look specifically for the CMake version.
  224. # Note that args are passed in the Boost_FIND_xxxxx variables, so there is no
  225. # need to delegate them to this find_package call.
  226. find_package(Boost QUIET NO_MODULE)
  227. mark_as_advanced(Boost_DIR)
  228. # If we found boost-cmake, then we're done. Print out what we found.
  229. # Otherwise let the rest of the module try to find it.
  230. if (Boost_FOUND)
  231. message("Boost ${Boost_FIND_VERSION} found.")
  232. if (Boost_FIND_COMPONENTS)
  233. message("Found Boost components:")
  234. message(" ${Boost_FIND_COMPONENTS}")
  235. endif()
  236. return()
  237. endif()
  238. endif()
  239. #-------------------------------------------------------------------------------
  240. # FindBoost functions & macros
  241. #
  242. ############################################
  243. #
  244. # Check the existence of the libraries.
  245. #
  246. ############################################
  247. # This macro was taken directly from the FindQt4.cmake file that is included
  248. # with the CMake distribution. This is NOT my work. All work was done by the
  249. # original authors of the FindQt4.cmake file. Only minor modifications were
  250. # made to remove references to Qt and make this file more generally applicable
  251. # And ELSE/ENDIF pairs were removed for readability.
  252. #########################################################################
  253. macro(_Boost_ADJUST_LIB_VARS basename)
  254. if(Boost_INCLUDE_DIR )
  255. if(Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
  256. # if the generator supports configuration types then set
  257. # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
  258. if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
  259. set(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
  260. else()
  261. # if there are no configuration types and CMAKE_BUILD_TYPE has no value
  262. # then just use the release libraries
  263. set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
  264. endif()
  265. # FIXME: This probably should be set for both cases
  266. set(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
  267. endif()
  268. # if only the release version was found, set the debug variable also to the release version
  269. if(Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG)
  270. set(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE})
  271. set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE})
  272. set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE})
  273. endif()
  274. # if only the debug version was found, set the release variable also to the debug version
  275. if(Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE)
  276. set(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG})
  277. set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG})
  278. set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG})
  279. endif()
  280. # If the debug & release library ends up being the same, omit the keywords
  281. if(${Boost_${basename}_LIBRARY_RELEASE} STREQUAL ${Boost_${basename}_LIBRARY_DEBUG})
  282. set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
  283. set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE} )
  284. endif()
  285. if(Boost_${basename}_LIBRARY AND Boost_${basename}_HEADER)
  286. set(Boost_${basename}_FOUND ON)
  287. endif()
  288. endif()
  289. # Make variables changeable to the advanced user
  290. mark_as_advanced(
  291. Boost_${basename}_LIBRARY_RELEASE
  292. Boost_${basename}_LIBRARY_DEBUG
  293. )
  294. endmacro()
  295. # Detect changes in used variables.
  296. # Compares the current variable value with the last one.
  297. # In short form:
  298. # v != v_LAST -> CHANGED = 1
  299. # v is defined, v_LAST not -> CHANGED = 1
  300. # v is not defined, but v_LAST is -> CHANGED = 1
  301. # otherwise -> CHANGED = 0
  302. # CHANGED is returned in variable named ${changed_var}
  303. macro(_Boost_CHANGE_DETECT changed_var)
  304. set(${changed_var} 0)
  305. foreach(v ${ARGN})
  306. if(DEFINED _Boost_COMPONENTS_SEARCHED)
  307. if(${v})
  308. if(_${v}_LAST)
  309. string(COMPARE NOTEQUAL "${${v}}" "${_${v}_LAST}" _${v}_CHANGED)
  310. else()
  311. set(_${v}_CHANGED 1)
  312. endif()
  313. elseif(_${v}_LAST)
  314. set(_${v}_CHANGED 1)
  315. endif()
  316. if(_${v}_CHANGED)
  317. set(${changed_var} 1)
  318. endif()
  319. else()
  320. set(_${v}_CHANGED 0)
  321. endif()
  322. endforeach()
  323. endmacro()
  324. #
  325. # Find the given library (var).
  326. # Use 'build_type' to support different lib paths for RELEASE or DEBUG builds
  327. #
  328. macro(_Boost_FIND_LIBRARY var build_type)
  329. find_library(${var} ${ARGN})
  330. if(${var})
  331. # If this is the first library found then save Boost_LIBRARY_DIR_[RELEASE,DEBUG].
  332. if(NOT Boost_LIBRARY_DIR_${build_type})
  333. get_filename_component(_dir "${${var}}" PATH)
  334. set(Boost_LIBRARY_DIR_${build_type} "${_dir}" CACHE PATH "Boost library directory ${build_type}" FORCE)
  335. endif()
  336. elseif(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT)
  337. # Try component-specific hints but do not save Boost_LIBRARY_DIR_[RELEASE,DEBUG].
  338. find_library(${var} HINTS ${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT} ${ARGN})
  339. endif()
  340. # If Boost_LIBRARY_DIR_[RELEASE,DEBUG] is known then search only there.
  341. if(Boost_LIBRARY_DIR_${build_type})
  342. set(_boost_LIBRARY_SEARCH_DIRS_${build_type} ${Boost_LIBRARY_DIR_${build_type}} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
  343. if(Boost_DEBUG)
  344. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  345. " Boost_LIBRARY_DIR_${build_type} = ${Boost_LIBRARY_DIR_${build_type}}"
  346. " _boost_LIBRARY_SEARCH_DIRS_${build_type} = ${_boost_LIBRARY_SEARCH_DIRS_${build_type}}")
  347. endif()
  348. endif()
  349. endmacro()
  350. #-------------------------------------------------------------------------------
  351. #
  352. # Runs compiler with "-dumpversion" and parses major/minor
  353. # version with a regex.
  354. #
  355. function(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION)
  356. exec_program(${CMAKE_CXX_COMPILER}
  357. ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
  358. OUTPUT_VARIABLE _boost_COMPILER_VERSION
  359. )
  360. string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
  361. _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
  362. set(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE)
  363. endfunction()
  364. #
  365. # Take a list of libraries with "thread" in it
  366. # and prepend duplicates with "thread_${Boost_THREADAPI}"
  367. # at the front of the list
  368. #
  369. function(_Boost_PREPEND_LIST_WITH_THREADAPI _output)
  370. set(_orig_libnames ${ARGN})
  371. string(REPLACE "thread" "thread_${Boost_THREADAPI}" _threadapi_libnames "${_orig_libnames}")
  372. set(${_output} ${_threadapi_libnames} ${_orig_libnames} PARENT_SCOPE)
  373. endfunction()
  374. #
  375. # If a library is found, replace its cache entry with its REALPATH
  376. #
  377. function(_Boost_SWAP_WITH_REALPATH _library _docstring)
  378. if(${_library})
  379. get_filename_component(_boost_filepathreal ${${_library}} REALPATH)
  380. unset(${_library} CACHE)
  381. set(${_library} ${_boost_filepathreal} CACHE FILEPATH "${_docstring}")
  382. endif()
  383. endfunction()
  384. function(_Boost_CHECK_SPELLING _var)
  385. if(${_var})
  386. string(TOUPPER ${_var} _var_UC)
  387. message(FATAL_ERROR "ERROR: ${_var} is not the correct spelling. The proper spelling is ${_var_UC}.")
  388. endif()
  389. endfunction()
  390. # Guesses Boost's compiler prefix used in built library names
  391. # Returns the guess by setting the variable pointed to by _ret
  392. function(_Boost_GUESS_COMPILER_PREFIX _ret)
  393. if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel"
  394. OR CMAKE_CXX_COMPILER MATCHES "icl"
  395. OR CMAKE_CXX_COMPILER MATCHES "icpc")
  396. if(WIN32)
  397. set (_boost_COMPILER "-iw")
  398. else()
  399. set (_boost_COMPILER "-il")
  400. endif()
  401. elseif (GHSMULTI)
  402. set(_boost_COMPILER "-ghs")
  403. elseif("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
  404. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10)
  405. set(_boost_COMPILER "-vc141")
  406. elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19)
  407. set(_boost_COMPILER "-vc140")
  408. elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18)
  409. set(_boost_COMPILER "-vc120")
  410. elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17)
  411. set(_boost_COMPILER "-vc110")
  412. elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
  413. set(_boost_COMPILER "-vc100")
  414. elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15)
  415. set(_boost_COMPILER "-vc90")
  416. elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14)
  417. set(_boost_COMPILER "-vc80")
  418. elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.10)
  419. set(_boost_COMPILER "-vc71")
  420. elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13) # Good luck!
  421. set(_boost_COMPILER "-vc7") # yes, this is correct
  422. else() # MSVC60 Good luck!
  423. set(_boost_COMPILER "-vc6") # yes, this is correct
  424. endif()
  425. elseif (BORLAND)
  426. set(_boost_COMPILER "-bcb")
  427. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
  428. set(_boost_COMPILER "-sw")
  429. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "XL")
  430. set(_boost_COMPILER "-xlc")
  431. elseif (MINGW)
  432. if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
  433. set(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34
  434. else()
  435. _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
  436. set(_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}")
  437. endif()
  438. elseif (UNIX)
  439. if (CMAKE_COMPILER_IS_GNUCXX)
  440. if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
  441. set(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34
  442. else()
  443. _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
  444. # Determine which version of GCC we have.
  445. if(APPLE)
  446. if(Boost_MINOR_VERSION)
  447. if(${Boost_MINOR_VERSION} GREATER 35)
  448. # In Boost 1.36.0 and newer, the mangled compiler name used
  449. # on Mac OS X/Darwin is "xgcc".
  450. set(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}")
  451. else()
  452. # In Boost <= 1.35.0, there is no mangled compiler name for
  453. # the Mac OS X/Darwin version of GCC.
  454. set(_boost_COMPILER "")
  455. endif()
  456. else()
  457. # We don't know the Boost version, so assume it's
  458. # pre-1.36.0.
  459. set(_boost_COMPILER "")
  460. endif()
  461. else()
  462. set(_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}")
  463. endif()
  464. endif()
  465. endif ()
  466. else()
  467. # TODO at least Boost_DEBUG here?
  468. set(_boost_COMPILER "")
  469. endif()
  470. set(${_ret} ${_boost_COMPILER} PARENT_SCOPE)
  471. endfunction()
  472. #
  473. # Get component dependencies. Requires the dependencies to have been
  474. # defined for the Boost release version.
  475. #
  476. # component - the component to check
  477. # _ret - list of library dependencies
  478. #
  479. function(_Boost_COMPONENT_DEPENDENCIES component _ret)
  480. # Note: to add a new Boost release, run
  481. #
  482. # % cmake -DBOOST_DIR=/path/to/boost/source -P Utilities/Scripts/BoostScanDeps.cmake
  483. #
  484. # The output may be added in a new block below. If it's the same as
  485. # the previous release, simply update the version range of the block
  486. # for the previous release. Also check if any new components have
  487. # been added, and add any new components to
  488. # _Boost_COMPONENT_HEADERS.
  489. #
  490. # This information was originally generated by running
  491. # BoostScanDeps.cmake against every boost release to date supported
  492. # by FindBoost:
  493. #
  494. # % for version in /path/to/boost/sources/*
  495. # do
  496. # cmake -DBOOST_DIR=$version -P Utilities/Scripts/BoostScanDeps.cmake
  497. # done
  498. #
  499. # The output was then updated by search and replace with these regexes:
  500. #
  501. # - Strip message(STATUS) prefix dashes
  502. # s;^-- ;;
  503. # - Indent
  504. # s;^set(; set(;;
  505. # - Add conditionals
  506. # s;Scanning /path/to/boost/sources/boost_\(.*\)_\(.*\)_\(.*); elseif(NOT Boost_VERSION VERSION_LESS \10\20\3 AND Boost_VERSION VERSION_LESS xxxx);
  507. #
  508. # This results in the logic seen below, but will require the xxxx
  509. # replacing with the following Boost release version (or the next
  510. # minor version to be released, e.g. 1.59 was the latest at the time
  511. # of writing, making 1.60 the next, so 106000 is the needed version
  512. # number). Identical consecutive releases were then merged together
  513. # by updating the end range of the first block and removing the
  514. # following redundant blocks.
  515. #
  516. # Running the script against all historical releases should be
  517. # required only if the BoostScanDeps.cmake script logic is changed.
  518. # The addition of a new release should only require it to be run
  519. # against the new release.
  520. set(_Boost_IMPORTED_TARGETS TRUE)
  521. if(NOT Boost_VERSION VERSION_LESS 103300 AND Boost_VERSION VERSION_LESS 103500)
  522. set(_Boost_IOSTREAMS_DEPENDENCIES regex thread)
  523. set(_Boost_REGEX_DEPENDENCIES thread)
  524. set(_Boost_WAVE_DEPENDENCIES filesystem thread)
  525. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  526. elseif(NOT Boost_VERSION VERSION_LESS 103500 AND Boost_VERSION VERSION_LESS 103600)
  527. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  528. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  529. set(_Boost_MPI_DEPENDENCIES serialization)
  530. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  531. set(_Boost_WAVE_DEPENDENCIES filesystem system thread)
  532. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  533. elseif(NOT Boost_VERSION VERSION_LESS 103600 AND Boost_VERSION VERSION_LESS 103800)
  534. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  535. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  536. set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l)
  537. set(_Boost_MPI_DEPENDENCIES serialization)
  538. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  539. set(_Boost_WAVE_DEPENDENCIES filesystem system thread)
  540. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  541. elseif(NOT Boost_VERSION VERSION_LESS 103800 AND Boost_VERSION VERSION_LESS 104300)
  542. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  543. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  544. set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l)
  545. set(_Boost_MPI_DEPENDENCIES serialization)
  546. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  547. set(_Boost_THREAD_DEPENDENCIES date_time)
  548. set(_Boost_WAVE_DEPENDENCIES filesystem system thread date_time)
  549. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  550. elseif(NOT Boost_VERSION VERSION_LESS 104300 AND Boost_VERSION VERSION_LESS 104400)
  551. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  552. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  553. set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random)
  554. set(_Boost_MPI_DEPENDENCIES serialization)
  555. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  556. set(_Boost_THREAD_DEPENDENCIES date_time)
  557. set(_Boost_WAVE_DEPENDENCIES filesystem system thread date_time)
  558. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  559. elseif(NOT Boost_VERSION VERSION_LESS 104400 AND Boost_VERSION VERSION_LESS 104500)
  560. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  561. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  562. set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random serialization)
  563. set(_Boost_MPI_DEPENDENCIES serialization)
  564. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  565. set(_Boost_THREAD_DEPENDENCIES date_time)
  566. set(_Boost_WAVE_DEPENDENCIES serialization filesystem system thread date_time)
  567. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  568. elseif(NOT Boost_VERSION VERSION_LESS 104500 AND Boost_VERSION VERSION_LESS 104700)
  569. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  570. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  571. set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random)
  572. set(_Boost_MPI_DEPENDENCIES serialization)
  573. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  574. set(_Boost_THREAD_DEPENDENCIES date_time)
  575. set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time)
  576. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  577. elseif(NOT Boost_VERSION VERSION_LESS 104700 AND Boost_VERSION VERSION_LESS 104800)
  578. set(_Boost_CHRONO_DEPENDENCIES system)
  579. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  580. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  581. set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random)
  582. set(_Boost_MPI_DEPENDENCIES serialization)
  583. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  584. set(_Boost_THREAD_DEPENDENCIES date_time)
  585. set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time)
  586. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  587. elseif(NOT Boost_VERSION VERSION_LESS 104800 AND Boost_VERSION VERSION_LESS 105000)
  588. set(_Boost_CHRONO_DEPENDENCIES system)
  589. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  590. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  591. set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random)
  592. set(_Boost_MPI_DEPENDENCIES serialization)
  593. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  594. set(_Boost_THREAD_DEPENDENCIES date_time)
  595. set(_Boost_TIMER_DEPENDENCIES chrono system)
  596. set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time)
  597. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  598. elseif(NOT Boost_VERSION VERSION_LESS 105000 AND Boost_VERSION VERSION_LESS 105300)
  599. set(_Boost_CHRONO_DEPENDENCIES system)
  600. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  601. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  602. set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random)
  603. set(_Boost_MPI_DEPENDENCIES serialization)
  604. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  605. set(_Boost_THREAD_DEPENDENCIES chrono system date_time)
  606. set(_Boost_TIMER_DEPENDENCIES chrono system)
  607. set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time)
  608. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  609. elseif(NOT Boost_VERSION VERSION_LESS 105300 AND Boost_VERSION VERSION_LESS 105400)
  610. set(_Boost_ATOMIC_DEPENDENCIES thread chrono system date_time)
  611. set(_Boost_CHRONO_DEPENDENCIES system)
  612. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  613. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  614. set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random)
  615. set(_Boost_MPI_DEPENDENCIES serialization)
  616. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  617. set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
  618. set(_Boost_TIMER_DEPENDENCIES chrono system)
  619. set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time)
  620. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  621. elseif(NOT Boost_VERSION VERSION_LESS 105400 AND Boost_VERSION VERSION_LESS 105500)
  622. set(_Boost_ATOMIC_DEPENDENCIES thread chrono system date_time)
  623. set(_Boost_CHRONO_DEPENDENCIES system)
  624. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  625. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  626. set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono)
  627. set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random)
  628. set(_Boost_MPI_DEPENDENCIES serialization)
  629. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  630. set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
  631. set(_Boost_TIMER_DEPENDENCIES chrono system)
  632. set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
  633. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  634. elseif(NOT Boost_VERSION VERSION_LESS 105500 AND Boost_VERSION VERSION_LESS 105600)
  635. set(_Boost_CHRONO_DEPENDENCIES system)
  636. set(_Boost_COROUTINE_DEPENDENCIES context system)
  637. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  638. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  639. set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono)
  640. set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random)
  641. set(_Boost_MPI_DEPENDENCIES serialization)
  642. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  643. set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
  644. set(_Boost_TIMER_DEPENDENCIES chrono system)
  645. set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
  646. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  647. elseif(NOT Boost_VERSION VERSION_LESS 105600 AND Boost_VERSION VERSION_LESS 105900)
  648. set(_Boost_CHRONO_DEPENDENCIES system)
  649. set(_Boost_COROUTINE_DEPENDENCIES context system)
  650. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  651. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  652. set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono)
  653. set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
  654. set(_Boost_MPI_DEPENDENCIES serialization)
  655. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  656. set(_Boost_RANDOM_DEPENDENCIES system)
  657. set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
  658. set(_Boost_TIMER_DEPENDENCIES chrono system)
  659. set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
  660. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  661. elseif(NOT Boost_VERSION VERSION_LESS 105900 AND Boost_VERSION VERSION_LESS 106000)
  662. set(_Boost_CHRONO_DEPENDENCIES system)
  663. set(_Boost_COROUTINE_DEPENDENCIES context system)
  664. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  665. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  666. set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono atomic)
  667. set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
  668. set(_Boost_MPI_DEPENDENCIES serialization)
  669. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  670. set(_Boost_RANDOM_DEPENDENCIES system)
  671. set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
  672. set(_Boost_TIMER_DEPENDENCIES chrono system)
  673. set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
  674. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  675. elseif(NOT Boost_VERSION VERSION_LESS 106000 AND Boost_VERSION VERSION_LESS 106100)
  676. set(_Boost_CHRONO_DEPENDENCIES system)
  677. set(_Boost_COROUTINE_DEPENDENCIES context system)
  678. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  679. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  680. set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic)
  681. set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
  682. set(_Boost_MPI_DEPENDENCIES serialization)
  683. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  684. set(_Boost_RANDOM_DEPENDENCIES system)
  685. set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
  686. set(_Boost_TIMER_DEPENDENCIES chrono system)
  687. set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
  688. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  689. elseif(NOT Boost_VERSION VERSION_LESS 106100 AND Boost_VERSION VERSION_LESS 106200)
  690. set(_Boost_CHRONO_DEPENDENCIES system)
  691. set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time)
  692. set(_Boost_COROUTINE_DEPENDENCIES context system)
  693. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  694. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  695. set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic)
  696. set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
  697. set(_Boost_MPI_DEPENDENCIES serialization)
  698. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  699. set(_Boost_RANDOM_DEPENDENCIES system)
  700. set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
  701. set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
  702. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  703. elseif(NOT Boost_VERSION VERSION_LESS 106200 AND Boost_VERSION VERSION_LESS 106300)
  704. set(_Boost_CHRONO_DEPENDENCIES system)
  705. set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time)
  706. set(_Boost_COROUTINE_DEPENDENCIES context system)
  707. set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time)
  708. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  709. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  710. set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic)
  711. set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
  712. set(_Boost_MPI_DEPENDENCIES serialization)
  713. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  714. set(_Boost_RANDOM_DEPENDENCIES system)
  715. set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
  716. set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
  717. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  718. elseif(NOT Boost_VERSION VERSION_LESS 106300 AND Boost_VERSION VERSION_LESS 106500)
  719. set(_Boost_CHRONO_DEPENDENCIES system)
  720. set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time)
  721. set(_Boost_COROUTINE_DEPENDENCIES context system)
  722. set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time)
  723. set(_Boost_FILESYSTEM_DEPENDENCIES system)
  724. set(_Boost_IOSTREAMS_DEPENDENCIES regex)
  725. set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic)
  726. set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
  727. set(_Boost_MPI_DEPENDENCIES serialization)
  728. set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
  729. set(_Boost_RANDOM_DEPENDENCIES system)
  730. set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
  731. set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
  732. set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
  733. else()
  734. message(WARNING "Imported targets not available for Boost version ${Boost_VERSION}")
  735. set(_Boost_IMPORTED_TARGETS FALSE)
  736. endif()
  737. string(TOUPPER ${component} uppercomponent)
  738. set(${_ret} ${_Boost_${uppercomponent}_DEPENDENCIES} PARENT_SCOPE)
  739. set(_Boost_IMPORTED_TARGETS ${_Boost_IMPORTED_TARGETS} PARENT_SCOPE)
  740. string(REGEX REPLACE ";" " " _boost_DEPS_STRING "${_Boost_${uppercomponent}_DEPENDENCIES}")
  741. if (NOT _boost_DEPS_STRING)
  742. set(_boost_DEPS_STRING "(none)")
  743. endif()
  744. # message(STATUS "Dependencies for Boost::${component}: ${_boost_DEPS_STRING}")
  745. endfunction()
  746. #
  747. # Get component headers. This is the primary header (or headers) for
  748. # a given component, and is used to check that the headers are present
  749. # as well as the library itself as an extra sanity check of the build
  750. # environment.
  751. #
  752. # component - the component to check
  753. # _hdrs
  754. #
  755. function(_Boost_COMPONENT_HEADERS component _hdrs)
  756. # Note: new boost components will require adding here. The header
  757. # must be present in all versions of Boost providing a library.
  758. set(_Boost_ATOMIC_HEADERS "boost/atomic.hpp")
  759. set(_Boost_CHRONO_HEADERS "boost/chrono.hpp")
  760. set(_Boost_CONTAINER_HEADERS "boost/container/container_fwd.hpp")
  761. set(_Boost_CONTEXT_HEADERS "boost/context/all.hpp")
  762. set(_Boost_COROUTINE_HEADERS "boost/coroutine/all.hpp")
  763. set(_Boost_EXCEPTION_HEADERS "boost/exception/exception.hpp")
  764. set(_Boost_DATE_TIME_HEADERS "boost/date_time/date.hpp")
  765. set(_Boost_FIBER_HEADERS "boost/fiber/all.hpp")
  766. set(_Boost_FILESYSTEM_HEADERS "boost/filesystem/path.hpp")
  767. set(_Boost_GRAPH_HEADERS "boost/graph/adjacency_list.hpp")
  768. set(_Boost_GRAPH_PARALLEL_HEADERS "boost/graph/adjacency_list.hpp")
  769. set(_Boost_IOSTREAMS_HEADERS "boost/iostreams/stream.hpp")
  770. set(_Boost_LOCALE_HEADERS "boost/locale.hpp")
  771. set(_Boost_LOG_HEADERS "boost/log/core.hpp")
  772. set(_Boost_LOG_SETUP_HEADERS "boost/log/detail/setup_config.hpp")
  773. set(_Boost_MATH_HEADERS "boost/math_fwd.hpp")
  774. set(_Boost_MATH_C99_HEADERS "boost/math/tr1.hpp")
  775. set(_Boost_MATH_C99F_HEADERS "boost/math/tr1.hpp")
  776. set(_Boost_MATH_C99L_HEADERS "boost/math/tr1.hpp")
  777. set(_Boost_MATH_TR1_HEADERS "boost/math/tr1.hpp")
  778. set(_Boost_MATH_TR1F_HEADERS "boost/math/tr1.hpp")
  779. set(_Boost_MATH_TR1L_HEADERS "boost/math/tr1.hpp")
  780. set(_Boost_MPI_HEADERS "boost/mpi.hpp")
  781. set(_Boost_MPI_PYTHON_HEADERS "boost/mpi/python/config.hpp")
  782. set(_Boost_PRG_EXEC_MONITOR_HEADERS "boost/test/prg_exec_monitor.hpp")
  783. set(_Boost_PROGRAM_OPTIONS_HEADERS "boost/program_options.hpp")
  784. set(_Boost_PYTHON_HEADERS "boost/python.hpp")
  785. set(_Boost_RANDOM_HEADERS "boost/random.hpp")
  786. set(_Boost_REGEX_HEADERS "boost/regex.hpp")
  787. set(_Boost_SERIALIZATION_HEADERS "boost/serialization/serialization.hpp")
  788. set(_Boost_SIGNALS_HEADERS "boost/signals.hpp")
  789. set(_Boost_SYSTEM_HEADERS "boost/system/config.hpp")
  790. set(_Boost_TEST_EXEC_MONITOR_HEADERS "boost/test/test_exec_monitor.hpp")
  791. set(_Boost_THREAD_HEADERS "boost/thread.hpp")
  792. set(_Boost_TIMER_HEADERS "boost/timer.hpp")
  793. set(_Boost_TYPE_ERASURE_HEADERS "boost/type_erasure/config.hpp")
  794. set(_Boost_UNIT_TEST_FRAMEWORK_HEADERS "boost/test/framework.hpp")
  795. set(_Boost_WAVE_HEADERS "boost/wave.hpp")
  796. set(_Boost_WSERIALIZATION_HEADERS "boost/archive/text_wiarchive.hpp")
  797. if(WIN32)
  798. set(_Boost_BZIP2_HEADERS "boost/iostreams/filter/bzip2.hpp")
  799. set(_Boost_ZLIB_HEADERS "boost/iostreams/filter/zlib.hpp")
  800. endif()
  801. string(TOUPPER ${component} uppercomponent)
  802. set(${_hdrs} ${_Boost_${uppercomponent}_HEADERS} PARENT_SCOPE)
  803. string(REGEX REPLACE ";" " " _boost_HDRS_STRING "${_Boost_${uppercomponent}_HEADERS}")
  804. if (NOT _boost_HDRS_STRING)
  805. set(_boost_HDRS_STRING "(none)")
  806. endif()
  807. # message(STATUS "Headers for Boost::${component}: ${_boost_HDRS_STRING}")
  808. endfunction()
  809. #
  810. # Determine if any missing dependencies require adding to the component list.
  811. #
  812. # Sets _Boost_${COMPONENT}_DEPENDENCIES for each required component,
  813. # plus _Boost_IMPORTED_TARGETS (TRUE if imported targets should be
  814. # defined; FALSE if dependency information is unavailable).
  815. #
  816. # componentvar - the component list variable name
  817. # extravar - the indirect dependency list variable name
  818. #
  819. #
  820. function(_Boost_MISSING_DEPENDENCIES componentvar extravar)
  821. # _boost_unprocessed_components - list of components requiring processing
  822. # _boost_processed_components - components already processed (or currently being processed)
  823. # _boost_new_components - new components discovered for future processing
  824. #
  825. list(APPEND _boost_unprocessed_components ${${componentvar}})
  826. while(_boost_unprocessed_components)
  827. list(APPEND _boost_processed_components ${_boost_unprocessed_components})
  828. foreach(component ${_boost_unprocessed_components})
  829. string(TOUPPER ${component} uppercomponent)
  830. set(${_ret} ${_Boost_${uppercomponent}_DEPENDENCIES} PARENT_SCOPE)
  831. _Boost_COMPONENT_DEPENDENCIES("${component}" _Boost_${uppercomponent}_DEPENDENCIES)
  832. set(_Boost_${uppercomponent}_DEPENDENCIES ${_Boost_${uppercomponent}_DEPENDENCIES} PARENT_SCOPE)
  833. set(_Boost_IMPORTED_TARGETS ${_Boost_IMPORTED_TARGETS} PARENT_SCOPE)
  834. foreach(componentdep ${_Boost_${uppercomponent}_DEPENDENCIES})
  835. list(FIND _boost_processed_components "${componentdep}" _boost_component_found)
  836. list(FIND _boost_new_components "${componentdep}" _boost_component_new)
  837. if (_boost_component_found EQUAL -1 AND _boost_component_new EQUAL -1)
  838. list(APPEND _boost_new_components ${componentdep})
  839. endif()
  840. endforeach()
  841. endforeach()
  842. set(_boost_unprocessed_components ${_boost_new_components})
  843. unset(_boost_new_components)
  844. endwhile()
  845. set(_boost_extra_components ${_boost_processed_components})
  846. if(_boost_extra_components AND ${componentvar})
  847. list(REMOVE_ITEM _boost_extra_components ${${componentvar}})
  848. endif()
  849. set(${componentvar} ${_boost_processed_components} PARENT_SCOPE)
  850. set(${extravar} ${_boost_extra_components} PARENT_SCOPE)
  851. endfunction()
  852. #
  853. # Update library search directory hint variable with paths used by prebuilt boost binaries.
  854. #
  855. # Prebuilt windows binaries (https://sourceforge.net/projects/boost/files/boost-binaries/)
  856. # have library directories named using MSVC compiler version and architecture.
  857. # This function would append corresponding directories if MSVC is a current compiler,
  858. # so having `BOOST_ROOT` would be enough to specify to find everything.
  859. #
  860. macro(_Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS componentlibvar basedir)
  861. if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
  862. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  863. set(_arch_suffix 64)
  864. else()
  865. set(_arch_suffix 32)
  866. endif()
  867. if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10)
  868. list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-15.0)
  869. elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19)
  870. list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-14.0)
  871. elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18)
  872. list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-12.0)
  873. elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17)
  874. list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-11.0)
  875. elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
  876. list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-10.0)
  877. elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15)
  878. list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-9.0)
  879. elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14)
  880. list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-8.0)
  881. endif()
  882. endif()
  883. endmacro()
  884. #
  885. # End functions/macros
  886. #
  887. #-------------------------------------------------------------------------------
  888. #-------------------------------------------------------------------------------
  889. # main.
  890. #-------------------------------------------------------------------------------
  891. # If the user sets Boost_LIBRARY_DIR, use it as the default for both
  892. # configurations.
  893. if(NOT Boost_LIBRARY_DIR_RELEASE AND Boost_LIBRARY_DIR)
  894. set(Boost_LIBRARY_DIR_RELEASE "${Boost_LIBRARY_DIR}")
  895. endif()
  896. if(NOT Boost_LIBRARY_DIR_DEBUG AND Boost_LIBRARY_DIR)
  897. set(Boost_LIBRARY_DIR_DEBUG "${Boost_LIBRARY_DIR}")
  898. endif()
  899. if(NOT DEFINED Boost_USE_MULTITHREADED)
  900. set(Boost_USE_MULTITHREADED TRUE)
  901. endif()
  902. if(NOT DEFINED Boost_USE_DEBUG_RUNTIME)
  903. set(Boost_USE_DEBUG_RUNTIME TRUE)
  904. endif()
  905. # Check the version of Boost against the requested version.
  906. if(Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
  907. 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")
  908. endif()
  909. if(Boost_FIND_VERSION_EXACT)
  910. # The version may appear in a directory with or without the patch
  911. # level, even when the patch level is non-zero.
  912. set(_boost_TEST_VERSIONS
  913. "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.${Boost_FIND_VERSION_PATCH}"
  914. "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  915. else()
  916. # The user has not requested an exact version. Among known
  917. # versions, find those that are acceptable to the user request.
  918. #
  919. # Note: When adding a new Boost release, also update the dependency
  920. # information in _Boost_COMPONENT_DEPENDENCIES and
  921. # _Boost_COMPONENT_HEADERS. See the instructions at the top of
  922. # _Boost_COMPONENT_DEPENDENCIES.
  923. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
  924. "1.64.0" "1.64" "1.63.0" "1.63" "1.62.0" "1.62" "1.61.0" "1.61" "1.60.0" "1.60"
  925. "1.59.0" "1.59" "1.58.0" "1.58" "1.57.0" "1.57" "1.56.0" "1.56" "1.55.0" "1.55"
  926. "1.54.0" "1.54" "1.53.0" "1.53" "1.52.0" "1.52" "1.51.0" "1.51"
  927. "1.50.0" "1.50" "1.49.0" "1.49" "1.48.0" "1.48" "1.47.0" "1.47" "1.46.1"
  928. "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"
  929. "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"
  930. "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0"
  931. "1.34" "1.33.1" "1.33.0" "1.33")
  932. set(_boost_TEST_VERSIONS)
  933. if(Boost_FIND_VERSION)
  934. set(_Boost_FIND_VERSION_SHORT "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  935. # Select acceptable versions.
  936. foreach(version ${_Boost_KNOWN_VERSIONS})
  937. if(NOT "${version}" VERSION_LESS "${Boost_FIND_VERSION}")
  938. # This version is high enough.
  939. list(APPEND _boost_TEST_VERSIONS "${version}")
  940. elseif("${version}.99" VERSION_EQUAL "${_Boost_FIND_VERSION_SHORT}.99")
  941. # This version is a short-form for the requested version with
  942. # the patch level dropped.
  943. list(APPEND _boost_TEST_VERSIONS "${version}")
  944. endif()
  945. endforeach()
  946. else()
  947. # Any version is acceptable.
  948. set(_boost_TEST_VERSIONS "${_Boost_KNOWN_VERSIONS}")
  949. endif()
  950. endif()
  951. # The reason that we failed to find Boost. This will be set to a
  952. # user-friendly message when we fail to find some necessary piece of
  953. # Boost.
  954. set(Boost_ERROR_REASON)
  955. if(Boost_DEBUG)
  956. # Output some of their choices
  957. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  958. "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
  959. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  960. "Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}")
  961. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  962. "Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}")
  963. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  964. "Boost_USE_STATIC_RUNTIME = ${Boost_USE_STATIC_RUNTIME}")
  965. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  966. "Boost_ADDITIONAL_VERSIONS = ${Boost_ADDITIONAL_VERSIONS}")
  967. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  968. "Boost_NO_SYSTEM_PATHS = ${Boost_NO_SYSTEM_PATHS}")
  969. endif()
  970. # Supply Boost_LIB_DIAGNOSTIC_DEFINITIONS as a convenience target. It
  971. # will only contain any interface definitions on WIN32, but is created
  972. # on all platforms to keep end user code free from platform dependent
  973. # code. Also provide convenience targets to disable autolinking and
  974. # enable dynamic linking.
  975. if(NOT TARGET Boost::diagnostic_definitions)
  976. add_library(Boost::diagnostic_definitions INTERFACE IMPORTED)
  977. add_library(Boost::disable_autolinking INTERFACE IMPORTED)
  978. add_library(Boost::dynamic_linking INTERFACE IMPORTED)
  979. endif()
  980. if(WIN32)
  981. # In windows, automatic linking is performed, so you do not have
  982. # to specify the libraries. If you are linking to a dynamic
  983. # runtime, then you can choose to link to either a static or a
  984. # dynamic Boost library, the default is to do a static link. You
  985. # can alter this for a specific library "whatever" by defining
  986. # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be
  987. # linked dynamically. Alternatively you can force all Boost
  988. # libraries to dynamic link by defining BOOST_ALL_DYN_LINK.
  989. # This feature can be disabled for Boost library "whatever" by
  990. # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining
  991. # BOOST_ALL_NO_LIB.
  992. # If you want to observe which libraries are being linked against
  993. # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking
  994. # code to emit a #pragma message each time a library is selected
  995. # for linking.
  996. set(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC")
  997. set_target_properties(Boost::diagnostic_definitions PROPERTIES
  998. INTERFACE_COMPILE_DEFINITIONS "BOOST_LIB_DIAGNOSTIC")
  999. set_target_properties(Boost::disable_autolinking PROPERTIES
  1000. INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB")
  1001. set_target_properties(Boost::dynamic_linking PROPERTIES
  1002. INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_DYN_LINK")
  1003. endif()
  1004. _Boost_CHECK_SPELLING(Boost_ROOT)
  1005. _Boost_CHECK_SPELLING(Boost_LIBRARYDIR)
  1006. _Boost_CHECK_SPELLING(Boost_INCLUDEDIR)
  1007. # Collect environment variable inputs as hints. Do not consider changes.
  1008. foreach(v BOOSTROOT BOOST_ROOT BOOST_INCLUDEDIR BOOST_LIBRARYDIR)
  1009. set(_env $ENV{${v}})
  1010. if(_env)
  1011. file(TO_CMAKE_PATH "${_env}" _ENV_${v})
  1012. else()
  1013. set(_ENV_${v} "")
  1014. endif()
  1015. endforeach()
  1016. if(NOT _ENV_BOOST_ROOT AND _ENV_BOOSTROOT)
  1017. set(_ENV_BOOST_ROOT "${_ENV_BOOSTROOT}")
  1018. endif()
  1019. # Collect inputs and cached results. Detect changes since the last run.
  1020. if(NOT BOOST_ROOT AND BOOSTROOT)
  1021. set(BOOST_ROOT "${BOOSTROOT}")
  1022. endif()
  1023. set(_Boost_VARS_DIR
  1024. BOOST_ROOT
  1025. Boost_NO_SYSTEM_PATHS
  1026. )
  1027. if(Boost_DEBUG)
  1028. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1029. "Declared as CMake or Environmental Variables:")
  1030. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1031. " BOOST_ROOT = ${BOOST_ROOT}")
  1032. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1033. " BOOST_INCLUDEDIR = ${BOOST_INCLUDEDIR}")
  1034. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1035. " BOOST_LIBRARYDIR = ${BOOST_LIBRARYDIR}")
  1036. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1037. "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
  1038. endif()
  1039. # ------------------------------------------------------------------------
  1040. # Search for Boost include DIR
  1041. # ------------------------------------------------------------------------
  1042. set(_Boost_VARS_INC BOOST_INCLUDEDIR Boost_INCLUDE_DIR Boost_ADDITIONAL_VERSIONS)
  1043. _Boost_CHANGE_DETECT(_Boost_CHANGE_INCDIR ${_Boost_VARS_DIR} ${_Boost_VARS_INC})
  1044. # Clear Boost_INCLUDE_DIR if it did not change but other input affecting the
  1045. # location did. We will find a new one based on the new inputs.
  1046. if(_Boost_CHANGE_INCDIR AND NOT _Boost_INCLUDE_DIR_CHANGED)
  1047. unset(Boost_INCLUDE_DIR CACHE)
  1048. endif()
  1049. if(NOT Boost_INCLUDE_DIR)
  1050. set(_boost_INCLUDE_SEARCH_DIRS "")
  1051. if(BOOST_INCLUDEDIR)
  1052. list(APPEND _boost_INCLUDE_SEARCH_DIRS ${BOOST_INCLUDEDIR})
  1053. elseif(_ENV_BOOST_INCLUDEDIR)
  1054. list(APPEND _boost_INCLUDE_SEARCH_DIRS ${_ENV_BOOST_INCLUDEDIR})
  1055. endif()
  1056. if( BOOST_ROOT )
  1057. list(APPEND _boost_INCLUDE_SEARCH_DIRS ${BOOST_ROOT}/include ${BOOST_ROOT})
  1058. elseif( _ENV_BOOST_ROOT )
  1059. list(APPEND _boost_INCLUDE_SEARCH_DIRS ${_ENV_BOOST_ROOT}/include ${_ENV_BOOST_ROOT})
  1060. endif()
  1061. if( Boost_NO_SYSTEM_PATHS)
  1062. list(APPEND _boost_INCLUDE_SEARCH_DIRS NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH)
  1063. else()
  1064. list(APPEND _boost_INCLUDE_SEARCH_DIRS PATHS
  1065. C:/boost/include
  1066. C:/boost
  1067. /sw/local/include
  1068. )
  1069. endif()
  1070. # Try to find Boost by stepping backwards through the Boost versions
  1071. # we know about.
  1072. # Build a list of path suffixes for each version.
  1073. set(_boost_PATH_SUFFIXES)
  1074. foreach(_boost_VER ${_boost_TEST_VERSIONS})
  1075. # Add in a path suffix, based on the required version, ideally
  1076. # we could read this from version.hpp, but for that to work we'd
  1077. # need to know the include dir already
  1078. set(_boost_BOOSTIFIED_VERSION)
  1079. # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0
  1080. if(_boost_VER MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)")
  1081. set(_boost_BOOSTIFIED_VERSION
  1082. "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}_${CMAKE_MATCH_3}")
  1083. elseif(_boost_VER MATCHES "([0-9]+)\\.([0-9]+)")
  1084. set(_boost_BOOSTIFIED_VERSION
  1085. "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}")
  1086. endif()
  1087. list(APPEND _boost_PATH_SUFFIXES
  1088. "boost-${_boost_BOOSTIFIED_VERSION}"
  1089. "boost_${_boost_BOOSTIFIED_VERSION}"
  1090. "boost/boost-${_boost_BOOSTIFIED_VERSION}"
  1091. "boost/boost_${_boost_BOOSTIFIED_VERSION}"
  1092. )
  1093. endforeach()
  1094. if(Boost_DEBUG)
  1095. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1096. "Include debugging info:")
  1097. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1098. " _boost_INCLUDE_SEARCH_DIRS = ${_boost_INCLUDE_SEARCH_DIRS}")
  1099. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1100. " _boost_PATH_SUFFIXES = ${_boost_PATH_SUFFIXES}")
  1101. endif()
  1102. # Look for a standard boost header file.
  1103. find_path(Boost_INCLUDE_DIR
  1104. NAMES boost/config.hpp
  1105. HINTS ${_boost_INCLUDE_SEARCH_DIRS}
  1106. PATH_SUFFIXES ${_boost_PATH_SUFFIXES}
  1107. )
  1108. endif()
  1109. # ------------------------------------------------------------------------
  1110. # Extract version information from version.hpp
  1111. # ------------------------------------------------------------------------
  1112. # Set Boost_FOUND based only on header location and version.
  1113. # It will be updated below for component libraries.
  1114. if(Boost_INCLUDE_DIR)
  1115. if(Boost_DEBUG)
  1116. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1117. "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp")
  1118. endif()
  1119. # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp
  1120. set(Boost_VERSION 0)
  1121. set(Boost_LIB_VERSION "")
  1122. file(STRINGS "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS REGEX "#define BOOST_(LIB_)?VERSION ")
  1123. set(_Boost_VERSION_REGEX "([0-9]+)")
  1124. set(_Boost_LIB_VERSION_REGEX "\"([0-9_]+)\"")
  1125. foreach(v VERSION LIB_VERSION)
  1126. if("${_boost_VERSION_HPP_CONTENTS}" MATCHES "#define BOOST_${v} ${_Boost_${v}_REGEX}")
  1127. set(Boost_${v} "${CMAKE_MATCH_1}")
  1128. endif()
  1129. endforeach()
  1130. unset(_boost_VERSION_HPP_CONTENTS)
  1131. math(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
  1132. math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
  1133. math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
  1134. string(APPEND Boost_ERROR_REASON
  1135. "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}")
  1136. if(Boost_DEBUG)
  1137. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1138. "version.hpp reveals boost "
  1139. "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
  1140. endif()
  1141. if(Boost_FIND_VERSION)
  1142. # Set Boost_FOUND based on requested version.
  1143. set(_Boost_VERSION "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
  1144. if("${_Boost_VERSION}" VERSION_LESS "${Boost_FIND_VERSION}")
  1145. set(Boost_FOUND 0)
  1146. set(_Boost_VERSION_AGE "old")
  1147. elseif(Boost_FIND_VERSION_EXACT AND
  1148. NOT "${_Boost_VERSION}" VERSION_EQUAL "${Boost_FIND_VERSION}")
  1149. set(Boost_FOUND 0)
  1150. set(_Boost_VERSION_AGE "new")
  1151. else()
  1152. set(Boost_FOUND 1)
  1153. endif()
  1154. if(NOT Boost_FOUND)
  1155. # State that we found a version of Boost that is too new or too old.
  1156. string(APPEND Boost_ERROR_REASON
  1157. "\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  1158. if (Boost_FIND_VERSION_PATCH)
  1159. string(APPEND Boost_ERROR_REASON
  1160. ".${Boost_FIND_VERSION_PATCH}")
  1161. endif ()
  1162. if (NOT Boost_FIND_VERSION_EXACT)
  1163. string(APPEND Boost_ERROR_REASON " (or newer)")
  1164. endif ()
  1165. string(APPEND Boost_ERROR_REASON ".")
  1166. endif ()
  1167. else()
  1168. # Caller will accept any Boost version.
  1169. set(Boost_FOUND 1)
  1170. endif()
  1171. else()
  1172. set(Boost_FOUND 0)
  1173. string(APPEND Boost_ERROR_REASON
  1174. "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.")
  1175. endif()
  1176. # ------------------------------------------------------------------------
  1177. # Prefix initialization
  1178. # ------------------------------------------------------------------------
  1179. set(Boost_LIB_PREFIX "")
  1180. if ( (GHSMULTI AND Boost_USE_STATIC_LIBS) OR
  1181. (WIN32 AND Boost_USE_STATIC_LIBS AND NOT CYGWIN) )
  1182. set(Boost_LIB_PREFIX "lib")
  1183. endif()
  1184. if ( NOT Boost_NAMESPACE )
  1185. set(Boost_NAMESPACE "boost")
  1186. endif()
  1187. # ------------------------------------------------------------------------
  1188. # Suffix initialization and compiler suffix detection.
  1189. # ------------------------------------------------------------------------
  1190. set(_Boost_VARS_NAME
  1191. Boost_NAMESPACE
  1192. Boost_COMPILER
  1193. Boost_THREADAPI
  1194. Boost_USE_DEBUG_PYTHON
  1195. Boost_USE_MULTITHREADED
  1196. Boost_USE_STATIC_LIBS
  1197. Boost_USE_STATIC_RUNTIME
  1198. Boost_USE_STLPORT
  1199. Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS
  1200. )
  1201. _Boost_CHANGE_DETECT(_Boost_CHANGE_LIBNAME ${_Boost_VARS_NAME})
  1202. # Setting some more suffixes for the library
  1203. if (Boost_COMPILER)
  1204. set(_boost_COMPILER ${Boost_COMPILER})
  1205. if(Boost_DEBUG)
  1206. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1207. "using user-specified Boost_COMPILER = ${_boost_COMPILER}")
  1208. endif()
  1209. else()
  1210. # Attempt to guess the compiler suffix
  1211. # NOTE: this is not perfect yet, if you experience any issues
  1212. # please report them and use the Boost_COMPILER variable
  1213. # to work around the problems.
  1214. _Boost_GUESS_COMPILER_PREFIX(_boost_COMPILER)
  1215. if(Boost_DEBUG)
  1216. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1217. "guessed _boost_COMPILER = ${_boost_COMPILER}")
  1218. endif()
  1219. endif()
  1220. set (_boost_MULTITHREADED "-mt")
  1221. if( NOT Boost_USE_MULTITHREADED )
  1222. set (_boost_MULTITHREADED "")
  1223. endif()
  1224. if(Boost_DEBUG)
  1225. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1226. "_boost_MULTITHREADED = ${_boost_MULTITHREADED}")
  1227. endif()
  1228. #======================
  1229. # Systematically build up the Boost ABI tag
  1230. # http://boost.org/doc/libs/1_41_0/more/getting_started/windows.html#library-naming
  1231. set( _boost_RELEASE_ABI_TAG "-")
  1232. set( _boost_DEBUG_ABI_TAG "-")
  1233. # Key Use this library when:
  1234. # s linking statically to the C++ standard library and
  1235. # compiler runtime support libraries.
  1236. if(Boost_USE_STATIC_RUNTIME)
  1237. set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}s")
  1238. set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}s")
  1239. endif()
  1240. # g using debug versions of the standard and runtime
  1241. # support libraries
  1242. if(WIN32 AND Boost_USE_DEBUG_RUNTIME)
  1243. if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC"
  1244. OR "${CMAKE_CXX_COMPILER}" MATCHES "icl"
  1245. OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
  1246. string(APPEND _boost_DEBUG_ABI_TAG "g")
  1247. endif()
  1248. endif()
  1249. # y using special debug build of python
  1250. if(Boost_USE_DEBUG_PYTHON)
  1251. string(APPEND _boost_DEBUG_ABI_TAG "y")
  1252. endif()
  1253. # d using a debug version of your code
  1254. string(APPEND _boost_DEBUG_ABI_TAG "d")
  1255. # p using the STLport standard library rather than the
  1256. # default one supplied with your compiler
  1257. if(Boost_USE_STLPORT)
  1258. string(APPEND _boost_RELEASE_ABI_TAG "p")
  1259. string(APPEND _boost_DEBUG_ABI_TAG "p")
  1260. endif()
  1261. # n using the STLport deprecated "native iostreams" feature
  1262. if(Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS)
  1263. string(APPEND _boost_RELEASE_ABI_TAG "n")
  1264. string(APPEND _boost_DEBUG_ABI_TAG "n")
  1265. endif()
  1266. if(Boost_DEBUG)
  1267. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1268. "_boost_RELEASE_ABI_TAG = ${_boost_RELEASE_ABI_TAG}")
  1269. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1270. "_boost_DEBUG_ABI_TAG = ${_boost_DEBUG_ABI_TAG}")
  1271. endif()
  1272. # ------------------------------------------------------------------------
  1273. # Begin finding boost libraries
  1274. # ------------------------------------------------------------------------
  1275. set(_Boost_VARS_LIB "")
  1276. foreach(c DEBUG RELEASE)
  1277. set(_Boost_VARS_LIB_${c} BOOST_LIBRARYDIR Boost_LIBRARY_DIR_${c})
  1278. list(APPEND _Boost_VARS_LIB ${_Boost_VARS_LIB_${c}})
  1279. _Boost_CHANGE_DETECT(_Boost_CHANGE_LIBDIR_${c} ${_Boost_VARS_DIR} ${_Boost_VARS_LIB_${c}} Boost_INCLUDE_DIR)
  1280. # Clear Boost_LIBRARY_DIR_${c} if it did not change but other input affecting the
  1281. # location did. We will find a new one based on the new inputs.
  1282. if(_Boost_CHANGE_LIBDIR_${c} AND NOT _Boost_LIBRARY_DIR_${c}_CHANGED)
  1283. unset(Boost_LIBRARY_DIR_${c} CACHE)
  1284. endif()
  1285. # If Boost_LIBRARY_DIR_[RELEASE,DEBUG] is set, prefer its value.
  1286. if(Boost_LIBRARY_DIR_${c})
  1287. set(_boost_LIBRARY_SEARCH_DIRS_${c} ${Boost_LIBRARY_DIR_${c}} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
  1288. else()
  1289. set(_boost_LIBRARY_SEARCH_DIRS_${c} "")
  1290. if(BOOST_LIBRARYDIR)
  1291. list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${BOOST_LIBRARYDIR})
  1292. elseif(_ENV_BOOST_LIBRARYDIR)
  1293. list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${_ENV_BOOST_LIBRARYDIR})
  1294. endif()
  1295. if(BOOST_ROOT)
  1296. list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${BOOST_ROOT}/lib ${BOOST_ROOT}/stage/lib)
  1297. _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "${BOOST_ROOT}")
  1298. elseif(_ENV_BOOST_ROOT)
  1299. list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${_ENV_BOOST_ROOT}/lib ${_ENV_BOOST_ROOT}/stage/lib)
  1300. _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "${_ENV_BOOST_ROOT}")
  1301. endif()
  1302. list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c}
  1303. ${Boost_INCLUDE_DIR}/lib
  1304. ${Boost_INCLUDE_DIR}/../lib
  1305. ${Boost_INCLUDE_DIR}/stage/lib
  1306. )
  1307. _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "${Boost_INCLUDE_DIR}/..")
  1308. if( Boost_NO_SYSTEM_PATHS )
  1309. list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH)
  1310. else()
  1311. list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} PATHS
  1312. C:/boost/lib
  1313. C:/boost
  1314. /sw/local/lib
  1315. )
  1316. _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "C:/boost")
  1317. endif()
  1318. endif()
  1319. endforeach()
  1320. if(Boost_DEBUG)
  1321. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1322. "_boost_LIBRARY_SEARCH_DIRS_RELEASE = ${_boost_LIBRARY_SEARCH_DIRS_RELEASE}"
  1323. "_boost_LIBRARY_SEARCH_DIRS_DEBUG = ${_boost_LIBRARY_SEARCH_DIRS_DEBUG}")
  1324. endif()
  1325. # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
  1326. if( Boost_USE_STATIC_LIBS )
  1327. set( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
  1328. if(WIN32)
  1329. list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .lib .a)
  1330. else()
  1331. set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
  1332. endif()
  1333. endif()
  1334. # We want to use the tag inline below without risking double dashes
  1335. if(_boost_RELEASE_ABI_TAG)
  1336. if(${_boost_RELEASE_ABI_TAG} STREQUAL "-")
  1337. set(_boost_RELEASE_ABI_TAG "")
  1338. endif()
  1339. endif()
  1340. if(_boost_DEBUG_ABI_TAG)
  1341. if(${_boost_DEBUG_ABI_TAG} STREQUAL "-")
  1342. set(_boost_DEBUG_ABI_TAG "")
  1343. endif()
  1344. endif()
  1345. # The previous behavior of FindBoost when Boost_USE_STATIC_LIBS was enabled
  1346. # on WIN32 was to:
  1347. # 1. Search for static libs compiled against a SHARED C++ standard runtime library (use if found)
  1348. # 2. Search for static libs compiled against a STATIC C++ standard runtime library (use if found)
  1349. # We maintain this behavior since changing it could break people's builds.
  1350. # To disable the ambiguous behavior, the user need only
  1351. # set Boost_USE_STATIC_RUNTIME either ON or OFF.
  1352. set(_boost_STATIC_RUNTIME_WORKAROUND false)
  1353. if(WIN32 AND Boost_USE_STATIC_LIBS)
  1354. if(NOT DEFINED Boost_USE_STATIC_RUNTIME)
  1355. set(_boost_STATIC_RUNTIME_WORKAROUND TRUE)
  1356. endif()
  1357. endif()
  1358. # On versions < 1.35, remove the System library from the considered list
  1359. # since it wasn't added until 1.35.
  1360. if(Boost_VERSION AND Boost_FIND_COMPONENTS)
  1361. if(Boost_VERSION LESS 103500)
  1362. list(REMOVE_ITEM Boost_FIND_COMPONENTS system)
  1363. endif()
  1364. endif()
  1365. # Additional components may be required via component dependencies.
  1366. # Add any missing components to the list.
  1367. _Boost_MISSING_DEPENDENCIES(Boost_FIND_COMPONENTS _Boost_EXTRA_FIND_COMPONENTS)
  1368. # If thread is required, get the thread libs as a dependency
  1369. list(FIND Boost_FIND_COMPONENTS thread _Boost_THREAD_DEPENDENCY_LIBS)
  1370. if(NOT _Boost_THREAD_DEPENDENCY_LIBS EQUAL -1)
  1371. include(CMakeFindDependencyMacro)
  1372. find_dependency(Threads)
  1373. endif()
  1374. # If the user changed any of our control inputs flush previous results.
  1375. if(_Boost_CHANGE_LIBDIR_DEBUG OR _Boost_CHANGE_LIBDIR_RELEASE OR _Boost_CHANGE_LIBNAME)
  1376. foreach(COMPONENT ${_Boost_COMPONENTS_SEARCHED})
  1377. string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  1378. foreach(c DEBUG RELEASE)
  1379. set(_var Boost_${UPPERCOMPONENT}_LIBRARY_${c})
  1380. unset(${_var} CACHE)
  1381. set(${_var} "${_var}-NOTFOUND")
  1382. endforeach()
  1383. endforeach()
  1384. set(_Boost_COMPONENTS_SEARCHED "")
  1385. endif()
  1386. foreach(COMPONENT ${Boost_FIND_COMPONENTS})
  1387. string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  1388. set( _boost_docstring_release "Boost ${COMPONENT} library (release)")
  1389. set( _boost_docstring_debug "Boost ${COMPONENT} library (debug)")
  1390. # Compute component-specific hints.
  1391. set(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT "")
  1392. if(${COMPONENT} STREQUAL "mpi" OR ${COMPONENT} STREQUAL "mpi_python" OR
  1393. ${COMPONENT} STREQUAL "graph_parallel")
  1394. foreach(lib ${MPI_CXX_LIBRARIES} ${MPI_C_LIBRARIES})
  1395. if(IS_ABSOLUTE "${lib}")
  1396. get_filename_component(libdir "${lib}" PATH)
  1397. string(REPLACE "\\" "/" libdir "${libdir}")
  1398. list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT ${libdir})
  1399. endif()
  1400. endforeach()
  1401. endif()
  1402. # Consolidate and report component-specific hints.
  1403. if(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT)
  1404. list(REMOVE_DUPLICATES _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT)
  1405. if(Boost_DEBUG)
  1406. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1407. "Component-specific library search paths for ${COMPONENT}: "
  1408. "${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT}")
  1409. endif()
  1410. endif()
  1411. #
  1412. # Find headers
  1413. #
  1414. _Boost_COMPONENT_HEADERS("${COMPONENT}" Boost_${UPPERCOMPONENT}_HEADER_NAME)
  1415. # Look for a standard boost header file.
  1416. if(Boost_${UPPERCOMPONENT}_HEADER_NAME)
  1417. if(EXISTS "${Boost_INCLUDE_DIR}/${Boost_${UPPERCOMPONENT}_HEADER_NAME}")
  1418. set(Boost_${UPPERCOMPONENT}_HEADER ON)
  1419. else()
  1420. set(Boost_${UPPERCOMPONENT}_HEADER OFF)
  1421. endif()
  1422. else()
  1423. set(Boost_${UPPERCOMPONENT}_HEADER ON)
  1424. message(WARNING "No header defined for ${COMPONENT}; skipping header check")
  1425. endif()
  1426. #
  1427. # Find RELEASE libraries
  1428. #
  1429. set(_boost_RELEASE_NAMES
  1430. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
  1431. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
  1432. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
  1433. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
  1434. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT} )
  1435. if(_boost_STATIC_RUNTIME_WORKAROUND)
  1436. set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}")
  1437. list(APPEND _boost_RELEASE_NAMES
  1438. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
  1439. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}
  1440. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
  1441. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} )
  1442. endif()
  1443. if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread")
  1444. _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_RELEASE_NAMES ${_boost_RELEASE_NAMES})
  1445. endif()
  1446. if(Boost_DEBUG)
  1447. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1448. "Searching for ${UPPERCOMPONENT}_LIBRARY_RELEASE: ${_boost_RELEASE_NAMES}")
  1449. endif()
  1450. # if Boost_LIBRARY_DIR_RELEASE is not defined,
  1451. # but Boost_LIBRARY_DIR_DEBUG is, look there first for RELEASE libs
  1452. if(NOT Boost_LIBRARY_DIR_RELEASE AND Boost_LIBRARY_DIR_DEBUG)
  1453. list(INSERT _boost_LIBRARY_SEARCH_DIRS_RELEASE 0 ${Boost_LIBRARY_DIR_DEBUG})
  1454. endif()
  1455. # Avoid passing backslashes to _Boost_FIND_LIBRARY due to macro re-parsing.
  1456. string(REPLACE "\\" "/" _boost_LIBRARY_SEARCH_DIRS_tmp "${_boost_LIBRARY_SEARCH_DIRS_RELEASE}")
  1457. _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE RELEASE
  1458. NAMES ${_boost_RELEASE_NAMES}
  1459. HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp}
  1460. NAMES_PER_DIR
  1461. DOC "${_boost_docstring_release}"
  1462. )
  1463. #
  1464. # Find DEBUG libraries
  1465. #
  1466. set(_boost_DEBUG_NAMES
  1467. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
  1468. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
  1469. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
  1470. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
  1471. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}
  1472. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT} )
  1473. if(_boost_STATIC_RUNTIME_WORKAROUND)
  1474. set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}")
  1475. list(APPEND _boost_DEBUG_NAMES
  1476. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
  1477. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}
  1478. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
  1479. ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} )
  1480. endif()
  1481. if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread")
  1482. _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_DEBUG_NAMES ${_boost_DEBUG_NAMES})
  1483. endif()
  1484. if(Boost_DEBUG)
  1485. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  1486. "Searching for ${UPPERCOMPONENT}_LIBRARY_DEBUG: ${_boost_DEBUG_NAMES}")
  1487. endif()
  1488. # if Boost_LIBRARY_DIR_DEBUG is not defined,
  1489. # but Boost_LIBRARY_DIR_RELEASE is, look there first for DEBUG libs
  1490. if(NOT Boost_LIBRARY_DIR_DEBUG AND Boost_LIBRARY_DIR_RELEASE)
  1491. list(INSERT _boost_LIBRARY_SEARCH_DIRS_DEBUG 0 ${Boost_LIBRARY_DIR_RELEASE})
  1492. endif()
  1493. # Avoid passing backslashes to _Boost_FIND_LIBRARY due to macro re-parsing.
  1494. string(REPLACE "\\" "/" _boost_LIBRARY_SEARCH_DIRS_tmp "${_boost_LIBRARY_SEARCH_DIRS_DEBUG}")
  1495. _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG DEBUG
  1496. NAMES ${_boost_DEBUG_NAMES}
  1497. HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp}
  1498. NAMES_PER_DIR
  1499. DOC "${_boost_docstring_debug}"
  1500. )
  1501. if(Boost_REALPATH)
  1502. _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "${_boost_docstring_release}")
  1503. _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "${_boost_docstring_debug}" )
  1504. endif()
  1505. _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT})
  1506. endforeach()
  1507. # Restore the original find library ordering
  1508. if( Boost_USE_STATIC_LIBS )
  1509. set(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
  1510. endif()
  1511. # ------------------------------------------------------------------------
  1512. # End finding boost libraries
  1513. # ------------------------------------------------------------------------
  1514. set(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
  1515. set(Boost_LIBRARY_DIRS)
  1516. if(Boost_LIBRARY_DIR_RELEASE)
  1517. list(APPEND Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIR_RELEASE})
  1518. endif()
  1519. if(Boost_LIBRARY_DIR_DEBUG)
  1520. list(APPEND Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIR_DEBUG})
  1521. endif()
  1522. if(Boost_LIBRARY_DIRS)
  1523. list(REMOVE_DUPLICATES Boost_LIBRARY_DIRS)
  1524. endif()
  1525. # The above setting of Boost_FOUND was based only on the header files.
  1526. # Update it for the requested component libraries.
  1527. if(Boost_FOUND)
  1528. # The headers were found. Check for requested component libs.
  1529. set(_boost_CHECKED_COMPONENT FALSE)
  1530. set(_Boost_MISSING_COMPONENTS "")
  1531. foreach(COMPONENT ${Boost_FIND_COMPONENTS})
  1532. string(TOUPPER ${COMPONENT} COMPONENT)
  1533. set(_boost_CHECKED_COMPONENT TRUE)
  1534. if(NOT Boost_${COMPONENT}_FOUND)
  1535. string(TOLOWER ${COMPONENT} COMPONENT)
  1536. list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT})
  1537. endif()
  1538. endforeach()
  1539. if(_Boost_MISSING_COMPONENTS AND _Boost_EXTRA_FIND_COMPONENTS)
  1540. # Optional indirect dependencies are not counted as missing.
  1541. list(REMOVE_ITEM _Boost_MISSING_COMPONENTS ${_Boost_EXTRA_FIND_COMPONENTS})
  1542. endif()
  1543. if(Boost_DEBUG)
  1544. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] Boost_FOUND = ${Boost_FOUND}")
  1545. endif()
  1546. if (_Boost_MISSING_COMPONENTS)
  1547. set(Boost_FOUND 0)
  1548. # We were unable to find some libraries, so generate a sensible
  1549. # error message that lists the libraries we were unable to find.
  1550. string(APPEND Boost_ERROR_REASON
  1551. "\nCould not find the following")
  1552. if(Boost_USE_STATIC_LIBS)
  1553. string(APPEND Boost_ERROR_REASON " static")
  1554. endif()
  1555. string(APPEND Boost_ERROR_REASON
  1556. " Boost libraries:\n")
  1557. foreach(COMPONENT ${_Boost_MISSING_COMPONENTS})
  1558. string(APPEND Boost_ERROR_REASON
  1559. " ${Boost_NAMESPACE}_${COMPONENT}\n")
  1560. endforeach()
  1561. list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED)
  1562. list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS)
  1563. if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
  1564. string(APPEND Boost_ERROR_REASON
  1565. "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.")
  1566. else ()
  1567. string(APPEND Boost_ERROR_REASON
  1568. "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.")
  1569. endif ()
  1570. endif ()
  1571. if( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
  1572. # Compatibility Code for backwards compatibility with CMake
  1573. # 2.4's FindBoost module.
  1574. # Look for the boost library path.
  1575. # Note that the user may not have installed any libraries
  1576. # so it is quite possible the Boost_LIBRARY_DIRS may not exist.
  1577. set(_boost_LIB_DIR ${Boost_INCLUDE_DIR})
  1578. if("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
  1579. get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
  1580. endif()
  1581. if("${_boost_LIB_DIR}" MATCHES "/include$")
  1582. # Strip off the trailing "/include" in the path.
  1583. get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
  1584. endif()
  1585. if(EXISTS "${_boost_LIB_DIR}/lib")
  1586. string(APPEND _boost_LIB_DIR /lib)
  1587. elseif(EXISTS "${_boost_LIB_DIR}/stage/lib")
  1588. string(APPEND _boost_LIB_DIR "/stage/lib")
  1589. else()
  1590. set(_boost_LIB_DIR "")
  1591. endif()
  1592. if(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
  1593. set(Boost_LIBRARY_DIRS ${_boost_LIB_DIR})
  1594. endif()
  1595. endif()
  1596. else()
  1597. # Boost headers were not found so no components were found.
  1598. foreach(COMPONENT ${Boost_FIND_COMPONENTS})
  1599. string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  1600. set(Boost_${UPPERCOMPONENT}_FOUND 0)
  1601. endforeach()
  1602. endif()
  1603. # ------------------------------------------------------------------------
  1604. # Add imported targets
  1605. # ------------------------------------------------------------------------
  1606. if(Boost_FOUND)
  1607. # For header-only libraries
  1608. if(NOT TARGET Boost::boost)
  1609. add_library(Boost::boost INTERFACE IMPORTED)
  1610. if(Boost_INCLUDE_DIRS)
  1611. set_target_properties(Boost::boost PROPERTIES
  1612. INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}")
  1613. endif()
  1614. endif()
  1615. foreach(COMPONENT ${Boost_FIND_COMPONENTS})
  1616. if(_Boost_IMPORTED_TARGETS AND NOT TARGET Boost::${COMPONENT})
  1617. string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  1618. if(Boost_${UPPERCOMPONENT}_FOUND)
  1619. if(Boost_USE_STATIC_LIBS)
  1620. add_library(Boost::${COMPONENT} STATIC IMPORTED)
  1621. else()
  1622. # Even if Boost_USE_STATIC_LIBS is OFF, we might have static
  1623. # libraries as a result.
  1624. add_library(Boost::${COMPONENT} UNKNOWN IMPORTED)
  1625. endif()
  1626. if(Boost_INCLUDE_DIRS)
  1627. set_target_properties(Boost::${COMPONENT} PROPERTIES
  1628. INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}")
  1629. endif()
  1630. if(EXISTS "${Boost_${UPPERCOMPONENT}_LIBRARY}")
  1631. set_target_properties(Boost::${COMPONENT} PROPERTIES
  1632. IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
  1633. IMPORTED_LOCATION "${Boost_${UPPERCOMPONENT}_LIBRARY}")
  1634. endif()
  1635. if(EXISTS "${Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE}")
  1636. set_property(TARGET Boost::${COMPONENT} APPEND PROPERTY
  1637. IMPORTED_CONFIGURATIONS RELEASE)
  1638. set_target_properties(Boost::${COMPONENT} PROPERTIES
  1639. IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
  1640. IMPORTED_LOCATION_RELEASE "${Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE}")
  1641. endif()
  1642. if(EXISTS "${Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG}")
  1643. set_property(TARGET Boost::${COMPONENT} APPEND PROPERTY
  1644. IMPORTED_CONFIGURATIONS DEBUG)
  1645. set_target_properties(Boost::${COMPONENT} PROPERTIES
  1646. IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
  1647. IMPORTED_LOCATION_DEBUG "${Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG}")
  1648. endif()
  1649. if(_Boost_${UPPERCOMPONENT}_DEPENDENCIES)
  1650. unset(_Boost_${UPPERCOMPONENT}_TARGET_DEPENDENCIES)
  1651. foreach(dep ${_Boost_${UPPERCOMPONENT}_DEPENDENCIES})
  1652. list(APPEND _Boost_${UPPERCOMPONENT}_TARGET_DEPENDENCIES Boost::${dep})
  1653. endforeach()
  1654. if(COMPONENT STREQUAL "thread")
  1655. list(APPEND _Boost_${UPPERCOMPONENT}_TARGET_DEPENDENCIES Threads::Threads)
  1656. endif()
  1657. set_target_properties(Boost::${COMPONENT} PROPERTIES
  1658. INTERFACE_LINK_LIBRARIES "${_Boost_${UPPERCOMPONENT}_TARGET_DEPENDENCIES}")
  1659. endif()
  1660. endif()
  1661. endif()
  1662. endforeach()
  1663. endif()
  1664. # ------------------------------------------------------------------------
  1665. # Notification to end user about what was found
  1666. # ------------------------------------------------------------------------
  1667. set(Boost_LIBRARIES "")
  1668. if(Boost_FOUND)
  1669. if(NOT Boost_FIND_QUIETLY)
  1670. message(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
  1671. if(Boost_FIND_COMPONENTS)
  1672. message(STATUS "Found the following Boost libraries:")
  1673. endif()
  1674. endif()
  1675. foreach( COMPONENT ${Boost_FIND_COMPONENTS} )
  1676. string( TOUPPER ${COMPONENT} UPPERCOMPONENT )
  1677. if( Boost_${UPPERCOMPONENT}_FOUND )
  1678. if(NOT Boost_FIND_QUIETLY)
  1679. message (STATUS " ${COMPONENT}")
  1680. endif()
  1681. list(APPEND Boost_LIBRARIES ${Boost_${UPPERCOMPONENT}_LIBRARY})
  1682. endif()
  1683. endforeach()
  1684. else()
  1685. if(Boost_FIND_REQUIRED)
  1686. message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")
  1687. else()
  1688. if(NOT Boost_FIND_QUIETLY)
  1689. # we opt not to automatically output Boost_ERROR_REASON here as
  1690. # it could be quite lengthy and somewhat imposing in its requests
  1691. # Since Boost is not always a required dependency we'll leave this
  1692. # up to the end-user.
  1693. if(Boost_DEBUG OR Boost_DETAILED_FAILURE_MSG)
  1694. message(STATUS "Could NOT find Boost\n${Boost_ERROR_REASON}")
  1695. else()
  1696. message(STATUS "Could NOT find Boost")
  1697. endif()
  1698. endif()
  1699. endif()
  1700. endif()
  1701. # Configure display of cache entries in GUI.
  1702. foreach(v BOOSTROOT BOOST_ROOT ${_Boost_VARS_INC} ${_Boost_VARS_LIB})
  1703. get_property(_type CACHE ${v} PROPERTY TYPE)
  1704. if(_type)
  1705. set_property(CACHE ${v} PROPERTY ADVANCED 1)
  1706. if("x${_type}" STREQUAL "xUNINITIALIZED")
  1707. if("x${v}" STREQUAL "xBoost_ADDITIONAL_VERSIONS")
  1708. set_property(CACHE ${v} PROPERTY TYPE STRING)
  1709. else()
  1710. set_property(CACHE ${v} PROPERTY TYPE PATH)
  1711. endif()
  1712. endif()
  1713. endif()
  1714. endforeach()
  1715. # Record last used values of input variables so we can
  1716. # detect on the next run if the user changed them.
  1717. foreach(v
  1718. ${_Boost_VARS_INC} ${_Boost_VARS_LIB}
  1719. ${_Boost_VARS_DIR} ${_Boost_VARS_NAME}
  1720. )
  1721. if(DEFINED ${v})
  1722. set(_${v}_LAST "${${v}}" CACHE INTERNAL "Last used ${v} value.")
  1723. else()
  1724. unset(_${v}_LAST CACHE)
  1725. endif()
  1726. endforeach()
  1727. # Maintain a persistent list of components requested anywhere since
  1728. # the last flush.
  1729. set(_Boost_COMPONENTS_SEARCHED "${_Boost_COMPONENTS_SEARCHED}")
  1730. list(APPEND _Boost_COMPONENTS_SEARCHED ${Boost_FIND_COMPONENTS})
  1731. list(REMOVE_DUPLICATES _Boost_COMPONENTS_SEARCHED)
  1732. list(SORT _Boost_COMPONENTS_SEARCHED)
  1733. set(_Boost_COMPONENTS_SEARCHED "${_Boost_COMPONENTS_SEARCHED}"
  1734. CACHE INTERNAL "Components requested for this build tree.")