FindBoost.cmake 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. # - Try to find Boost include dirs and libraries
  2. # Usage of this module as follows:
  3. #
  4. # SET(Boost_USE_STATIC_LIBS ON)
  5. # SET(Boost_USE_MULTITHREAD OFF)
  6. # FIND_PACKAGE( Boost 1.34.1 COMPONENTS date_time filesystem iostreams ... )
  7. #
  8. # The Boost_ADDITIONAL_VERSIONS variable can be used to specify a list of
  9. # boost version numbers that should be taken into account when searching
  10. # for the libraries. Unfortunately boost puts the version number into the
  11. # actual filename for the libraries, so this might be needed in the future
  12. # when new Boost versions are released.
  13. #
  14. # Currently this module searches for the following version numbers:
  15. # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1, 1.36,
  16. # 1.36.0, 1.36.1
  17. #
  18. # The components list needs to be the actual names of boost libraries, that is
  19. # the part of the actual library files that differ on different libraries. So
  20. # its "date_time" for "libboost_date_time...". Anything else will result in
  21. # errors
  22. #
  23. # You can provide a minimum version number that should be used. If you provide this
  24. # version number and specify the REQUIRED attribute, this module will fail if it
  25. # can't find the specified or a later version. If you specify a version number this is
  26. # automatically put into the considered list of version numbers and thus doesn't need
  27. # to be specified in the Boost_ADDITIONAL_VERSIONS variable
  28. #
  29. # Variables used by this module, they can change the default behaviour and need to be set
  30. # before calling find_package:
  31. # Boost_USE_MULTITHREAD Can be set to OFF to use the non-multithreaded
  32. # boost libraries. Defaults to ON.
  33. # Boost_USE_STATIC_LIBS Can be set to ON to force the use of the static
  34. # boost libraries. Defaults to OFF.
  35. # Boost_ADDITIONAL_VERSIONS A list of version numbers to use for searching
  36. # the boost include directory. The default list
  37. # of version numbers is:
  38. # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1,
  39. # 1.35, 1.35.0, 1.35.1, 1.36, 1.36.0, 1.36.1
  40. # If you want to look for an older or newer
  41. # version set this variable to a list of
  42. # strings, where each string contains a number, i.e.
  43. # SET(Boost_ADDITIONAL_VERSIONS "0.99.0" "1.35.0")
  44. # BOOST_ROOT or BOOSTROOT Preferred installation prefix for searching for Boost,
  45. # set this if the module has problems finding the proper Boost installation
  46. # BOOST_INCLUDEDIR Set this to the include directory of Boost, if the
  47. # module has problems finding the proper Boost installation
  48. # BOOST_LIBRARYDIR Set this to the lib directory of Boost, if the
  49. # module has problems finding the proper Boost installation
  50. #
  51. # The last three variables are available also as environment variables
  52. #
  53. #
  54. # Variables defined by this module:
  55. #
  56. # Boost_FOUND System has Boost, this means the include dir was found,
  57. # as well as all the libraries specified in the COMPONENTS list
  58. # Boost_INCLUDE_DIRS Boost include directories, not cached
  59. # Boost_INCLUDE_DIR This is almost the same as above, but this one is cached and may be
  60. # modified by advanced users
  61. # Boost_LIBRARIES Link these to use the Boost libraries that you specified, not cached
  62. # Boost_LIBRARY_DIRS The path to where the Boost library files are.
  63. # Boost_VERSION The version number of the boost libraries that have been found,
  64. # same as in version.hpp from Boost
  65. # Boost_LIB_VERSION The version number in filename form as its appended to the library filenames
  66. # Boost_MAJOR_VERSION major version number of boost
  67. # Boost_MINOR_VERSION minor version number of boost
  68. # Boost_SUBMINOR_VERSION subminor version number of boost
  69. # Boost_LIB_DIAGNOSTIC_DEFINITIONS Only set on windows. Can be used with add_definitions
  70. # to print diagnostic information about the automatic
  71. # linking done on windows.
  72. # For each component you list the following variables are set.
  73. # ATTENTION: The component names need to be in lower case, just as the boost
  74. # library names however the cmake variables use upper case for the component
  75. # part. So you'd get Boost_SERIALIZATION_FOUND for example.
  76. #
  77. # Boost_${COMPONENT}_FOUND True IF the Boost library "component" was found.
  78. # Boost_${COMPONENT}_LIBRARY The absolute path of the Boost library "component".
  79. # Boost_${COMPONENT}_LIBRARY_DEBUG The absolute path of the debug version of the
  80. # Boost library "component".
  81. # Boost_${COMPONENT}_LIBRARY_RELEASE The absolute path of the release version of the
  82. # Boost library "component"
  83. #
  84. # Copyright (c) 2006-2008 Andreas Schneider <[email protected]>
  85. # Copyright (c) 2007 Wengo
  86. # Copyright (c) 2007 Mike Jackson
  87. # Copyright (c) 2008 Andreas Pakulat <[email protected]>
  88. #
  89. # Redistribution AND use is allowed according to the terms of the New
  90. # BSD license.
  91. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  92. #
  93. OPTION(Boost_USE_MULTITHREADED
  94. "Use the multithreaded versions of the Boost libraries" ON)
  95. if(Boost_FIND_VERSION_EXACT)
  96. # The version may appear in a directory with or without the patch
  97. # level, even when the patch level is non-zero.
  98. set(_boost_TEST_VERSIONS
  99. "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.${Boost_FIND_VERSION_PATCH}"
  100. "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  101. else(Boost_FIND_VERSION_EXACT)
  102. # The user has not requested an exact version. Among known
  103. # versions, find those that are acceptable to the user request.
  104. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
  105. "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0"
  106. "1.34" "1.33.1" "1.33.0" "1.33")
  107. set(_boost_TEST_VERSIONS)
  108. if(Boost_FIND_VERSION)
  109. set(_Boost_FIND_VERSION_SHORT "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  110. # Select acceptable versions.
  111. foreach(version ${_Boost_KNOWN_VERSIONS})
  112. if(NOT "${version}" VERSION_LESS "${Boost_FIND_VERSION}")
  113. # This version is high enough.
  114. list(APPEND _boost_TEST_VERSIONS "${version}")
  115. elseif("${version}.99" VERSION_EQUAL "${_Boost_FIND_VERSION_SHORT}.99")
  116. # This version is a short-form for the requested version with
  117. # the patch level dropped.
  118. list(APPEND _boost_TEST_VERSIONS "${version}")
  119. endif()
  120. endforeach(version)
  121. else(Boost_FIND_VERSION)
  122. # Any version is acceptable.
  123. set(_boost_TEST_VERSIONS "${_Boost_KNOWN_VERSIONS}")
  124. endif(Boost_FIND_VERSION)
  125. endif(Boost_FIND_VERSION_EXACT)
  126. # The reason that we failed to find Boost. This will be set to a
  127. # user-friendly message when we fail to find some necessary piece of
  128. # Boost.
  129. set(Boost_ERROR_REASON)
  130. ############################################
  131. #
  132. # Check the existence of the libraries.
  133. #
  134. ############################################
  135. # This macro was taken directly from the FindQt4.cmake file that is included
  136. # with the CMake distribution. This is NOT my work. All work was done by the
  137. # original authors of the FindQt4.cmake file. Only minor modifications were
  138. # made to remove references to Qt and make this file more generally applicable
  139. #########################################################################
  140. MACRO (_Boost_ADJUST_LIB_VARS basename)
  141. IF (Boost_INCLUDE_DIR )
  142. IF (Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
  143. # if the generator supports configuration types then set
  144. # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
  145. IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
  146. SET(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
  147. ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
  148. # if there are no configuration types and CMAKE_BUILD_TYPE has no value
  149. # then just use the release libraries
  150. SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
  151. ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
  152. SET(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
  153. ENDIF (Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
  154. # if only the release version was found, set the debug variable also to the release version
  155. IF (Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG)
  156. SET(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE})
  157. SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE})
  158. SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE})
  159. ENDIF (Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG)
  160. # if only the debug version was found, set the release variable also to the debug version
  161. IF (Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE)
  162. SET(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG})
  163. SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG})
  164. SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG})
  165. ENDIF (Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE)
  166. IF (Boost_${basename}_LIBRARY)
  167. SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library")
  168. GET_FILENAME_COMPONENT(Boost_LIBRARY_DIRS "${Boost_${basename}_LIBRARY}" PATH)
  169. SET(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS} CACHE FILEPATH "Boost library directory")
  170. SET(Boost_${basename}_FOUND ON CACHE INTERNAL "Whether the Boost ${basename} library found")
  171. ENDIF (Boost_${basename}_LIBRARY)
  172. ENDIF (Boost_INCLUDE_DIR )
  173. # Make variables changeble to the advanced user
  174. MARK_AS_ADVANCED(
  175. Boost_${basename}_LIBRARY
  176. Boost_${basename}_LIBRARY_RELEASE
  177. Boost_${basename}_LIBRARY_DEBUG
  178. )
  179. ENDMACRO (_Boost_ADJUST_LIB_VARS)
  180. #-------------------------------------------------------------------------------
  181. SET( _boost_IN_CACHE TRUE)
  182. IF(Boost_INCLUDE_DIR)
  183. FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
  184. STRING(TOUPPER ${COMPONENT} COMPONENT)
  185. IF(NOT Boost_${COMPONENT}_FOUND)
  186. SET( _boost_IN_CACHE FALSE)
  187. ENDIF(NOT Boost_${COMPONENT}_FOUND)
  188. ENDFOREACH(COMPONENT)
  189. ELSE(Boost_INCLUDE_DIR)
  190. SET( _boost_IN_CACHE FALSE)
  191. ENDIF(Boost_INCLUDE_DIR)
  192. IF (_boost_IN_CACHE)
  193. # in cache already
  194. SET(Boost_FOUND TRUE)
  195. FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
  196. STRING(TOUPPER ${COMPONENT} COMPONENT)
  197. _Boost_ADJUST_LIB_VARS( ${COMPONENT} )
  198. SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${COMPONENT}_LIBRARY})
  199. ENDFOREACH(COMPONENT)
  200. SET(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
  201. IF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
  202. MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
  203. MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
  204. MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
  205. ENDIF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
  206. ELSE (_boost_IN_CACHE)
  207. # Need to search for boost
  208. IF(WIN32)
  209. # In windows, automatic linking is performed, so you do not have
  210. # to specify the libraries. If you are linking to a dynamic
  211. # runtime, then you can choose to link to either a static or a
  212. # dynamic Boost library, the default is to do a static link. You
  213. # can alter this for a specific library "whatever" by defining
  214. # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be
  215. # linked dynamically. Alternatively you can force all Boost
  216. # libraries to dynamic link by defining BOOST_ALL_DYN_LINK.
  217. # This feature can be disabled for Boost library "whatever" by
  218. # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining
  219. # BOOST_ALL_NO_LIB.
  220. # If you want to observe which libraries are being linked against
  221. # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking
  222. # code to emit a #pragma message each time a library is selected
  223. # for linking.
  224. SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS
  225. "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define")
  226. ENDIF(WIN32)
  227. SET(_boost_INCLUDE_SEARCH_DIRS
  228. C:/boost/include
  229. "C:/boost"
  230. "$ENV{ProgramFiles}/boost/boost_${Boost_FIND_VERSION_MAJOR}_${Boost_FIND_VERSION_MINOR}_${Boost_FIND_VERSION_PATCH}"
  231. "$ENV{ProgramFiles}/Boost"
  232. /sw/local/include
  233. )
  234. SET(_boost_LIBRARIES_SEARCH_DIRS
  235. C:/boost/lib
  236. "C:/boost"
  237. "$ENV{ProgramFiles}/boost/boost_${Boost_FIND_VERSION_MAJOR}_${Boost_FIND_VERSION_MINOR}_${Boost_FIND_VERSION_PATCH}/lib"
  238. "$ENV{ProgramFiles}/Boost"
  239. /sw/local/lib
  240. )
  241. # If BOOST_ROOT was defined in the environment, use it.
  242. if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
  243. set(BOOST_ROOT $ENV{BOOST_ROOT})
  244. endif(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
  245. # If BOOSTROOT was defined in the environment, use it.
  246. if (NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
  247. set(BOOST_ROOT $ENV{BOOSTROOT})
  248. endif(NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
  249. # If BOOST_INCLUDEDIR was defined in the environment, use it.
  250. IF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
  251. set(BOOST_INCLUDEDIR $ENV{BOOST_INCLUDEDIR})
  252. ENDIF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
  253. # If BOOST_LIBRARYDIR was defined in the environment, use it.
  254. IF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
  255. set(BOOST_LIBRARYDIR $ENV{BOOST_LIBRARYDIR})
  256. ENDIF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
  257. IF( BOOST_ROOT )
  258. file(TO_CMAKE_PATH ${BOOST_ROOT} BOOST_ROOT)
  259. SET(_boost_INCLUDE_SEARCH_DIRS
  260. ${BOOST_ROOT}/include
  261. ${BOOST_ROOT}
  262. ${_boost_INCLUDE_SEARCH_DIRS})
  263. SET(_boost_LIBRARIES_SEARCH_DIRS
  264. ${BOOST_ROOT}/lib
  265. ${BOOST_ROOT}/stage/lib
  266. ${_boost_LIBRARIES_SEARCH_DIRS})
  267. ENDIF( BOOST_ROOT )
  268. IF( BOOST_INCLUDEDIR )
  269. file(TO_CMAKE_PATH ${BOOST_INCLUDEDIR} BOOST_INCLUDEDIR)
  270. SET(_boost_INCLUDE_SEARCH_DIRS
  271. ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS})
  272. ENDIF( BOOST_INCLUDEDIR )
  273. IF( BOOST_LIBRARYDIR )
  274. file(TO_CMAKE_PATH ${BOOST_LIBRARYDIR} BOOST_LIBRARYDIR)
  275. SET(_boost_LIBRARIES_SEARCH_DIRS
  276. ${BOOST_LIBRARYDIR} ${_boost_LIBRARIES_SEARCH_DIRS})
  277. ENDIF( BOOST_LIBRARYDIR )
  278. # Try to find Boost by stepping backwards through the Boost versions
  279. # we know about.
  280. IF( NOT Boost_INCLUDE_DIR )
  281. # Build a list of path suffixes for each version.
  282. SET(_boost_PATH_SUFFIXES)
  283. FOREACH(_boost_VER ${_boost_TEST_VERSIONS})
  284. # Add in a path suffix, based on the required version, ideally
  285. # we could read this from version.hpp, but for that to work we'd
  286. # need to know the include dir already
  287. if (WIN32 AND NOT CYGWIN)
  288. set(_boost_PATH_SUFFIX boost_${_boost_VER})
  289. else (WIN32 AND NOT CYGWIN)
  290. set(_boost_PATH_SUFFIX boost-${_boost_VER})
  291. endif (WIN32 AND NOT CYGWIN)
  292. IF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
  293. STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3"
  294. _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX})
  295. ELSEIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+")
  296. STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2"
  297. _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX})
  298. ENDIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
  299. LIST(APPEND _boost_PATH_SUFFIXES "${_boost_PATH_SUFFIX}")
  300. ENDFOREACH(_boost_VER)
  301. # Look for a standard boost header file.
  302. FIND_PATH(Boost_INCLUDE_DIR
  303. NAMES boost/config.hpp
  304. HINTS ${_boost_INCLUDE_SEARCH_DIRS}
  305. PATH_SUFFIXES ${_boost_PATH_SUFFIXES}
  306. )
  307. ENDIF( NOT Boost_INCLUDE_DIR )
  308. IF(Boost_INCLUDE_DIR)
  309. # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp
  310. # Read the whole file:
  311. #
  312. SET(BOOST_VERSION 0)
  313. SET(BOOST_LIB_VERSION "")
  314. FILE(READ "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS)
  315. STRING(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}")
  316. STRING(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}")
  317. SET(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE INTERNAL "The library version string for boost libraries")
  318. SET(Boost_VERSION ${Boost_VERSION} CACHE INTERNAL "The version number for boost libraries")
  319. IF(NOT "${Boost_VERSION}" STREQUAL "0")
  320. MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
  321. MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
  322. MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
  323. set(Boost_ERROR_REASON
  324. "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}")
  325. ENDIF(NOT "${Boost_VERSION}" STREQUAL "0")
  326. ELSE(Boost_INCLUDE_DIR)
  327. set(Boost_ERROR_REASON
  328. "${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.")
  329. ENDIF(Boost_INCLUDE_DIR)
  330. # Setting some more suffixes for the library
  331. SET (Boost_LIB_PREFIX "")
  332. IF ( WIN32 AND Boost_USE_STATIC_LIBS )
  333. SET (Boost_LIB_PREFIX "lib")
  334. ENDIF ( WIN32 AND Boost_USE_STATIC_LIBS )
  335. SET (_boost_COMPILER "-gcc")
  336. IF (MSVC90)
  337. SET (_boost_COMPILER "-vc90")
  338. ELSEIF (MSVC80)
  339. SET (_boost_COMPILER "-vc80")
  340. ELSEIF (MSVC71)
  341. SET (_boost_COMPILER "-vc71")
  342. ENDIF(MSVC90)
  343. IF (MINGW)
  344. EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
  345. ARGS -dumpversion
  346. OUTPUT_VARIABLE _boost_COMPILER_VERSION
  347. )
  348. STRING(REGEX REPLACE "([0-9])\\.([0-9])\\.[0-9]" "\\1\\2"
  349. _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
  350. SET (_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}")
  351. ENDIF(MINGW)
  352. IF (UNIX)
  353. IF (NOT CMAKE_COMPILER_IS_GNUCC)
  354. # We assume that we have the Intel compiler.
  355. SET (_boost_COMPILER "-il")
  356. ELSE (NOT CMAKE_COMPILER_IS_GNUCC)
  357. # Determine which version of GCC we have.
  358. EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
  359. ARGS -dumpversion
  360. OUTPUT_VARIABLE _boost_COMPILER_VERSION
  361. )
  362. STRING(REGEX REPLACE "([0-9])\\.([0-9])\\.[0-9]" "\\1\\2"
  363. _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
  364. IF(APPLE)
  365. IF(Boost_MINOR_VERSION)
  366. IF(${Boost_MINOR_VERSION} GREATER 35)
  367. # In Boost 1.36.0 and newer, the mangled compiler name used
  368. # on Mac OS X/Darwin is "xgcc".
  369. SET(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}")
  370. ELSE(${Boost_MINOR_VERSION} GREATER 35)
  371. # In Boost <= 1.35.0, there is no mangled compiler name for
  372. # the Mac OS X/Darwin version of GCC.
  373. SET(_boost_COMPILER "")
  374. ENDIF(${Boost_MINOR_VERSION} GREATER 35)
  375. ELSE(Boost_MINOR_VERSION)
  376. # We don't know the Boost version, so assume it's
  377. # pre-1.36.0.
  378. SET(_boost_COMPILER "")
  379. ENDIF(Boost_MINOR_VERSION)
  380. ELSE()
  381. SET (_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}")
  382. ENDIF()
  383. ENDIF (NOT CMAKE_COMPILER_IS_GNUCC)
  384. ENDIF(UNIX)
  385. SET (_boost_MULTITHREADED "-mt")
  386. IF( NOT Boost_USE_MULTITHREADED )
  387. SET (_boost_MULTITHREADED "")
  388. ENDIF( NOT Boost_USE_MULTITHREADED )
  389. SET( _boost_STATIC_TAG "")
  390. IF (WIN32)
  391. IF(MSVC)
  392. SET (_boost_ABI_TAG "g")
  393. ENDIF(MSVC)
  394. IF( Boost_USE_STATIC_LIBS )
  395. SET( _boost_STATIC_TAG "-s")
  396. ENDIF( Boost_USE_STATIC_LIBS )
  397. ENDIF(WIN32)
  398. SET (_boost_ABI_TAG "${_boost_ABI_TAG}d")
  399. # ------------------------------------------------------------------------
  400. # Begin finding boost libraries
  401. # ------------------------------------------------------------------------
  402. FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
  403. STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  404. SET( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" )
  405. SET( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" )
  406. SET( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND")
  407. # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
  408. IF( Boost_USE_STATIC_LIBS )
  409. SET( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
  410. IF(WIN32)
  411. SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
  412. ELSE(WIN32)
  413. SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
  414. ENDIF(WIN32)
  415. ENDIF( Boost_USE_STATIC_LIBS )
  416. FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE
  417. NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${Boost_LIB_VERSION}
  418. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION}
  419. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}
  420. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}
  421. ${Boost_LIB_PREFIX}boost_${COMPONENT}
  422. HINTS ${_boost_LIBRARIES_SEARCH_DIRS}
  423. )
  424. FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG
  425. NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION}
  426. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION}
  427. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}
  428. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}
  429. ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_boost_ABI_TAG}
  430. HINTS ${_boost_LIBRARIES_SEARCH_DIRS}
  431. )
  432. _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT})
  433. IF( Boost_USE_STATIC_LIBS )
  434. SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
  435. ENDIF( Boost_USE_STATIC_LIBS )
  436. ENDFOREACH(COMPONENT)
  437. # ------------------------------------------------------------------------
  438. # End finding boost libraries
  439. # ------------------------------------------------------------------------
  440. SET(Boost_INCLUDE_DIRS
  441. ${Boost_INCLUDE_DIR}
  442. )
  443. SET(Boost_FOUND FALSE)
  444. IF(Boost_INCLUDE_DIR)
  445. SET( Boost_FOUND TRUE )
  446. # Check the version of Boost against the requested version.
  447. if (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
  448. 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")
  449. endif (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
  450. if(Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
  451. set( Boost_FOUND FALSE )
  452. set(_Boost_VERSION_AGE "old")
  453. elseif(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
  454. if(Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
  455. set( Boost_FOUND FALSE )
  456. set(_Boost_VERSION_AGE "old")
  457. elseif(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
  458. if( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
  459. set( Boost_FOUND FALSE )
  460. set(_Boost_VERSION_AGE "old")
  461. endif( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
  462. endif( Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
  463. endif( Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
  464. if (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
  465. # If the user requested an exact version of Boost, check
  466. # that. We already know that the Boost version we have is >= the
  467. # requested version.
  468. set(_Boost_VERSION_AGE "new")
  469. # If the user didn't specify a patchlevel, it's 0.
  470. if (NOT Boost_FIND_VERSION_PATCH)
  471. set(Boost_FIND_VERSION_PATCH 0)
  472. endif (NOT Boost_FIND_VERSION_PATCH)
  473. # We'll set Boost_FOUND true again if we have an exact version match.
  474. set(Boost_FOUND FALSE)
  475. if(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
  476. if(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
  477. if(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
  478. set( Boost_FOUND TRUE )
  479. endif(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
  480. endif( Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
  481. endif( Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
  482. endif (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
  483. if(NOT Boost_FOUND)
  484. # State that we found a version of Boost that is too new or too old.
  485. set(Boost_ERROR_REASON
  486. "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  487. if (Boost_FIND_VERSION_PATCH)
  488. set(Boost_ERROR_REASON
  489. "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}")
  490. endif (Boost_FIND_VERSION_PATCH)
  491. if (NOT Boost_FIND_VERSION_EXACT)
  492. set(Boost_ERROR_REASON "${Boost_ERROR_REASON} (or newer)")
  493. endif (NOT Boost_FIND_VERSION_EXACT)
  494. set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.")
  495. endif (NOT Boost_FOUND)
  496. if (Boost_FOUND)
  497. set(_boost_CHECKED_COMPONENT FALSE)
  498. set(_Boost_MISSING_COMPONENTS)
  499. foreach(COMPONENT ${Boost_FIND_COMPONENTS})
  500. string(TOUPPER ${COMPONENT} COMPONENT)
  501. set(_boost_CHECKED_COMPONENT TRUE)
  502. if(NOT Boost_${COMPONENT}_FOUND)
  503. string(TOLOWER ${COMPONENT} COMPONENT)
  504. list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT})
  505. set( Boost_FOUND FALSE)
  506. endif(NOT Boost_${COMPONENT}_FOUND)
  507. endforeach(COMPONENT)
  508. endif (Boost_FOUND)
  509. if (_Boost_MISSING_COMPONENTS)
  510. # We were unable to find some libraries, so generate a sensible
  511. # error message that lists the libraries we were unable to find.
  512. set(Boost_ERROR_REASON
  513. "${Boost_ERROR_REASON}\nThe following Boost libraries could not be found:\n")
  514. foreach(COMPONENT ${_Boost_MISSING_COMPONENTS})
  515. set(Boost_ERROR_REASON
  516. "${Boost_ERROR_REASON} boost_${COMPONENT}\n")
  517. endforeach(COMPONENT)
  518. list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED)
  519. list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS)
  520. if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
  521. set(Boost_ERROR_REASON
  522. "${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.")
  523. else (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
  524. set(Boost_ERROR_REASON
  525. "${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.")
  526. endif (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
  527. endif (_Boost_MISSING_COMPONENTS)
  528. IF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
  529. # Compatibility Code for backwards compatibility with CMake
  530. # 2.4's FindBoost module.
  531. # Look for the boost library path.
  532. # Note that the user may not have installed any libraries
  533. # so it is quite possible the Boost_LIBRARY_PATH may not exist.
  534. SET(_boost_LIB_DIR ${Boost_INCLUDE_DIR})
  535. IF("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
  536. GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
  537. ENDIF ("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
  538. IF("${_boost_LIB_DIR}" MATCHES "/include$")
  539. # Strip off the trailing "/include" in the path.
  540. GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
  541. ENDIF("${_boost_LIB_DIR}" MATCHES "/include$")
  542. IF(EXISTS "${_boost_LIB_DIR}/lib")
  543. SET (_boost_LIB_DIR ${_boost_LIB_DIR}/lib)
  544. ELSE(EXISTS "${_boost_LIB_DIR}/lib")
  545. IF(EXISTS "${_boost_LIB_DIR}/stage/lib")
  546. SET(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib)
  547. ELSE(EXISTS "${_boost_LIB_DIR}/stage/lib")
  548. SET(_boost_LIB_DIR "")
  549. ENDIF(EXISTS "${_boost_LIB_DIR}/stage/lib")
  550. ENDIF(EXISTS "${_boost_LIB_DIR}/lib")
  551. IF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
  552. SET(Boost_LIBRARY_DIRS ${_boost_LIB_DIR} CACHE FILEPATH "Boost library directory")
  553. ENDIF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
  554. ENDIF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
  555. ELSE(Boost_INCLUDE_DIR)
  556. SET( Boost_FOUND FALSE)
  557. ENDIF(Boost_INCLUDE_DIR)
  558. IF (Boost_FOUND)
  559. IF (NOT Boost_FIND_QUIETLY)
  560. MESSAGE(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
  561. ENDIF(NOT Boost_FIND_QUIETLY)
  562. IF (NOT Boost_FIND_QUIETLY)
  563. MESSAGE(STATUS "Found the following Boost libraries:")
  564. ENDIF(NOT Boost_FIND_QUIETLY)
  565. FOREACH ( COMPONENT ${Boost_FIND_COMPONENTS} )
  566. STRING( TOUPPER ${COMPONENT} UPPERCOMPONENT )
  567. IF ( Boost_${UPPERCOMPONENT}_FOUND )
  568. IF (NOT Boost_FIND_QUIETLY)
  569. MESSAGE (STATUS " ${COMPONENT}")
  570. ENDIF(NOT Boost_FIND_QUIETLY)
  571. SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${UPPERCOMPONENT}_LIBRARY})
  572. ENDIF ( Boost_${UPPERCOMPONENT}_FOUND )
  573. ENDFOREACH(COMPONENT)
  574. ELSE (Boost_FOUND)
  575. IF (Boost_FIND_REQUIRED)
  576. message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")
  577. ENDIF(Boost_FIND_REQUIRED)
  578. ENDIF(Boost_FOUND)
  579. # Under Windows, automatic linking is performed, so no need to specify the libraries.
  580. IF (WIN32)
  581. IF (NOT MINGW)
  582. SET(Boost_LIBRARIES "")
  583. ENDIF (NOT MINGW)
  584. ENDIF(WIN32)
  585. # show the Boost_INCLUDE_DIRS AND Boost_LIBRARIES variables only in the advanced view
  586. MARK_AS_ADVANCED(Boost_INCLUDE_DIR
  587. Boost_INCLUDE_DIRS
  588. Boost_LIBRARY_DIRS
  589. Boost_USE_MULTITHREADED
  590. )
  591. ENDIF(_boost_IN_CACHE)