FindBoost.cmake 41 KB

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