FindBoost.cmake 41 KB

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