FindBoost.cmake 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932
  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
  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.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37"
  281. "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0"
  282. "1.34" "1.33.1" "1.33.0" "1.33")
  283. set(_boost_TEST_VERSIONS)
  284. if(Boost_FIND_VERSION)
  285. set(_Boost_FIND_VERSION_SHORT "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  286. # Select acceptable versions.
  287. foreach(version ${_Boost_KNOWN_VERSIONS})
  288. if(NOT "${version}" VERSION_LESS "${Boost_FIND_VERSION}")
  289. # This version is high enough.
  290. list(APPEND _boost_TEST_VERSIONS "${version}")
  291. elseif("${version}.99" VERSION_EQUAL "${_Boost_FIND_VERSION_SHORT}.99")
  292. # This version is a short-form for the requested version with
  293. # the patch level dropped.
  294. list(APPEND _boost_TEST_VERSIONS "${version}")
  295. endif()
  296. endforeach(version)
  297. else(Boost_FIND_VERSION)
  298. # Any version is acceptable.
  299. set(_boost_TEST_VERSIONS "${_Boost_KNOWN_VERSIONS}")
  300. endif(Boost_FIND_VERSION)
  301. endif(Boost_FIND_VERSION_EXACT)
  302. # The reason that we failed to find Boost. This will be set to a
  303. # user-friendly message when we fail to find some necessary piece of
  304. # Boost.
  305. set(Boost_ERROR_REASON)
  306. SET( _boost_IN_CACHE TRUE)
  307. IF(Boost_INCLUDE_DIR)
  308. # On versions < 1.35, remove the System library from the considered list
  309. # since it wasn't added until 1.35.
  310. if(Boost_VERSION AND Boost_FIND_COMPONENTS)
  311. math(EXPR _boost_maj "${Boost_VERSION} / 100000")
  312. math(EXPR _boost_min "${Boost_VERSION} / 100 % 1000")
  313. if(${_boost_maj}.${_boost_min} VERSION_LESS 1.35)
  314. list(REMOVE_ITEM Boost_FIND_COMPONENTS system)
  315. endif()
  316. endif()
  317. FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
  318. STRING(TOUPPER ${COMPONENT} COMPONENT)
  319. IF(NOT Boost_${COMPONENT}_FOUND)
  320. SET( _boost_IN_CACHE FALSE)
  321. ENDIF(NOT Boost_${COMPONENT}_FOUND)
  322. ENDFOREACH(COMPONENT)
  323. ELSE(Boost_INCLUDE_DIR)
  324. SET( _boost_IN_CACHE FALSE)
  325. ENDIF(Boost_INCLUDE_DIR)
  326. IF (_boost_IN_CACHE)
  327. # in cache already
  328. SET(Boost_FOUND TRUE)
  329. FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
  330. STRING(TOUPPER ${COMPONENT} COMPONENT)
  331. _Boost_ADJUST_LIB_VARS( ${COMPONENT} )
  332. SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${COMPONENT}_LIBRARY})
  333. ENDFOREACH(COMPONENT)
  334. SET(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
  335. IF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
  336. MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
  337. MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
  338. MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
  339. ENDIF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
  340. if(Boost_DEBUG)
  341. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  342. "boost ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION} "
  343. "is already in the cache. For debugging messages, please clear the cache.")
  344. endif()
  345. ELSE (_boost_IN_CACHE)
  346. # Need to search for boost
  347. if(Boost_DEBUG)
  348. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  349. "Boost not in cache")
  350. # Output some of their choices
  351. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  352. "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
  353. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  354. "Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}")
  355. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  356. "Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}")
  357. endif()
  358. IF(WIN32)
  359. # In windows, automatic linking is performed, so you do not have
  360. # to specify the libraries. If you are linking to a dynamic
  361. # runtime, then you can choose to link to either a static or a
  362. # dynamic Boost library, the default is to do a static link. You
  363. # can alter this for a specific library "whatever" by defining
  364. # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be
  365. # linked dynamically. Alternatively you can force all Boost
  366. # libraries to dynamic link by defining BOOST_ALL_DYN_LINK.
  367. # This feature can be disabled for Boost library "whatever" by
  368. # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining
  369. # BOOST_ALL_NO_LIB.
  370. # If you want to observe which libraries are being linked against
  371. # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking
  372. # code to emit a #pragma message each time a library is selected
  373. # for linking.
  374. SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS
  375. "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define")
  376. ENDIF(WIN32)
  377. SET(_boost_INCLUDE_SEARCH_DIRS
  378. C:/boost/include
  379. C:/boost
  380. "$ENV{ProgramFiles}/boost/include"
  381. "$ENV{ProgramFiles}/boost"
  382. /sw/local/include
  383. )
  384. # If BOOST_ROOT was defined in the environment, use it.
  385. if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
  386. set(BOOST_ROOT $ENV{BOOST_ROOT})
  387. endif(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
  388. # If BOOSTROOT was defined in the environment, use it.
  389. if (NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
  390. set(BOOST_ROOT $ENV{BOOSTROOT})
  391. endif(NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
  392. # If BOOST_INCLUDEDIR was defined in the environment, use it.
  393. IF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
  394. set(BOOST_INCLUDEDIR $ENV{BOOST_INCLUDEDIR})
  395. ENDIF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
  396. # If BOOST_LIBRARYDIR was defined in the environment, use it.
  397. IF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
  398. set(BOOST_LIBRARYDIR $ENV{BOOST_LIBRARYDIR})
  399. ENDIF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
  400. IF( BOOST_ROOT )
  401. file(TO_CMAKE_PATH ${BOOST_ROOT} BOOST_ROOT)
  402. ENDIF( BOOST_ROOT )
  403. if(Boost_DEBUG)
  404. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  405. "Declared as CMake or Environmental Variables:")
  406. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  407. " BOOST_ROOT = ${BOOST_ROOT}")
  408. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  409. " BOOST_INCLUDEDIR = ${BOOST_INCLUDEDIR}")
  410. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  411. " BOOST_LIBRARYDIR = ${BOOST_LIBRARYDIR}")
  412. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  413. "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
  414. endif()
  415. IF( BOOST_ROOT )
  416. SET(_boost_INCLUDE_SEARCH_DIRS
  417. ${BOOST_ROOT}/include
  418. ${BOOST_ROOT}
  419. ${_boost_INCLUDE_SEARCH_DIRS})
  420. ENDIF( BOOST_ROOT )
  421. IF( BOOST_INCLUDEDIR )
  422. file(TO_CMAKE_PATH ${BOOST_INCLUDEDIR} BOOST_INCLUDEDIR)
  423. SET(_boost_INCLUDE_SEARCH_DIRS
  424. ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS})
  425. ENDIF( BOOST_INCLUDEDIR )
  426. # ------------------------------------------------------------------------
  427. # Search for Boost include DIR
  428. # ------------------------------------------------------------------------
  429. # Try to find Boost by stepping backwards through the Boost versions
  430. # we know about.
  431. IF( NOT Boost_INCLUDE_DIR )
  432. # Build a list of path suffixes for each version.
  433. SET(_boost_PATH_SUFFIXES)
  434. FOREACH(_boost_VER ${_boost_TEST_VERSIONS})
  435. # Add in a path suffix, based on the required version, ideally
  436. # we could read this from version.hpp, but for that to work we'd
  437. # need to know the include dir already
  438. set(_boost_BOOSTIFIED_VERSION)
  439. # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0
  440. IF(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
  441. STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3"
  442. _boost_BOOSTIFIED_VERSION ${_boost_VER})
  443. ELSEIF(_boost_VER MATCHES "[0-9]+\\.[0-9]+")
  444. STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2"
  445. _boost_BOOSTIFIED_VERSION ${_boost_VER})
  446. ENDIF()
  447. list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_BOOSTIFIED_VERSION}")
  448. if(WIN32)
  449. # For BoostPro's underscores (and others?)
  450. list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_BOOSTIFIED_VERSION}")
  451. endif()
  452. ENDFOREACH(_boost_VER)
  453. if(Boost_DEBUG)
  454. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  455. "Include debugging info:")
  456. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  457. " _boost_INCLUDE_SEARCH_DIRS = ${_boost_INCLUDE_SEARCH_DIRS}")
  458. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  459. " _boost_PATH_SUFFIXES = ${_boost_PATH_SUFFIXES}")
  460. endif()
  461. # Look for a standard boost header file.
  462. FIND_PATH(Boost_INCLUDE_DIR
  463. NAMES boost/config.hpp
  464. HINTS ${_boost_INCLUDE_SEARCH_DIRS}
  465. PATH_SUFFIXES ${_boost_PATH_SUFFIXES}
  466. )
  467. ENDIF( NOT Boost_INCLUDE_DIR )
  468. # ------------------------------------------------------------------------
  469. # Extract version information from version.hpp
  470. # ------------------------------------------------------------------------
  471. IF(Boost_INCLUDE_DIR)
  472. # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp
  473. # Read the whole file:
  474. #
  475. SET(BOOST_VERSION 0)
  476. SET(BOOST_LIB_VERSION "")
  477. FILE(READ "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS)
  478. if(Boost_DEBUG)
  479. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  480. "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp")
  481. endif()
  482. STRING(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}")
  483. STRING(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}")
  484. SET(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE INTERNAL "The library version string for boost libraries")
  485. SET(Boost_VERSION ${Boost_VERSION} CACHE INTERNAL "The version number for boost libraries")
  486. IF(NOT "${Boost_VERSION}" STREQUAL "0")
  487. MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
  488. MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
  489. MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
  490. set(Boost_ERROR_REASON
  491. "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}")
  492. ENDIF(NOT "${Boost_VERSION}" STREQUAL "0")
  493. if(Boost_DEBUG)
  494. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  495. "version.hpp reveals boost "
  496. "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
  497. endif()
  498. ELSE(Boost_INCLUDE_DIR)
  499. set(Boost_ERROR_REASON
  500. "${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.")
  501. ENDIF(Boost_INCLUDE_DIR)
  502. # ------------------------------------------------------------------------
  503. # Suffix initialization and compiler suffix detection.
  504. # ------------------------------------------------------------------------
  505. # Setting some more suffixes for the library
  506. SET (Boost_LIB_PREFIX "")
  507. if ( WIN32 AND Boost_USE_STATIC_LIBS )
  508. SET (Boost_LIB_PREFIX "lib")
  509. endif()
  510. if (Boost_COMPILER)
  511. set(_boost_COMPILER ${Boost_COMPILER})
  512. if(Boost_DEBUG)
  513. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  514. "using user-specified Boost_COMPILER = ${_boost_COMPILER}")
  515. endif()
  516. else(Boost_COMPILER)
  517. # Attempt to guess the compiler suffix
  518. # NOTE: this is not perfect yet, if you experience any issues
  519. # please report them and use the Boost_COMPILER variable
  520. # to work around the problems.
  521. if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel"
  522. OR "${CMAKE_CXX_COMPILER}" MATCHES "icl"
  523. OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
  524. if(WIN32)
  525. set (_boost_COMPILER "-iw")
  526. else()
  527. set (_boost_COMPILER "-il")
  528. endif()
  529. elseif (MSVC90)
  530. SET (_boost_COMPILER "-vc90")
  531. elseif (MSVC10)
  532. SET (_boost_COMPILER "-vc100")
  533. elseif (MSVC80)
  534. SET (_boost_COMPILER "-vc80")
  535. elseif (MSVC71)
  536. SET (_boost_COMPILER "-vc71")
  537. elseif (MSVC70) # Good luck!
  538. SET (_boost_COMPILER "-vc7") # yes, this is correct
  539. elseif (MSVC60) # Good luck!
  540. SET (_boost_COMPILER "-vc6") # yes, this is correct
  541. elseif (BORLAND)
  542. SET (_boost_COMPILER "-bcb")
  543. elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "SunPro")
  544. set(_boost_COMPILER "-sw")
  545. elseif (MINGW)
  546. if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
  547. SET(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34
  548. else()
  549. _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
  550. SET (_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}")
  551. endif()
  552. elseif (UNIX)
  553. if (CMAKE_COMPILER_IS_GNUCXX)
  554. if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
  555. SET(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34
  556. else()
  557. _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
  558. # Determine which version of GCC we have.
  559. IF(APPLE)
  560. IF(Boost_MINOR_VERSION)
  561. IF(${Boost_MINOR_VERSION} GREATER 35)
  562. # In Boost 1.36.0 and newer, the mangled compiler name used
  563. # on Mac OS X/Darwin is "xgcc".
  564. SET(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}")
  565. ELSE(${Boost_MINOR_VERSION} GREATER 35)
  566. # In Boost <= 1.35.0, there is no mangled compiler name for
  567. # the Mac OS X/Darwin version of GCC.
  568. SET(_boost_COMPILER "")
  569. ENDIF(${Boost_MINOR_VERSION} GREATER 35)
  570. ELSE(Boost_MINOR_VERSION)
  571. # We don't know the Boost version, so assume it's
  572. # pre-1.36.0.
  573. SET(_boost_COMPILER "")
  574. ENDIF(Boost_MINOR_VERSION)
  575. ELSE()
  576. SET (_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}")
  577. ENDIF()
  578. endif()
  579. endif (CMAKE_COMPILER_IS_GNUCXX)
  580. endif()
  581. if(Boost_DEBUG)
  582. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  583. "guessed _boost_COMPILER = ${_boost_COMPILER}")
  584. endif()
  585. endif(Boost_COMPILER)
  586. SET (_boost_MULTITHREADED "-mt")
  587. if( NOT Boost_USE_MULTITHREADED )
  588. set (_boost_MULTITHREADED "")
  589. endif()
  590. if(Boost_DEBUG)
  591. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  592. "_boost_MULTITHREADED = ${_boost_MULTITHREADED}")
  593. endif()
  594. SET( _boost_STATIC_TAG "")
  595. set( _boost_ABI_TAG "")
  596. IF (WIN32)
  597. IF(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl"
  598. OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
  599. SET (_boost_ABI_TAG "g")
  600. ENDIF()
  601. IF( Boost_USE_STATIC_LIBS )
  602. SET( _boost_STATIC_TAG "-s")
  603. ENDIF( Boost_USE_STATIC_LIBS )
  604. ENDIF(WIN32)
  605. SET (_boost_ABI_TAG "${_boost_ABI_TAG}d")
  606. if(Boost_DEBUG)
  607. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  608. "_boost_STATIC_TAG = ${_boost_STATIC_TAG}")
  609. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  610. "_boost_ABI_TAG = ${_boost_ABI_TAG}")
  611. endif()
  612. # ------------------------------------------------------------------------
  613. # Begin finding boost libraries
  614. # ------------------------------------------------------------------------
  615. SET(_boost_LIBRARIES_SEARCH_DIRS
  616. ${Boost_INCLUDE_DIR}/lib
  617. ${Boost_INCLUDE_DIR}/../lib
  618. C:/boost/lib
  619. C:/boost
  620. "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}_${Boost_SUBMINOR_VERSION}/lib"
  621. "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}/lib"
  622. "$ENV{ProgramFiles}/boost/lib"
  623. "$ENV{ProgramFiles}/boost"
  624. /sw/local/lib
  625. )
  626. IF( BOOST_ROOT )
  627. SET(_boost_LIBRARIES_SEARCH_DIRS
  628. ${BOOST_ROOT}/lib
  629. ${BOOST_ROOT}/stage/lib
  630. ${_boost_LIBRARIES_SEARCH_DIRS})
  631. ENDIF( BOOST_ROOT )
  632. IF( BOOST_LIBRARYDIR )
  633. file(TO_CMAKE_PATH ${BOOST_LIBRARYDIR} BOOST_LIBRARYDIR)
  634. SET(_boost_LIBRARIES_SEARCH_DIRS
  635. ${BOOST_LIBRARYDIR} ${_boost_LIBRARIES_SEARCH_DIRS})
  636. ENDIF( BOOST_LIBRARYDIR )
  637. if(Boost_DEBUG)
  638. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  639. "_boost_LIBRARIES_SEARCH_DIRS = ${_boost_LIBRARIES_SEARCH_DIRS}")
  640. endif()
  641. FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
  642. STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  643. SET( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" )
  644. SET( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" )
  645. SET( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND")
  646. # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
  647. IF( Boost_USE_STATIC_LIBS )
  648. SET( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
  649. IF(WIN32)
  650. SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
  651. ELSE(WIN32)
  652. SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
  653. ENDIF(WIN32)
  654. ENDIF( Boost_USE_STATIC_LIBS )
  655. FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE
  656. NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${Boost_LIB_VERSION}
  657. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION}
  658. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${Boost_LIB_VERSION}
  659. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION}
  660. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}
  661. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}
  662. ${Boost_LIB_PREFIX}boost_${COMPONENT}
  663. HINTS ${_boost_LIBRARIES_SEARCH_DIRS}
  664. )
  665. FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG
  666. NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION}
  667. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION}
  668. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION}
  669. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION}
  670. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}
  671. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}
  672. ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_boost_ABI_TAG}
  673. HINTS ${_boost_LIBRARIES_SEARCH_DIRS}
  674. )
  675. _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT})
  676. IF( Boost_USE_STATIC_LIBS )
  677. SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
  678. ENDIF( Boost_USE_STATIC_LIBS )
  679. ENDFOREACH(COMPONENT)
  680. # ------------------------------------------------------------------------
  681. # End finding boost libraries
  682. # ------------------------------------------------------------------------
  683. SET(Boost_INCLUDE_DIRS
  684. ${Boost_INCLUDE_DIR}
  685. )
  686. SET(Boost_FOUND FALSE)
  687. IF(Boost_INCLUDE_DIR)
  688. SET( Boost_FOUND TRUE )
  689. # Check the version of Boost against the requested version.
  690. if (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
  691. 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")
  692. endif (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
  693. if(Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
  694. set( Boost_FOUND FALSE )
  695. set(_Boost_VERSION_AGE "old")
  696. elseif(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
  697. if(Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
  698. set( Boost_FOUND FALSE )
  699. set(_Boost_VERSION_AGE "old")
  700. elseif(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
  701. if( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
  702. set( Boost_FOUND FALSE )
  703. set(_Boost_VERSION_AGE "old")
  704. endif( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
  705. endif( Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
  706. endif( Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
  707. if (NOT Boost_FOUND)
  708. _Boost_MARK_COMPONENTS_FOUND(OFF)
  709. endif()
  710. if (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
  711. # If the user requested an exact version of Boost, check
  712. # that. We already know that the Boost version we have is >= the
  713. # requested version.
  714. set(_Boost_VERSION_AGE "new")
  715. # If the user didn't specify a patchlevel, it's 0.
  716. if (NOT Boost_FIND_VERSION_PATCH)
  717. set(Boost_FIND_VERSION_PATCH 0)
  718. endif (NOT Boost_FIND_VERSION_PATCH)
  719. # We'll set Boost_FOUND true again if we have an exact version match.
  720. set(Boost_FOUND FALSE)
  721. _Boost_MARK_COMPONENTS_FOUND(OFF)
  722. if(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
  723. if(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
  724. if(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
  725. set( Boost_FOUND TRUE )
  726. _Boost_MARK_COMPONENTS_FOUND(ON)
  727. endif(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
  728. endif( Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
  729. endif( Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
  730. endif (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
  731. if(NOT Boost_FOUND)
  732. # State that we found a version of Boost that is too new or too old.
  733. set(Boost_ERROR_REASON
  734. "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  735. if (Boost_FIND_VERSION_PATCH)
  736. set(Boost_ERROR_REASON
  737. "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}")
  738. endif (Boost_FIND_VERSION_PATCH)
  739. if (NOT Boost_FIND_VERSION_EXACT)
  740. set(Boost_ERROR_REASON "${Boost_ERROR_REASON} (or newer)")
  741. endif (NOT Boost_FIND_VERSION_EXACT)
  742. set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.")
  743. endif (NOT Boost_FOUND)
  744. # Always check for missing components
  745. set(_boost_CHECKED_COMPONENT FALSE)
  746. set(_Boost_MISSING_COMPONENTS "")
  747. foreach(COMPONENT ${Boost_FIND_COMPONENTS})
  748. string(TOUPPER ${COMPONENT} COMPONENT)
  749. set(_boost_CHECKED_COMPONENT TRUE)
  750. if(NOT Boost_${COMPONENT}_FOUND)
  751. string(TOLOWER ${COMPONENT} COMPONENT)
  752. list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT})
  753. set( Boost_FOUND FALSE)
  754. endif(NOT Boost_${COMPONENT}_FOUND)
  755. endforeach(COMPONENT)
  756. if(Boost_DEBUG)
  757. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] Boost_FOUND = ${Boost_FOUND}")
  758. endif()
  759. if (_Boost_MISSING_COMPONENTS)
  760. # We were unable to find some libraries, so generate a sensible
  761. # error message that lists the libraries we were unable to find.
  762. set(Boost_ERROR_REASON
  763. "${Boost_ERROR_REASON}\nThe following Boost libraries could not be found:\n")
  764. foreach(COMPONENT ${_Boost_MISSING_COMPONENTS})
  765. set(Boost_ERROR_REASON
  766. "${Boost_ERROR_REASON} boost_${COMPONENT}\n")
  767. endforeach(COMPONENT)
  768. list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED)
  769. list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS)
  770. if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
  771. set(Boost_ERROR_REASON
  772. "${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.")
  773. else (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
  774. set(Boost_ERROR_REASON
  775. "${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.")
  776. endif (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
  777. endif (_Boost_MISSING_COMPONENTS)
  778. IF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
  779. # Compatibility Code for backwards compatibility with CMake
  780. # 2.4's FindBoost module.
  781. # Look for the boost library path.
  782. # Note that the user may not have installed any libraries
  783. # so it is quite possible the Boost_LIBRARY_PATH may not exist.
  784. SET(_boost_LIB_DIR ${Boost_INCLUDE_DIR})
  785. IF("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
  786. GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
  787. ENDIF ("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
  788. IF("${_boost_LIB_DIR}" MATCHES "/include$")
  789. # Strip off the trailing "/include" in the path.
  790. GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
  791. ENDIF("${_boost_LIB_DIR}" MATCHES "/include$")
  792. IF(EXISTS "${_boost_LIB_DIR}/lib")
  793. SET (_boost_LIB_DIR ${_boost_LIB_DIR}/lib)
  794. ELSE(EXISTS "${_boost_LIB_DIR}/lib")
  795. IF(EXISTS "${_boost_LIB_DIR}/stage/lib")
  796. SET(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib)
  797. ELSE(EXISTS "${_boost_LIB_DIR}/stage/lib")
  798. SET(_boost_LIB_DIR "")
  799. ENDIF(EXISTS "${_boost_LIB_DIR}/stage/lib")
  800. ENDIF(EXISTS "${_boost_LIB_DIR}/lib")
  801. IF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
  802. SET(Boost_LIBRARY_DIRS ${_boost_LIB_DIR} CACHE FILEPATH "Boost library directory")
  803. ENDIF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
  804. ENDIF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
  805. ELSE(Boost_INCLUDE_DIR)
  806. SET( Boost_FOUND FALSE)
  807. ENDIF(Boost_INCLUDE_DIR)
  808. IF (Boost_FOUND)
  809. IF (NOT Boost_FIND_QUIETLY)
  810. MESSAGE(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
  811. if(Boost_FIND_COMPONENTS)
  812. message(STATUS "Found the following Boost libraries:")
  813. endif()
  814. ENDIF(NOT Boost_FIND_QUIETLY)
  815. FOREACH ( COMPONENT ${Boost_FIND_COMPONENTS} )
  816. STRING( TOUPPER ${COMPONENT} UPPERCOMPONENT )
  817. IF ( Boost_${UPPERCOMPONENT}_FOUND )
  818. IF (NOT Boost_FIND_QUIETLY)
  819. MESSAGE (STATUS " ${COMPONENT}")
  820. ENDIF(NOT Boost_FIND_QUIETLY)
  821. SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${UPPERCOMPONENT}_LIBRARY})
  822. ENDIF ( Boost_${UPPERCOMPONENT}_FOUND )
  823. ENDFOREACH(COMPONENT)
  824. else()
  825. if(Boost_FIND_REQUIRED)
  826. message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")
  827. else()
  828. if(NOT Boost_FIND_QUIETLY)
  829. # we opt not to automatically output Boost_ERROR_REASON here as
  830. # it could be quite lengthy and somewhat imposing in it's requests
  831. # Since Boost is not always a required dependency we'll leave this
  832. # up to the end-user.
  833. if(Boost_DEBUG OR Boost_DETAILED_FAILURE_MSG)
  834. message(STATUS "Could NOT find Boost\n${Boost_ERROR_REASON}")
  835. else()
  836. message(STATUS "Could NOT find Boost")
  837. endif()
  838. endif()
  839. endif(Boost_FIND_REQUIRED)
  840. endif()
  841. # show the Boost_INCLUDE_DIRS AND Boost_LIBRARIES variables only in the advanced view
  842. MARK_AS_ADVANCED(Boost_INCLUDE_DIR
  843. Boost_INCLUDE_DIRS
  844. Boost_LIBRARY_DIRS
  845. )
  846. ENDIF(_boost_IN_CACHE)