FindBoost.cmake 51 KB

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