FindBoost.cmake 27 KB

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