FindBoost.cmake 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  1. # - Try to find Boost include dirs and libraries
  2. # Usage of this module as follows:
  3. #
  4. # == Using Header-Only libraries from within Boost: ==
  5. #
  6. # find_package( Boost 1.36.0 )
  7. # if(Boost_FOUND)
  8. # include_directories(${Boost_INCLUDE_DIRS})
  9. # add_executable(foo foo.cc)
  10. # endif()
  11. #
  12. #
  13. # == Using actual libraries from within Boost: ==
  14. #
  15. # set(Boost_USE_STATIC_LIBS ON)
  16. # set(Boost_USE_MULTITHREADED ON)
  17. # find_package( Boost 1.36.0 COMPONENTS date_time filesystem system ... )
  18. #
  19. # if(Boost_FOUND)
  20. # include_directories(${Boost_INCLUDE_DIRS})
  21. # add_executable(foo foo.cc)
  22. # target_link_libraries(foo ${Boost_LIBRARIES})
  23. # endif()
  24. #
  25. #
  26. # The components list needs to contain actual names of boost libraries only,
  27. # such as "date_time" for "libboost_date_time". If you're using parts of
  28. # Boost that contain header files only (e.g. foreach) you do not need to
  29. # specify COMPONENTS.
  30. #
  31. # You should provide a minimum version number that should be used. If you provide this
  32. # version number and specify the REQUIRED attribute, this module will fail if it
  33. # can't find the specified or a later version. If you specify a version number this is
  34. # automatically put into the considered list of version numbers and thus doesn't need
  35. # to be specified in the Boost_ADDITIONAL_VERSIONS variable (see below).
  36. #
  37. # NOTE for Visual Studio Users:
  38. # Automatic linking is used on MSVC & Borland compilers by default when
  39. # #including things in Boost. It's important to note that setting
  40. # Boost_USE_STATIC_LIBS to OFF is NOT enough to get you dynamic linking,
  41. # should you need this feature. Automatic linking typically uses static
  42. # libraries with a few exceptions (Boost.Python is one).
  43. #
  44. # Please see the section below near Boost_LIB_DIAGNOSTIC_DEFINITIONS for
  45. # more details. Adding a TARGET_LINK_LIBRARIES() as shown in the example
  46. # above appears to cause VS to link dynamically if Boost_USE_STATIC_LIBS
  47. # gets set to OFF. It is suggested you avoid automatic linking since it
  48. # will make your application less portable.
  49. #
  50. # =========== The mess that is Boost_ADDITIONAL_VERSIONS (sorry?) ============
  51. #
  52. # OK, so the Boost_ADDITIONAL_VERSIONS variable can be used to specify a list of
  53. # boost version numbers that should be taken into account when searching
  54. # for Boost. Unfortunately boost puts the version number into the
  55. # actual filename for the libraries, so this variable will certainly be needed
  56. # in the future when new Boost versions are released.
  57. #
  58. # Currently this module searches for the following version numbers:
  59. # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1,
  60. # 1.36, 1.36.0, 1.36.1, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0,
  61. # 1.40, 1.40.0
  62. #
  63. # NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should
  64. # add both 1.x and 1.x.0 as shown above. Official Boost include directories
  65. # omit the 3rd version number from include paths if it is 0 although not all
  66. # binary Boost releases do so.
  67. #
  68. # SET(Boost_ADDITIONAL_VERSIONS "0.99" "0.99.0" "1.78" "1.78.0")
  69. #
  70. # ===================================== ============= ========================
  71. #
  72. # Variables used by this module, they can change the default behaviour and
  73. # need to be set before calling find_package:
  74. #
  75. # Boost_USE_MULTITHREADED Can be set to OFF to use the non-multithreaded
  76. # boost libraries. If not specified, defaults
  77. # to ON.
  78. #
  79. # Boost_USE_STATIC_LIBS Can be set to ON to force the use of the static
  80. # boost libraries. Defaults to OFF.
  81. #
  82. # Other Variables used by this module which you may want to set.
  83. #
  84. # Boost_ADDITIONAL_VERSIONS A list of version numbers to use for searching
  85. # the boost include directory. Please see
  86. # the documentation above regarding this
  87. # annoying, but necessary variable :(
  88. #
  89. # Boost_DEBUG Set this to TRUE to enable debugging output
  90. # of FindBoost.cmake if you are having problems.
  91. # Please enable this before filing any bug
  92. # reports.
  93. #
  94. # Boost_COMPILER Set this to the compiler suffix used by Boost
  95. # (e.g. "-gcc43") if FindBoost has problems finding
  96. # the proper Boost installation
  97. #
  98. # These last three variables are available also as environment variables:
  99. #
  100. # BOOST_ROOT or BOOSTROOT The preferred installation prefix for searching for
  101. # Boost. Set this if the module has problems finding
  102. # the proper Boost installation.
  103. #
  104. # BOOST_INCLUDEDIR Set this to the include directory of Boost, if the
  105. # module has problems finding the proper Boost installation
  106. #
  107. # BOOST_LIBRARYDIR Set this to the lib directory of Boost, if the
  108. # module has problems finding the proper Boost installation
  109. #
  110. # Variables defined by this module:
  111. #
  112. # Boost_FOUND System has Boost, this means the include dir was
  113. # found, as well as all the libraries specified in
  114. # the COMPONENTS list.
  115. #
  116. # Boost_INCLUDE_DIRS Boost include directories: not cached
  117. #
  118. # Boost_INCLUDE_DIR This is almost the same as above, but this one is
  119. # cached and may be modified by advanced users
  120. #
  121. # Boost_LIBRARIES Link to these to use the Boost libraries that you
  122. # specified: not cached
  123. #
  124. # Boost_LIBRARY_DIRS The path to where the Boost library files are.
  125. #
  126. # Boost_VERSION The version number of the boost libraries that
  127. # have been found, same as in version.hpp from Boost
  128. #
  129. # Boost_LIB_VERSION The version number in filename form as
  130. # it's appended to the library filenames
  131. #
  132. # Boost_MAJOR_VERSION major version number of boost
  133. # Boost_MINOR_VERSION minor version number of boost
  134. # Boost_SUBMINOR_VERSION subminor version number of boost
  135. #
  136. # Boost_LIB_DIAGNOSTIC_DEFINITIONS [WIN32 Only] You can call
  137. # add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
  138. # to have diagnostic information about Boost's
  139. # automatic linking outputted during compilation time.
  140. #
  141. # For each component you specify in find_package(), the following (UPPER-CASE)
  142. # variables are set. You can use these variables if you would like to pick and
  143. # choose components for your targets instead of just using Boost_LIBRARIES.
  144. #
  145. # Boost_${COMPONENT}_FOUND True IF the Boost library "component" was found.
  146. #
  147. # Boost_${COMPONENT}_LIBRARY Contains the libraries for the specified Boost
  148. # "component" (includes debug and optimized keywords
  149. # when needed).
  150. #=============================================================================
  151. # Copyright 2006-2009 Kitware, Inc.
  152. # Copyright 2006-2008 Andreas Schneider <[email protected]>
  153. # Copyright 2007 Wengo
  154. # Copyright 2007 Mike Jackson
  155. # Copyright 2008 Andreas Pakulat <[email protected]>
  156. #
  157. # Distributed under the OSI-approved BSD License (the "License");
  158. # see accompanying file Copyright.txt for details.
  159. #
  160. # This software is distributed WITHOUT ANY WARRANTY; without even the
  161. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  162. # See the License for more information.
  163. #=============================================================================
  164. # (To distributed this file outside of CMake, substitute the full
  165. # License text for the above reference.)
  166. #-------------------------------------------------------------------------------
  167. # FindBoost functions & macros
  168. #
  169. ############################################
  170. #
  171. # Check the existence of the libraries.
  172. #
  173. ############################################
  174. # This macro was taken directly from the FindQt4.cmake file that is included
  175. # with the CMake distribution. This is NOT my work. All work was done by the
  176. # original authors of the FindQt4.cmake file. Only minor modifications were
  177. # made to remove references to Qt and make this file more generally applicable
  178. # And ELSE/ENDIF pairs were removed for readability.
  179. #########################################################################
  180. MACRO (_Boost_ADJUST_LIB_VARS basename)
  181. IF (Boost_INCLUDE_DIR )
  182. IF (Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
  183. # if the generator supports configuration types then set
  184. # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
  185. IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
  186. SET(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
  187. ELSE()
  188. # if there are no configuration types and CMAKE_BUILD_TYPE has no value
  189. # then just use the release libraries
  190. SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
  191. ENDIF()
  192. # FIXME: This probably should be set for both cases
  193. SET(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
  194. ENDIF()
  195. # if only the release version was found, set the debug variable also to the release version
  196. IF (Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG)
  197. SET(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE})
  198. SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE})
  199. SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE})
  200. ENDIF()
  201. # if only the debug version was found, set the release variable also to the debug version
  202. IF (Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE)
  203. SET(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG})
  204. SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG})
  205. SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG})
  206. ENDIF()
  207. IF (Boost_${basename}_LIBRARY)
  208. set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library")
  209. # Remove superfluous "debug" / "optimized" keywords from
  210. # Boost_LIBRARY_DIRS
  211. FOREACH(_boost_my_lib ${Boost_${basename}_LIBRARY})
  212. GET_FILENAME_COMPONENT(_boost_my_lib_path "${_boost_my_lib}" PATH)
  213. LIST(APPEND Boost_LIBRARY_DIRS ${_boost_my_lib_path})
  214. ENDFOREACH()
  215. LIST(REMOVE_DUPLICATES Boost_LIBRARY_DIRS)
  216. set(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS} CACHE FILEPATH "Boost library directory")
  217. SET(Boost_${basename}_FOUND ON CACHE INTERNAL "Whether the Boost ${basename} library found")
  218. ENDIF(Boost_${basename}_LIBRARY)
  219. ENDIF (Boost_INCLUDE_DIR )
  220. # Make variables changeble to the advanced user
  221. MARK_AS_ADVANCED(
  222. Boost_${basename}_LIBRARY
  223. Boost_${basename}_LIBRARY_RELEASE
  224. Boost_${basename}_LIBRARY_DEBUG
  225. )
  226. ENDMACRO (_Boost_ADJUST_LIB_VARS)
  227. #-------------------------------------------------------------------------------
  228. #
  229. # Runs compiler with "-dumpversion" and parses major/minor
  230. # version with a regex.
  231. #
  232. FUNCTION(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION)
  233. EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
  234. ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
  235. OUTPUT_VARIABLE _boost_COMPILER_VERSION
  236. )
  237. STRING(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
  238. _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
  239. SET(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE)
  240. ENDFUNCTION()
  241. #
  242. # End functions/macros
  243. #
  244. #-------------------------------------------------------------------------------
  245. IF(NOT DEFINED Boost_USE_MULTITHREADED)
  246. SET(Boost_USE_MULTITHREADED TRUE)
  247. ENDIF()
  248. if(Boost_FIND_VERSION_EXACT)
  249. # The version may appear in a directory with or without the patch
  250. # level, even when the patch level is non-zero.
  251. set(_boost_TEST_VERSIONS
  252. "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.${Boost_FIND_VERSION_PATCH}"
  253. "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  254. else(Boost_FIND_VERSION_EXACT)
  255. # The user has not requested an exact version. Among known
  256. # versions, find those that are acceptable to the user request.
  257. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
  258. "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37"
  259. "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0"
  260. "1.34" "1.33.1" "1.33.0" "1.33")
  261. set(_boost_TEST_VERSIONS)
  262. if(Boost_FIND_VERSION)
  263. set(_Boost_FIND_VERSION_SHORT "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  264. # Select acceptable versions.
  265. foreach(version ${_Boost_KNOWN_VERSIONS})
  266. if(NOT "${version}" VERSION_LESS "${Boost_FIND_VERSION}")
  267. # This version is high enough.
  268. list(APPEND _boost_TEST_VERSIONS "${version}")
  269. elseif("${version}.99" VERSION_EQUAL "${_Boost_FIND_VERSION_SHORT}.99")
  270. # This version is a short-form for the requested version with
  271. # the patch level dropped.
  272. list(APPEND _boost_TEST_VERSIONS "${version}")
  273. endif()
  274. endforeach(version)
  275. else(Boost_FIND_VERSION)
  276. # Any version is acceptable.
  277. set(_boost_TEST_VERSIONS "${_Boost_KNOWN_VERSIONS}")
  278. endif(Boost_FIND_VERSION)
  279. endif(Boost_FIND_VERSION_EXACT)
  280. # The reason that we failed to find Boost. This will be set to a
  281. # user-friendly message when we fail to find some necessary piece of
  282. # Boost.
  283. set(Boost_ERROR_REASON)
  284. SET( _boost_IN_CACHE TRUE)
  285. IF(Boost_INCLUDE_DIR)
  286. # On versions < 1.35, remove the System library from the considered list
  287. # since it wasn't added until 1.35.
  288. if(Boost_VERSION AND Boost_FIND_COMPONENTS)
  289. math(EXPR _boost_maj "${Boost_VERSION} / 100000")
  290. math(EXPR _boost_min "${Boost_VERSION} / 100 % 1000")
  291. if(${_boost_maj}.${_boost_min} VERSION_LESS 1.35)
  292. list(REMOVE_ITEM Boost_FIND_COMPONENTS system)
  293. endif()
  294. endif()
  295. FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
  296. STRING(TOUPPER ${COMPONENT} COMPONENT)
  297. IF(NOT Boost_${COMPONENT}_FOUND)
  298. SET( _boost_IN_CACHE FALSE)
  299. ENDIF(NOT Boost_${COMPONENT}_FOUND)
  300. ENDFOREACH(COMPONENT)
  301. ELSE(Boost_INCLUDE_DIR)
  302. SET( _boost_IN_CACHE FALSE)
  303. ENDIF(Boost_INCLUDE_DIR)
  304. IF (_boost_IN_CACHE)
  305. # in cache already
  306. SET(Boost_FOUND TRUE)
  307. FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
  308. STRING(TOUPPER ${COMPONENT} COMPONENT)
  309. _Boost_ADJUST_LIB_VARS( ${COMPONENT} )
  310. SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${COMPONENT}_LIBRARY})
  311. ENDFOREACH(COMPONENT)
  312. SET(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
  313. IF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
  314. MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
  315. MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
  316. MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
  317. ENDIF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
  318. if(Boost_DEBUG)
  319. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  320. "boost ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION} "
  321. "is already in the cache. For debugging messages, please clear the cache.")
  322. endif()
  323. ELSE (_boost_IN_CACHE)
  324. # Need to search for boost
  325. if(Boost_DEBUG)
  326. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  327. "Boost not in cache")
  328. # Output some of their choices
  329. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  330. "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
  331. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  332. "Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}")
  333. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  334. "Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}")
  335. endif()
  336. IF(WIN32)
  337. # In windows, automatic linking is performed, so you do not have
  338. # to specify the libraries. If you are linking to a dynamic
  339. # runtime, then you can choose to link to either a static or a
  340. # dynamic Boost library, the default is to do a static link. You
  341. # can alter this for a specific library "whatever" by defining
  342. # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be
  343. # linked dynamically. Alternatively you can force all Boost
  344. # libraries to dynamic link by defining BOOST_ALL_DYN_LINK.
  345. # This feature can be disabled for Boost library "whatever" by
  346. # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining
  347. # BOOST_ALL_NO_LIB.
  348. # If you want to observe which libraries are being linked against
  349. # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking
  350. # code to emit a #pragma message each time a library is selected
  351. # for linking.
  352. SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS
  353. "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define")
  354. ENDIF(WIN32)
  355. SET(_boost_INCLUDE_SEARCH_DIRS
  356. C:/boost/include
  357. C:/boost
  358. "$ENV{ProgramFiles}/boost/include"
  359. "$ENV{ProgramFiles}/boost"
  360. /sw/local/include
  361. )
  362. # If BOOST_ROOT was defined in the environment, use it.
  363. if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
  364. set(BOOST_ROOT $ENV{BOOST_ROOT})
  365. endif(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
  366. # If BOOSTROOT was defined in the environment, use it.
  367. if (NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
  368. set(BOOST_ROOT $ENV{BOOSTROOT})
  369. endif(NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
  370. # If BOOST_INCLUDEDIR was defined in the environment, use it.
  371. IF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
  372. set(BOOST_INCLUDEDIR $ENV{BOOST_INCLUDEDIR})
  373. ENDIF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
  374. # If BOOST_LIBRARYDIR was defined in the environment, use it.
  375. IF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
  376. set(BOOST_LIBRARYDIR $ENV{BOOST_LIBRARYDIR})
  377. ENDIF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
  378. IF( BOOST_ROOT )
  379. file(TO_CMAKE_PATH ${BOOST_ROOT} BOOST_ROOT)
  380. ENDIF( BOOST_ROOT )
  381. if(Boost_DEBUG)
  382. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  383. "Declared as CMake or Environmental Variables:")
  384. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  385. " BOOST_ROOT = ${BOOST_ROOT}")
  386. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  387. " BOOST_INCLUDEDIR = ${BOOST_INCLUDEDIR}")
  388. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  389. " BOOST_LIBRARYDIR = ${BOOST_LIBRARYDIR}")
  390. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  391. "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
  392. endif()
  393. IF( BOOST_ROOT )
  394. SET(_boost_INCLUDE_SEARCH_DIRS
  395. ${BOOST_ROOT}/include
  396. ${BOOST_ROOT}
  397. ${_boost_INCLUDE_SEARCH_DIRS})
  398. ENDIF( BOOST_ROOT )
  399. IF( BOOST_INCLUDEDIR )
  400. file(TO_CMAKE_PATH ${BOOST_INCLUDEDIR} BOOST_INCLUDEDIR)
  401. SET(_boost_INCLUDE_SEARCH_DIRS
  402. ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS})
  403. ENDIF( BOOST_INCLUDEDIR )
  404. # ------------------------------------------------------------------------
  405. # Search for Boost include DIR
  406. # ------------------------------------------------------------------------
  407. # Try to find Boost by stepping backwards through the Boost versions
  408. # we know about.
  409. IF( NOT Boost_INCLUDE_DIR )
  410. # Build a list of path suffixes for each version.
  411. SET(_boost_PATH_SUFFIXES)
  412. FOREACH(_boost_VER ${_boost_TEST_VERSIONS})
  413. # Add in a path suffix, based on the required version, ideally
  414. # we could read this from version.hpp, but for that to work we'd
  415. # need to know the include dir already
  416. set(_boost_BOOSTIFIED_VERSION)
  417. # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0
  418. IF(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
  419. STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3"
  420. _boost_BOOSTIFIED_VERSION ${_boost_VER})
  421. ELSEIF(_boost_VER MATCHES "[0-9]+\\.[0-9]+")
  422. STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2"
  423. _boost_BOOSTIFIED_VERSION ${_boost_VER})
  424. ENDIF()
  425. list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_BOOSTIFIED_VERSION}")
  426. if(WIN32)
  427. # For BoostPro's underscores (and others?)
  428. list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_BOOSTIFIED_VERSION}")
  429. endif()
  430. ENDFOREACH(_boost_VER)
  431. if(Boost_DEBUG)
  432. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  433. "Include debugging info:")
  434. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  435. " _boost_INCLUDE_SEARCH_DIRS = ${_boost_INCLUDE_SEARCH_DIRS}")
  436. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  437. " _boost_PATH_SUFFIXES = ${_boost_PATH_SUFFIXES}")
  438. endif()
  439. # Look for a standard boost header file.
  440. FIND_PATH(Boost_INCLUDE_DIR
  441. NAMES boost/config.hpp
  442. HINTS ${_boost_INCLUDE_SEARCH_DIRS}
  443. PATH_SUFFIXES ${_boost_PATH_SUFFIXES}
  444. )
  445. ENDIF( NOT Boost_INCLUDE_DIR )
  446. # ------------------------------------------------------------------------
  447. # Extract version information from version.hpp
  448. # ------------------------------------------------------------------------
  449. IF(Boost_INCLUDE_DIR)
  450. # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp
  451. # Read the whole file:
  452. #
  453. SET(BOOST_VERSION 0)
  454. SET(BOOST_LIB_VERSION "")
  455. FILE(READ "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS)
  456. if(Boost_DEBUG)
  457. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  458. "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp")
  459. endif()
  460. STRING(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}")
  461. STRING(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}")
  462. SET(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE INTERNAL "The library version string for boost libraries")
  463. SET(Boost_VERSION ${Boost_VERSION} CACHE INTERNAL "The version number for boost libraries")
  464. IF(NOT "${Boost_VERSION}" STREQUAL "0")
  465. MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
  466. MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
  467. MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
  468. set(Boost_ERROR_REASON
  469. "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}")
  470. ENDIF(NOT "${Boost_VERSION}" STREQUAL "0")
  471. if(Boost_DEBUG)
  472. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  473. "version.hpp reveals boost "
  474. "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
  475. endif()
  476. ELSE(Boost_INCLUDE_DIR)
  477. set(Boost_ERROR_REASON
  478. "${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.")
  479. ENDIF(Boost_INCLUDE_DIR)
  480. # ------------------------------------------------------------------------
  481. # Suffix initialization and compiler suffix detection.
  482. # ------------------------------------------------------------------------
  483. # Setting some more suffixes for the library
  484. SET (Boost_LIB_PREFIX "")
  485. if ( WIN32 AND Boost_USE_STATIC_LIBS )
  486. SET (Boost_LIB_PREFIX "lib")
  487. endif()
  488. if (Boost_COMPILER)
  489. set(_boost_COMPILER ${Boost_COMPILER})
  490. if(Boost_DEBUG)
  491. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  492. "using user-specified Boost_COMPILER = ${_boost_COMPILER}")
  493. endif()
  494. else(Boost_COMPILER)
  495. # Attempt to guess the compiler suffix
  496. # NOTE: this is not perfect yet, if you experience any issues
  497. # please report them and use the Boost_COMPILER variable
  498. # to work around the problems.
  499. if("${CMAKE_CXX_COMPILER}" MATCHES "icl"
  500. OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
  501. if(WIN32)
  502. set (_boost_COMPILER "-iw")
  503. else()
  504. set (_boost_COMPILER "-il")
  505. endif()
  506. elseif (MSVC90)
  507. SET (_boost_COMPILER "-vc90")
  508. elseif (MSVC80)
  509. SET (_boost_COMPILER "-vc80")
  510. elseif (MSVC71)
  511. SET (_boost_COMPILER "-vc71")
  512. elseif (MSVC70) # Good luck!
  513. SET (_boost_COMPILER "-vc7") # yes, this is correct
  514. elseif (MSVC60) # Good luck!
  515. SET (_boost_COMPILER "-vc6") # yes, this is correct
  516. elseif (BORLAND)
  517. SET (_boost_COMPILER "-bcb")
  518. elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "SunPro")
  519. set(_boost_COMPILER "-sw")
  520. elseif (MINGW)
  521. if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
  522. SET(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34
  523. else()
  524. _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
  525. SET (_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}")
  526. endif()
  527. elseif (UNIX)
  528. if (CMAKE_COMPILER_IS_GNUCXX)
  529. if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
  530. SET(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34
  531. else()
  532. _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
  533. # Determine which version of GCC we have.
  534. IF(APPLE)
  535. IF(Boost_MINOR_VERSION)
  536. IF(${Boost_MINOR_VERSION} GREATER 35)
  537. # In Boost 1.36.0 and newer, the mangled compiler name used
  538. # on Mac OS X/Darwin is "xgcc".
  539. SET(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}")
  540. ELSE(${Boost_MINOR_VERSION} GREATER 35)
  541. # In Boost <= 1.35.0, there is no mangled compiler name for
  542. # the Mac OS X/Darwin version of GCC.
  543. SET(_boost_COMPILER "")
  544. ENDIF(${Boost_MINOR_VERSION} GREATER 35)
  545. ELSE(Boost_MINOR_VERSION)
  546. # We don't know the Boost version, so assume it's
  547. # pre-1.36.0.
  548. SET(_boost_COMPILER "")
  549. ENDIF(Boost_MINOR_VERSION)
  550. ELSE()
  551. SET (_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}")
  552. ENDIF()
  553. endif()
  554. endif (CMAKE_COMPILER_IS_GNUCXX)
  555. endif()
  556. if(Boost_DEBUG)
  557. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  558. "guessed _boost_COMPILER = ${_boost_COMPILER}")
  559. endif()
  560. endif(Boost_COMPILER)
  561. SET (_boost_MULTITHREADED "-mt")
  562. if( NOT Boost_USE_MULTITHREADED )
  563. set (_boost_MULTITHREADED "")
  564. endif()
  565. if(Boost_DEBUG)
  566. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  567. "_boost_MULTITHREADED = ${_boost_MULTITHREADED}")
  568. endif()
  569. SET( _boost_STATIC_TAG "")
  570. set( _boost_ABI_TAG "")
  571. IF (WIN32)
  572. IF(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl"
  573. OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
  574. SET (_boost_ABI_TAG "g")
  575. ENDIF()
  576. IF( Boost_USE_STATIC_LIBS )
  577. SET( _boost_STATIC_TAG "-s")
  578. ENDIF( Boost_USE_STATIC_LIBS )
  579. ENDIF(WIN32)
  580. SET (_boost_ABI_TAG "${_boost_ABI_TAG}d")
  581. if(Boost_DEBUG)
  582. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  583. "_boost_STATIC_TAG = ${_boost_STATIC_TAG}")
  584. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  585. "_boost_ABI_TAG = ${_boost_ABI_TAG}")
  586. endif()
  587. # ------------------------------------------------------------------------
  588. # Begin finding boost libraries
  589. # ------------------------------------------------------------------------
  590. SET(_boost_LIBRARIES_SEARCH_DIRS
  591. ${Boost_INCLUDE_DIR}/lib
  592. ${Boost_INCLUDE_DIR}/../lib
  593. C:/boost/lib
  594. C:/boost
  595. "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}_${Boost_SUBMINOR_VERSION}/lib"
  596. "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}/lib"
  597. "$ENV{ProgramFiles}/boost/lib"
  598. "$ENV{ProgramFiles}/boost"
  599. /sw/local/lib
  600. )
  601. IF( BOOST_ROOT )
  602. SET(_boost_LIBRARIES_SEARCH_DIRS
  603. ${BOOST_ROOT}/lib
  604. ${BOOST_ROOT}/stage/lib
  605. ${_boost_LIBRARIES_SEARCH_DIRS})
  606. ENDIF( BOOST_ROOT )
  607. IF( BOOST_LIBRARYDIR )
  608. file(TO_CMAKE_PATH ${BOOST_LIBRARYDIR} BOOST_LIBRARYDIR)
  609. SET(_boost_LIBRARIES_SEARCH_DIRS
  610. ${BOOST_LIBRARYDIR} ${_boost_LIBRARIES_SEARCH_DIRS})
  611. ENDIF( BOOST_LIBRARYDIR )
  612. if(Boost_DEBUG)
  613. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  614. "_boost_LIBRARIES_SEARCH_DIRS = ${_boost_LIBRARIES_SEARCH_DIRS}")
  615. endif()
  616. FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
  617. STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  618. SET( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" )
  619. SET( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" )
  620. SET( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND")
  621. # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
  622. IF( Boost_USE_STATIC_LIBS )
  623. SET( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
  624. IF(WIN32)
  625. SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
  626. ELSE(WIN32)
  627. SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
  628. ENDIF(WIN32)
  629. ENDIF( Boost_USE_STATIC_LIBS )
  630. FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE
  631. NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${Boost_LIB_VERSION}
  632. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION}
  633. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${Boost_LIB_VERSION}
  634. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION}
  635. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}
  636. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}
  637. ${Boost_LIB_PREFIX}boost_${COMPONENT}
  638. HINTS ${_boost_LIBRARIES_SEARCH_DIRS}
  639. )
  640. FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG
  641. NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION}
  642. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION}
  643. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION}
  644. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION}
  645. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}
  646. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}
  647. ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_boost_ABI_TAG}
  648. HINTS ${_boost_LIBRARIES_SEARCH_DIRS}
  649. )
  650. _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT})
  651. IF( Boost_USE_STATIC_LIBS )
  652. SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
  653. ENDIF( Boost_USE_STATIC_LIBS )
  654. ENDFOREACH(COMPONENT)
  655. # ------------------------------------------------------------------------
  656. # End finding boost libraries
  657. # ------------------------------------------------------------------------
  658. SET(Boost_INCLUDE_DIRS
  659. ${Boost_INCLUDE_DIR}
  660. )
  661. SET(Boost_FOUND FALSE)
  662. IF(Boost_INCLUDE_DIR)
  663. SET( Boost_FOUND TRUE )
  664. # Check the version of Boost against the requested version.
  665. if (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
  666. 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")
  667. endif (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
  668. if(Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
  669. set( Boost_FOUND FALSE )
  670. set(_Boost_VERSION_AGE "old")
  671. elseif(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
  672. if(Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
  673. set( Boost_FOUND FALSE )
  674. set(_Boost_VERSION_AGE "old")
  675. elseif(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
  676. if( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
  677. set( Boost_FOUND FALSE )
  678. set(_Boost_VERSION_AGE "old")
  679. endif( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
  680. endif( Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
  681. endif( Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
  682. if (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
  683. # If the user requested an exact version of Boost, check
  684. # that. We already know that the Boost version we have is >= the
  685. # requested version.
  686. set(_Boost_VERSION_AGE "new")
  687. # If the user didn't specify a patchlevel, it's 0.
  688. if (NOT Boost_FIND_VERSION_PATCH)
  689. set(Boost_FIND_VERSION_PATCH 0)
  690. endif (NOT Boost_FIND_VERSION_PATCH)
  691. # We'll set Boost_FOUND true again if we have an exact version match.
  692. set(Boost_FOUND FALSE)
  693. if(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
  694. if(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
  695. if(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
  696. set( Boost_FOUND TRUE )
  697. endif(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
  698. endif( Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
  699. endif( Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
  700. endif (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
  701. if(NOT Boost_FOUND)
  702. # State that we found a version of Boost that is too new or too old.
  703. set(Boost_ERROR_REASON
  704. "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  705. if (Boost_FIND_VERSION_PATCH)
  706. set(Boost_ERROR_REASON
  707. "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}")
  708. endif (Boost_FIND_VERSION_PATCH)
  709. if (NOT Boost_FIND_VERSION_EXACT)
  710. set(Boost_ERROR_REASON "${Boost_ERROR_REASON} (or newer)")
  711. endif (NOT Boost_FIND_VERSION_EXACT)
  712. set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.")
  713. endif (NOT Boost_FOUND)
  714. if (Boost_FOUND)
  715. set(_boost_CHECKED_COMPONENT FALSE)
  716. set(_Boost_MISSING_COMPONENTS)
  717. foreach(COMPONENT ${Boost_FIND_COMPONENTS})
  718. string(TOUPPER ${COMPONENT} COMPONENT)
  719. set(_boost_CHECKED_COMPONENT TRUE)
  720. if(NOT Boost_${COMPONENT}_FOUND)
  721. string(TOLOWER ${COMPONENT} COMPONENT)
  722. list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT})
  723. set( Boost_FOUND FALSE)
  724. endif(NOT Boost_${COMPONENT}_FOUND)
  725. endforeach(COMPONENT)
  726. endif (Boost_FOUND)
  727. if(Boost_DEBUG)
  728. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] Boost_FOUND = ${Boost_FOUND}")
  729. endif()
  730. if (_Boost_MISSING_COMPONENTS)
  731. # We were unable to find some libraries, so generate a sensible
  732. # error message that lists the libraries we were unable to find.
  733. set(Boost_ERROR_REASON
  734. "${Boost_ERROR_REASON}\nThe following Boost libraries could not be found:\n")
  735. foreach(COMPONENT ${_Boost_MISSING_COMPONENTS})
  736. set(Boost_ERROR_REASON
  737. "${Boost_ERROR_REASON} boost_${COMPONENT}\n")
  738. endforeach(COMPONENT)
  739. list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED)
  740. list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS)
  741. if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
  742. set(Boost_ERROR_REASON
  743. "${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.")
  744. else (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
  745. set(Boost_ERROR_REASON
  746. "${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.")
  747. endif (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
  748. endif (_Boost_MISSING_COMPONENTS)
  749. IF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
  750. # Compatibility Code for backwards compatibility with CMake
  751. # 2.4's FindBoost module.
  752. # Look for the boost library path.
  753. # Note that the user may not have installed any libraries
  754. # so it is quite possible the Boost_LIBRARY_PATH may not exist.
  755. SET(_boost_LIB_DIR ${Boost_INCLUDE_DIR})
  756. IF("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
  757. GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
  758. ENDIF ("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
  759. IF("${_boost_LIB_DIR}" MATCHES "/include$")
  760. # Strip off the trailing "/include" in the path.
  761. GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
  762. ENDIF("${_boost_LIB_DIR}" MATCHES "/include$")
  763. IF(EXISTS "${_boost_LIB_DIR}/lib")
  764. SET (_boost_LIB_DIR ${_boost_LIB_DIR}/lib)
  765. ELSE(EXISTS "${_boost_LIB_DIR}/lib")
  766. IF(EXISTS "${_boost_LIB_DIR}/stage/lib")
  767. SET(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib)
  768. ELSE(EXISTS "${_boost_LIB_DIR}/stage/lib")
  769. SET(_boost_LIB_DIR "")
  770. ENDIF(EXISTS "${_boost_LIB_DIR}/stage/lib")
  771. ENDIF(EXISTS "${_boost_LIB_DIR}/lib")
  772. IF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
  773. SET(Boost_LIBRARY_DIRS ${_boost_LIB_DIR} CACHE FILEPATH "Boost library directory")
  774. ENDIF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
  775. ENDIF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
  776. ELSE(Boost_INCLUDE_DIR)
  777. SET( Boost_FOUND FALSE)
  778. ENDIF(Boost_INCLUDE_DIR)
  779. IF (Boost_FOUND)
  780. IF (NOT Boost_FIND_QUIETLY)
  781. MESSAGE(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
  782. ENDIF(NOT Boost_FIND_QUIETLY)
  783. IF (NOT Boost_FIND_QUIETLY)
  784. MESSAGE(STATUS "Found the following Boost libraries:")
  785. ENDIF(NOT Boost_FIND_QUIETLY)
  786. FOREACH ( COMPONENT ${Boost_FIND_COMPONENTS} )
  787. STRING( TOUPPER ${COMPONENT} UPPERCOMPONENT )
  788. IF ( Boost_${UPPERCOMPONENT}_FOUND )
  789. IF (NOT Boost_FIND_QUIETLY)
  790. MESSAGE (STATUS " ${COMPONENT}")
  791. ENDIF(NOT Boost_FIND_QUIETLY)
  792. SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${UPPERCOMPONENT}_LIBRARY})
  793. ENDIF ( Boost_${UPPERCOMPONENT}_FOUND )
  794. ENDFOREACH(COMPONENT)
  795. ELSE (Boost_FOUND)
  796. IF (Boost_FIND_REQUIRED)
  797. message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")
  798. ENDIF(Boost_FIND_REQUIRED)
  799. ENDIF(Boost_FOUND)
  800. # show the Boost_INCLUDE_DIRS AND Boost_LIBRARIES variables only in the advanced view
  801. MARK_AS_ADVANCED(Boost_INCLUDE_DIR
  802. Boost_INCLUDE_DIRS
  803. Boost_LIBRARY_DIRS
  804. )
  805. ENDIF(_boost_IN_CACHE)