FindBoost.cmake 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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.0,
  16. # 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.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 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. # this module required CMake 2.5 for the Boost_FIND_VERSION stuff
  94. # this must not be done in find modules, it changes the policy settings, which may have been
  95. # set in the projects cmake files.
  96. # beside that this module comes with cmake, so the cmake version is always correct, Alex
  97. # CMAKE_MINIMUM_REQUIRED(VERSION "2.6" FATAL_ERROR)
  98. # MESSAGE(STATUS "Finding Boost libraries.... ")
  99. OPTION(Boost_USE_MULTITHREADED "Use the multithreaded versions of the boost libraries" ON)
  100. SET( _boost_TEST_VERSIONS ${Boost_ADDITIONAL_VERSIONS} "1.36.1" "1.36.0" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0" "1.34" "1.33.1" "1.33.0" "1.33" )
  101. ############################################
  102. #
  103. # Check the existence of the libraries.
  104. #
  105. ############################################
  106. # This macro was taken directly from the FindQt4.cmake file that is included
  107. # with the CMake distribution. This is NOT my work. All work was done by the
  108. # original authors of the FindQt4.cmake file. Only minor modifications were
  109. # made to remove references to Qt and make this file more generally applicable
  110. #########################################################################
  111. MACRO (_Boost_ADJUST_LIB_VARS basename)
  112. IF (Boost_INCLUDE_DIR )
  113. #MESSAGE(STATUS "Adjusting ${basename} ")
  114. IF (Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
  115. # if the generator supports configuration types then set
  116. # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
  117. IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
  118. SET(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
  119. ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
  120. # if there are no configuration types and CMAKE_BUILD_TYPE has no value
  121. # then just use the release libraries
  122. SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
  123. ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
  124. SET(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
  125. ENDIF (Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
  126. # if only the release version was found, set the debug variable also to the release version
  127. IF (Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG)
  128. SET(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE})
  129. SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE})
  130. SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE})
  131. ENDIF (Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG)
  132. # if only the debug version was found, set the release variable also to the debug version
  133. IF (Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE)
  134. SET(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG})
  135. SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG})
  136. SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG})
  137. ENDIF (Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE)
  138. IF (Boost_${basename}_LIBRARY)
  139. SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library")
  140. GET_FILENAME_COMPONENT(Boost_LIBRARY_DIRS "${Boost_${basename}_LIBRARY}" PATH)
  141. SET(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS} CACHE FILEPATH "Boost library directory")
  142. SET(Boost_${basename}_FOUND ON CACHE INTERNAL "Was the boost boost ${basename} library found")
  143. ENDIF (Boost_${basename}_LIBRARY)
  144. ENDIF (Boost_INCLUDE_DIR )
  145. # Make variables changeble to the advanced user
  146. MARK_AS_ADVANCED(
  147. Boost_${basename}_LIBRARY
  148. Boost_${basename}_LIBRARY_RELEASE
  149. Boost_${basename}_LIBRARY_DEBUG
  150. )
  151. ENDMACRO (_Boost_ADJUST_LIB_VARS)
  152. #-------------------------------------------------------------------------------
  153. SET( _boost_IN_CACHE TRUE)
  154. IF(Boost_INCLUDE_DIR)
  155. FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
  156. STRING(TOUPPER ${COMPONENT} COMPONENT)
  157. IF(NOT Boost_${COMPONENT}_FOUND)
  158. SET( _boost_IN_CACHE FALSE)
  159. ENDIF(NOT Boost_${COMPONENT}_FOUND)
  160. ENDFOREACH(COMPONENT)
  161. ELSE(Boost_INCLUDE_DIR)
  162. SET( _boost_IN_CACHE FALSE)
  163. ENDIF(Boost_INCLUDE_DIR)
  164. IF (_boost_IN_CACHE)
  165. # in cache already
  166. SET(Boost_FOUND TRUE)
  167. FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
  168. STRING(TOUPPER ${COMPONENT} COMPONENT)
  169. _Boost_ADJUST_LIB_VARS( ${COMPONENT} )
  170. SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${COMPONENT}_LIBRARY})
  171. ENDFOREACH(COMPONENT)
  172. SET(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
  173. IF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
  174. MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
  175. MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
  176. MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
  177. ENDIF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
  178. ELSE (_boost_IN_CACHE)
  179. # Need to search for boost
  180. IF(WIN32)
  181. # In windows, automatic linking is performed, so you do not have to specify the libraries.
  182. # If you are linking to a dynamic runtime, then you can choose to link to either a static or a
  183. # dynamic Boost library, the default is to do a static link. You can alter this for a specific
  184. # library "whatever" by defining BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to
  185. # be linked dynamically. Alternatively you can force all Boost libraries to dynamic link by
  186. # defining BOOST_ALL_DYN_LINK.
  187. # This feature can be disabled for Boost library "whatever" by defining BOOST_WHATEVER_NO_LIB,
  188. # or for all of Boost by defining BOOST_ALL_NO_LIB.
  189. # If you want to observe which libraries are being linked against then defining
  190. # BOOST_LIB_DIAGNOSTIC will cause the auto-linking code to emit a #pragma message each time
  191. # a library is selected for linking.
  192. SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define")
  193. ENDIF(WIN32)
  194. SET(_boost_INCLUDE_SEARCH_DIRS
  195. C:/boost/include
  196. "C:/Program Files/boost/boost_${Boost_FIND_VERSION_MAJOR}_${Boost_FIND_VERSION_MINOR}_${Boost_FIND_VERSION_PATCH}"
  197. # D: is very often the cdrom drive, IF you don't have a
  198. # cdrom inserted it will popup a very annoying dialog
  199. #D:/boost/include
  200. /sw/local/include
  201. )
  202. SET(_boost_LIBRARIES_SEARCH_DIRS
  203. C:/boost/lib
  204. "C:/Program Files/boost/boost_${Boost_FIND_VERSION_MAJOR}_${Boost_FIND_VERSION_MINOR}_${Boost_FIND_VERSION_PATCH}/lib"
  205. /sw/local/lib
  206. )
  207. IF( NOT $ENV{BOOST_ROOT} STREQUAL "" )
  208. SET(_boost_INCLUDE_SEARCH_DIRS $ENV{BOOST_ROOT}/include ${_boost_INCLUDE_SEARCH_DIRS})
  209. SET(_boost_LIBRARIES_SEARCH_DIRS $ENV{BOOST_ROOT}/lib ${_boost_INCLUDE_SEARCH_DIRS})
  210. ENDIF( NOT $ENV{BOOST_ROOT} STREQUAL "" )
  211. IF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
  212. SET(_boost_INCLUDE_SEARCH_DIRS $ENV{BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS})
  213. ENDIF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
  214. IF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
  215. SET(_boost_LIBRARIES_SEARCH_DIRS $ENV{BOOST_LIBRARYDIR} ${_boost_INCLUDE_SEARCH_DIRS})
  216. ENDIF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
  217. IF( BOOST_ROOT )
  218. IF( WIN32 )
  219. SET(_boost_INCLUDE_SEARCH_DIRS ${BOOST_ROOT} ${_boost_INCLUDE_SEARCH_DIRS})
  220. ELSE( WIN32 )
  221. SET(_boost_INCLUDE_SEARCH_DIRS ${BOOST_ROOT}/include ${_boost_INCLUDE_SEARCH_DIRS})
  222. ENDIF( WIN32 )
  223. SET(_boost_LIBRARIES_SEARCH_DIRS ${BOOST_ROOT}/lib ${_boost_LIBRARIES_SEARCH_DIRS})
  224. ENDIF( BOOST_ROOT )
  225. IF( BOOST_INCLUDEDIR )
  226. SET(_boost_INCLUDE_SEARCH_DIRS ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS})
  227. ENDIF( BOOST_INCLUDEDIR )
  228. IF( BOOST_LIBRARYDIR )
  229. SET(_boost_LIBRARIES_SEARCH_DIRS ${BOOST_LIBRARYDIR} ${_boost_LIBRARIES_SEARCH_DIRS})
  230. ENDIF( BOOST_LIBRARYDIR )
  231. #Try first in our own include search paths (e.g. BOOST_ROOT)
  232. FOREACH(_boost_VER ${_boost_TEST_VERSIONS})
  233. IF( NOT Boost_INCLUDE_DIR )
  234. # Add in a path suffix, based on the required version, ideally we could
  235. # read this from version.hpp, but for that to work we'd need to know the include
  236. # dir already
  237. SET(_boost_PATH_SUFFIX
  238. boost-${_boost_VER}
  239. )
  240. IF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
  241. STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX})
  242. ELSEIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+")
  243. STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX})
  244. ENDIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
  245. FIND_PATH(Boost_INCLUDE_DIR
  246. NAMES boost/config.hpp
  247. PATHS ${_boost_INCLUDE_SEARCH_DIRS}
  248. PATH_SUFFIXES ${_boost_PATH_SUFFIX}
  249. NO_DEFAULT_PATH
  250. )
  251. ENDIF( NOT Boost_INCLUDE_DIR )
  252. ENDFOREACH(_boost_VER)
  253. # If nothing is found search again using system default paths
  254. FOREACH(_boost_VER ${_boost_TEST_VERSIONS})
  255. IF( NOT Boost_INCLUDE_DIR )
  256. # Add in a path suffix, based on the required version, ideally we could
  257. # read this from version.hpp, but for that to work we'd need to know the include
  258. # dir already
  259. SET(_boost_PATH_SUFFIX
  260. boost-${_boost_VER}
  261. )
  262. IF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
  263. STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX})
  264. ELSEIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+")
  265. STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX})
  266. ENDIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
  267. FIND_PATH(Boost_INCLUDE_DIR
  268. NAMES boost/config.hpp
  269. PATH_SUFFIXES ${_boost_PATH_SUFFIX}
  270. )
  271. ENDIF( NOT Boost_INCLUDE_DIR )
  272. ENDFOREACH(_boost_VER)
  273. IF(Boost_INCLUDE_DIR)
  274. # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp
  275. # Read the whole file:
  276. #
  277. SET(BOOST_VERSION 0)
  278. SET(BOOST_LIB_VERSION "")
  279. FILE(READ "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS)
  280. STRING(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}")
  281. STRING(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}")
  282. SET(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE INTERNAL "The library version string for boost libraries")
  283. SET(Boost_VERSION ${Boost_VERSION} CACHE INTERNAL "The version number for boost libraries")
  284. IF(NOT "${Boost_VERSION}" STREQUAL "0")
  285. MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
  286. MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
  287. MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
  288. ENDIF(NOT "${Boost_VERSION}" STREQUAL "0")
  289. ENDIF(Boost_INCLUDE_DIR)
  290. #Setting some more suffixes for the library
  291. SET (Boost_LIB_PREFIX "")
  292. IF ( WIN32 AND Boost_USE_STATIC_LIBS )
  293. SET (Boost_LIB_PREFIX "lib")
  294. ENDIF ( WIN32 AND Boost_USE_STATIC_LIBS )
  295. SET (_boost_COMPILER "-gcc")
  296. IF (MSVC71)
  297. SET (_boost_COMPILER "-vc71")
  298. ENDIF(MSVC71)
  299. IF (MSVC80)
  300. SET (_boost_COMPILER "-vc80")
  301. ENDIF(MSVC80)
  302. IF (MSVC90)
  303. SET (_boost_COMPILER "-vc90")
  304. ENDIF (MSVC90)
  305. IF (MINGW)
  306. EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
  307. ARGS --version
  308. OUTPUT_VARIABLE _boost_COMPILER_VERSION
  309. )
  310. STRING(REGEX REPLACE ".* ([0-9])\\.([0-9])\\.[0-9] .*" "\\1\\2"
  311. _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
  312. SET (_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}")
  313. ENDIF(MINGW)
  314. IF (CYGWIN)
  315. SET (_boost_COMPILER "-gcc")
  316. ENDIF (CYGWIN)
  317. IF (UNIX)
  318. IF (APPLE)
  319. SET (_boost_COMPILER "")
  320. ELSE (APPLE)
  321. IF (NOT CMAKE_COMPILER_IS_GNUCC)
  322. # This is for the intel compiler
  323. SET (_boost_COMPILER "-il")
  324. ELSE (NOT CMAKE_COMPILER_IS_GNUCC)
  325. #find out the version of gcc being used.
  326. EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
  327. ARGS --version
  328. OUTPUT_VARIABLE _boost_COMPILER_VERSION
  329. )
  330. STRING(REGEX REPLACE ".* ([0-9])\\.([0-9])\\.[0-9] .*" "\\1\\2"
  331. _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
  332. SET (_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}")
  333. ENDIF (NOT CMAKE_COMPILER_IS_GNUCC)
  334. ENDIF (APPLE)
  335. ENDIF(UNIX)
  336. SET (_boost_MULTITHREADED "-mt")
  337. IF( NOT Boost_USE_MULTITHREADED )
  338. SET (_boost_MULTITHREADED "")
  339. ENDIF( NOT Boost_USE_MULTITHREADED )
  340. SET( _boost_STATIC_TAG "")
  341. IF (WIN32)
  342. IF(MSVC)
  343. SET (_boost_ABI_TAG "g")
  344. ENDIF(MSVC)
  345. IF( Boost_USE_STATIC_LIBS )
  346. SET( _boost_STATIC_TAG "-s")
  347. ENDIF( Boost_USE_STATIC_LIBS )
  348. ENDIF(WIN32)
  349. SET (_boost_ABI_TAG "${_boost_ABI_TAG}d")
  350. # ------------------------------------------------------------------------
  351. # Begin finding boost libraries
  352. # ------------------------------------------------------------------------
  353. FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
  354. STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  355. SET( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" )
  356. SET( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" )
  357. SET( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND")
  358. # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
  359. IF( Boost_USE_STATIC_LIBS )
  360. SET( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
  361. IF(WIN32)
  362. SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
  363. ELSE(WIN32)
  364. SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
  365. ENDIF(WIN32)
  366. ENDIF( Boost_USE_STATIC_LIBS )
  367. FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE
  368. NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${Boost_LIB_VERSION}
  369. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION}
  370. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}
  371. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}
  372. ${Boost_LIB_PREFIX}boost_${COMPONENT}
  373. PATHS ${_boost_LIBRARIES_SEARCH_DIRS}
  374. NO_DEFAULT_PATH
  375. )
  376. IF( NOT ${Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE} )
  377. FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE
  378. NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${Boost_LIB_VERSION}
  379. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION}
  380. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}
  381. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}
  382. ${Boost_LIB_PREFIX}boost_${COMPONENT}
  383. )
  384. ENDIF( NOT ${Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE} )
  385. FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG
  386. NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION}
  387. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION}
  388. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}
  389. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}
  390. ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_boost_ABI_TAG}
  391. PATHS ${_boost_LIBRARIES_SEARCH_DIRS}
  392. NO_DEFAULT_PATH
  393. )
  394. IF( NOT ${Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG} )
  395. FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG
  396. NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION}
  397. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION}
  398. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}
  399. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}
  400. ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_boost_ABI_TAG}
  401. )
  402. ENDIF( NOT ${Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG} )
  403. _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT})
  404. IF( Boost_USE_STATIC_LIBS )
  405. SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
  406. ENDIF( Boost_USE_STATIC_LIBS )
  407. ENDFOREACH(COMPONENT)
  408. # ------------------------------------------------------------------------
  409. # End finding boost libraries
  410. # ------------------------------------------------------------------------
  411. SET(Boost_INCLUDE_DIRS
  412. ${Boost_INCLUDE_DIR}
  413. )
  414. # MESSAGE(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
  415. # MESSAGE(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
  416. SET(Boost_FOUND FALSE)
  417. IF(Boost_INCLUDE_DIR)
  418. SET( Boost_FOUND TRUE )
  419. IF( Boost_FIND_VERSION_MAJOR AND Boost_VERSION_MAJOR LESS "${Boost_FIND_VERSION_MAJOR}" )
  420. SET( Boost_FOUND FALSE )
  421. ELSE( Boost_FIND_VERSION_MAJOR AND Boost_VERSION_MAJOR LESS "${Boost_FIND_VERSION_MAJOR}" )
  422. IF( Boost_FIND_VERSION_MINOR AND Boost_VERSION_MINOR LESS "${Boost_FIND_VERSION_MINOR}" )
  423. SET( Boost_FOUND FALSE )
  424. ELSE( Boost_FIND_VERSION_MINOR AND Boost_VERSION_MINOR LESS "${Boost_FIND_VERSION_MINOR}" )
  425. IF( Boost_FIND_VERSION_PATCH AND Boost_VERSION_SUBMINOR LESS "${Boost_FIND_VERSION_PATCH}" )
  426. SET( Boost_FOUND FALSE )
  427. ENDIF( Boost_FIND_VERSION_PATCH AND Boost_VERSION_SUBMINOR LESS "${Boost_FIND_VERSION_PATCH}" )
  428. ENDIF( Boost_FIND_VERSION_MINOR AND Boost_VERSION_MINOR LESS "${Boost_FIND_VERSION_MINOR}" )
  429. ENDIF( Boost_FIND_VERSION_MAJOR AND Boost_VERSION_MAJOR LESS "${Boost_FIND_VERSION_MAJOR}" )
  430. set(_boost_CHECKED_COMPONENT FALSE)
  431. FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
  432. STRING(TOUPPER ${COMPONENT} COMPONENT)
  433. set(_boost_CHECKED_COMPONENT TRUE)
  434. IF(NOT Boost_${COMPONENT}_FOUND)
  435. SET( Boost_FOUND FALSE)
  436. ENDIF(NOT Boost_${COMPONENT}_FOUND)
  437. ENDFOREACH(COMPONENT)
  438. IF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
  439. # Compatibility Code for backwards compatibility with CMake 2.4
  440. # Look for the boost library path.
  441. # Note that the user may not have installed any libraries
  442. # so it is quite possible the Boost_LIBRARY_PATH may not exist.
  443. SET(_boost_LIB_DIR ${Boost_INCLUDE_DIR})
  444. IF("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
  445. GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
  446. ENDIF ("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
  447. IF("${_boost_LIB_DIR}" MATCHES "/include$")
  448. # Strip off the trailing "/include" in the path.
  449. GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
  450. ENDIF("${_boost_LIB_DIR}" MATCHES "/include$")
  451. IF(EXISTS "${_boost_LIB_DIR}/lib")
  452. SET (_boost_LIB_DIR ${_boost_LIB_DIR}/lib)
  453. ELSE(EXISTS "${_boost_LIB_DIR}/lib")
  454. IF(EXISTS "${_boost_LIB_DIR}/stage/lib")
  455. SET(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib)
  456. ELSE(EXISTS "${_boost_LIB_DIR}/stage/lib")
  457. SET(_boost_LIB_DIR "")
  458. ENDIF(EXISTS "${_boost_LIB_DIR}/stage/lib")
  459. ENDIF(EXISTS "${_boost_LIB_DIR}/lib")
  460. IF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
  461. SET(Boost_LIBRARY_DIRS ${_boost_LIB_DIR} CACHE FILEPATH "Boost library directory")
  462. ENDIF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
  463. ENDIF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
  464. ELSE(Boost_INCLUDE_DIR)
  465. SET( Boost_FOUND FALSE)
  466. ENDIF(Boost_INCLUDE_DIR)
  467. IF (Boost_FOUND)
  468. IF (NOT Boost_FIND_QUIETLY)
  469. MESSAGE(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
  470. ENDIF(NOT Boost_FIND_QUIETLY)
  471. IF (NOT Boost_FIND_QUIETLY)
  472. MESSAGE(STATUS "Found the following Boost libraries:")
  473. ENDIF(NOT Boost_FIND_QUIETLY)
  474. FOREACH ( COMPONENT ${Boost_FIND_COMPONENTS} )
  475. STRING( TOUPPER ${COMPONENT} UPPERCOMPONENT )
  476. IF ( Boost_${UPPERCOMPONENT}_FOUND )
  477. IF (NOT Boost_FIND_QUIETLY)
  478. MESSAGE (STATUS " ${COMPONENT}")
  479. ENDIF(NOT Boost_FIND_QUIETLY)
  480. SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${UPPERCOMPONENT}_LIBRARY})
  481. ENDIF ( Boost_${UPPERCOMPONENT}_FOUND )
  482. ENDFOREACH(COMPONENT)
  483. ELSE (Boost_FOUND)
  484. IF (Boost_FIND_REQUIRED)
  485. MESSAGE(STATUS "Boost version required: ${Boost_FIND_VERSION}. Found: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
  486. MESSAGE(FATAL_ERROR "Couldn't find the Boost libraries and/or include directory, or the version found is too old. Please install the Boost libraries AND development packages. You can set BOOST_ROOT, BOOST_INCLUDEDIR and BOOST_LIBRARYDIR to help find Boost.")
  487. ENDIF(Boost_FIND_REQUIRED)
  488. ENDIF(Boost_FOUND)
  489. # Under Windows, automatic linking is performed, so no need to specify the libraries.
  490. IF (WIN32)
  491. IF (NOT MINGW)
  492. SET(Boost_LIBRARIES "")
  493. ENDIF (NOT MINGW)
  494. ENDIF(WIN32)
  495. # show the Boost_INCLUDE_DIRS AND Boost_LIBRARIES variables only in the advanced view
  496. MARK_AS_ADVANCED(Boost_INCLUDE_DIR
  497. Boost_INCLUDE_DIRS
  498. Boost_LIBRARY_DIRS
  499. Boost_USE_MULTITHREADED
  500. )
  501. ENDIF(_boost_IN_CACHE)