FindBoost.cmake 74 KB

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