FindBoost.cmake 48 KB

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