FindBoost.cmake 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088
  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. # set(Boost_USE_STATIC_RUNTIME OFF)
  23. # set(Boost_COMPAT_STATIC_RUNTIME OFF)
  24. # find_package( Boost 1.36.0 COMPONENTS date_time filesystem system ... )
  25. #
  26. # if(Boost_FOUND)
  27. # include_directories(${Boost_INCLUDE_DIRS})
  28. # add_executable(foo foo.cc)
  29. # target_link_libraries(foo ${Boost_LIBRARIES})
  30. # endif()
  31. #
  32. #
  33. # The components list needs to contain actual names of boost libraries only,
  34. # such as "date_time" for "libboost_date_time". If you're using parts of
  35. # Boost that contain header files only (e.g. foreach) you do not need to
  36. # specify COMPONENTS.
  37. #
  38. # You should provide a minimum version number that should be used. If you provide this
  39. # version number and specify the REQUIRED attribute, this module will fail if it
  40. # can't find the specified or a later version. If you specify a version number this is
  41. # automatically put into the considered list of version numbers and thus doesn't need
  42. # to be specified in the Boost_ADDITIONAL_VERSIONS variable (see below).
  43. #
  44. # NOTE for Visual Studio Users:
  45. # Automatic linking is used on MSVC & Borland compilers by default when
  46. # #including things in Boost. It's important to note that setting
  47. # Boost_USE_STATIC_LIBS to OFF is NOT enough to get you dynamic linking,
  48. # should you need this feature. Automatic linking typically uses static
  49. # libraries with a few exceptions (Boost.Python is one).
  50. #
  51. # Please see the section below near Boost_LIB_DIAGNOSTIC_DEFINITIONS for
  52. # more details. Adding a TARGET_LINK_LIBRARIES() as shown in the example
  53. # above appears to cause VS to link dynamically if Boost_USE_STATIC_LIBS
  54. # gets set to OFF. It is suggested you avoid automatic linking since it
  55. # will make your application less portable.
  56. #
  57. # =========== The mess that is Boost_ADDITIONAL_VERSIONS (sorry?) ============
  58. #
  59. # OK, so the Boost_ADDITIONAL_VERSIONS variable can be used to specify a list of
  60. # boost version numbers that should be taken into account when searching
  61. # for Boost. Unfortunately boost puts the version number into the
  62. # actual filename for the libraries, so this variable will certainly be needed
  63. # in the future when new Boost versions are released.
  64. #
  65. # Currently this module searches for the following version numbers:
  66. # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1,
  67. # 1.36, 1.36.0, 1.36.1, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0,
  68. # 1.40, 1.40.0, 1.41, 1.41.0, 1.42, 1.42.0, 1.43, 1.43.0, 1.44, 1.44.0
  69. #
  70. # NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should
  71. # add both 1.x and 1.x.0 as shown above. Official Boost include directories
  72. # omit the 3rd version number from include paths if it is 0 although not all
  73. # binary Boost releases do so.
  74. #
  75. # SET(Boost_ADDITIONAL_VERSIONS "1.78" "1.78.0" "1.79" "1.79.0")
  76. #
  77. # ===================================== ============= ========================
  78. #
  79. # Variables used by this module, they can change the default behaviour and
  80. # need to be set before calling find_package:
  81. #
  82. # Boost_USE_MULTITHREADED Can be set to OFF to use the non-multithreaded
  83. # boost libraries. If not specified, defaults
  84. # to ON.
  85. #
  86. # Boost_USE_STATIC_LIBS Can be set to ON to force the use of the static
  87. # boost libraries. Defaults to OFF.
  88. #
  89. # Boost_NO_SYSTEM_PATHS Set to TRUE to suppress searching in system
  90. # paths (or other locations outside of BOOST_ROOT
  91. # or BOOST_INCLUDEDIR). Useful when specifying
  92. # BOOST_ROOT. Defaults to OFF.
  93. # [Since CMake 2.8.3]
  94. #
  95. # Boost_USE_STATIC_RUNTIME If enabled, searches for boost libraries
  96. # linked against a static C++ standard library
  97. # ('s' ABI tag). Defaults to OFF.
  98. # [Since CMake 2.8.3]
  99. #
  100. # Boost_USE_DEBUG_PYTHON If enabled, searches for boost libraries
  101. # compiled against a special debug build of
  102. # Python ('y' ABI tag). Defaults to OFF.
  103. # [Since CMake 2.8.3]
  104. #
  105. # Boost_USE_STLPORT If enabled, searches for boost libraries
  106. # compiled against the STLPort standard
  107. # library ('p' ABI tag). Defaults to OFF.
  108. # [Since CMake 2.8.3]
  109. #
  110. # Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS
  111. # If enabled, searches for boost libraries
  112. # compiled against the deprecated STLPort
  113. # "native iostreams" feature ('n' ABI tag).
  114. # Defaults to OFF.
  115. # [Since CMake 2.8.3]
  116. #
  117. # Boost_COMPAT_STATIC_RUNTIME Set to OFF to disable backwards compatible
  118. # searching for libraries with the 's' ABI
  119. # tag on WIN32 after normal searches. You
  120. # should set this to OFF and also set
  121. # Boost_USE_STATIC_RUNTIME appropriately.
  122. # If not specified, defaults to ON.
  123. # [Since CMake 2.8.3]
  124. #
  125. # Other Variables used by this module which you may want to set.
  126. #
  127. # Boost_ADDITIONAL_VERSIONS A list of version numbers to use for searching
  128. # the boost include directory. Please see
  129. # the documentation above regarding this
  130. # annoying, but necessary variable :(
  131. #
  132. # Boost_DEBUG Set this to TRUE to enable debugging output
  133. # of FindBoost.cmake if you are having problems.
  134. # Please enable this before filing any bug
  135. # reports.
  136. #
  137. # Boost_DETAILED_FAILURE_MSG FindBoost doesn't output detailed information
  138. # about why it failed or how to fix the problem
  139. # unless this is set to TRUE or the REQUIRED
  140. # keyword is specified in find_package().
  141. # [Since CMake 2.8.0]
  142. #
  143. # Boost_COMPILER Set this to the compiler suffix used by Boost
  144. # (e.g. "-gcc43") if FindBoost has problems finding
  145. # the proper Boost installation
  146. #
  147. # These last three variables are available also as environment variables:
  148. #
  149. # BOOST_ROOT or BOOSTROOT The preferred installation prefix for searching for
  150. # Boost. Set this if the module has problems finding
  151. # the proper Boost installation. To prevent falling
  152. # back on the system paths, set Boost_NO_SYSTEM_PATHS
  153. # to true.
  154. #
  155. # BOOST_INCLUDEDIR Set this to the include directory of Boost, if the
  156. # module has problems finding the proper Boost installation
  157. #
  158. # BOOST_LIBRARYDIR Set this to the lib directory of Boost, if the
  159. # module has problems finding the proper Boost installation
  160. #
  161. # Variables defined by this module:
  162. #
  163. # Boost_FOUND System has Boost, this means the include dir was
  164. # found, as well as all the libraries specified in
  165. # the COMPONENTS list.
  166. #
  167. # Boost_INCLUDE_DIRS Boost include directories: not cached
  168. #
  169. # Boost_INCLUDE_DIR This is almost the same as above, but this one is
  170. # cached and may be modified by advanced users
  171. #
  172. # Boost_LIBRARIES Link to these to use the Boost libraries that you
  173. # specified: not cached
  174. #
  175. # Boost_LIBRARY_DIRS The path to where the Boost library files are.
  176. #
  177. # Boost_VERSION The version number of the boost libraries that
  178. # have been found, same as in version.hpp from Boost
  179. #
  180. # Boost_LIB_VERSION The version number in filename form as
  181. # it's appended to the library filenames
  182. #
  183. # Boost_MAJOR_VERSION major version number of boost
  184. # Boost_MINOR_VERSION minor version number of boost
  185. # Boost_SUBMINOR_VERSION subminor version number of boost
  186. #
  187. # Boost_LIB_DIAGNOSTIC_DEFINITIONS [WIN32 Only] You can call
  188. # add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
  189. # to have diagnostic information about Boost's
  190. # automatic linking outputted during compilation time.
  191. #
  192. # For each component you specify in find_package(), the following (UPPER-CASE)
  193. # variables are set. You can use these variables if you would like to pick and
  194. # choose components for your targets instead of just using Boost_LIBRARIES.
  195. #
  196. # Boost_${COMPONENT}_FOUND True IF the Boost library "component" was found.
  197. #
  198. # Boost_${COMPONENT}_LIBRARY Contains the libraries for the specified Boost
  199. # "component" (includes debug and optimized keywords
  200. # when needed).
  201. #=============================================================================
  202. # Copyright 2006-2009 Kitware, Inc.
  203. # Copyright 2006-2008 Andreas Schneider <[email protected]>
  204. # Copyright 2007 Wengo
  205. # Copyright 2007 Mike Jackson
  206. # Copyright 2008 Andreas Pakulat <[email protected]>
  207. # Copyright 2008-2010 Philip Lowman <[email protected]>
  208. #
  209. # Distributed under the OSI-approved BSD License (the "License");
  210. # see accompanying file Copyright.txt for details.
  211. #
  212. # This software is distributed WITHOUT ANY WARRANTY; without even the
  213. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  214. # See the License for more information.
  215. #=============================================================================
  216. # (To distribute this file outside of CMake, substitute the full
  217. # License text for the above reference.)
  218. #-------------------------------------------------------------------------------
  219. # FindBoost functions & macros
  220. #
  221. ############################################
  222. #
  223. # Check the existence of the libraries.
  224. #
  225. ############################################
  226. # This macro was taken directly from the FindQt4.cmake file that is included
  227. # with the CMake distribution. This is NOT my work. All work was done by the
  228. # original authors of the FindQt4.cmake file. Only minor modifications were
  229. # made to remove references to Qt and make this file more generally applicable
  230. # And ELSE/ENDIF pairs were removed for readability.
  231. #########################################################################
  232. MACRO (_Boost_ADJUST_LIB_VARS basename)
  233. IF (Boost_INCLUDE_DIR )
  234. IF (Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
  235. # if the generator supports configuration types then set
  236. # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
  237. IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
  238. SET(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
  239. ELSE()
  240. # if there are no configuration types and CMAKE_BUILD_TYPE has no value
  241. # then just use the release libraries
  242. SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
  243. ENDIF()
  244. # FIXME: This probably should be set for both cases
  245. SET(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
  246. ENDIF()
  247. # if only the release version was found, set the debug variable also to the release version
  248. IF (Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG)
  249. SET(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE})
  250. SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE})
  251. SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE})
  252. ENDIF()
  253. # if only the debug version was found, set the release variable also to the debug version
  254. IF (Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE)
  255. SET(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG})
  256. SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG})
  257. SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG})
  258. ENDIF()
  259. IF (Boost_${basename}_LIBRARY)
  260. set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library")
  261. # Remove superfluous "debug" / "optimized" keywords from
  262. # Boost_LIBRARY_DIRS
  263. FOREACH(_boost_my_lib ${Boost_${basename}_LIBRARY})
  264. GET_FILENAME_COMPONENT(_boost_my_lib_path "${_boost_my_lib}" PATH)
  265. LIST(APPEND Boost_LIBRARY_DIRS ${_boost_my_lib_path})
  266. ENDFOREACH()
  267. LIST(REMOVE_DUPLICATES Boost_LIBRARY_DIRS)
  268. set(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS} CACHE FILEPATH "Boost library directory")
  269. SET(Boost_${basename}_FOUND ON CACHE INTERNAL "Whether the Boost ${basename} library found")
  270. ENDIF(Boost_${basename}_LIBRARY)
  271. ENDIF (Boost_INCLUDE_DIR )
  272. # Make variables changeble to the advanced user
  273. MARK_AS_ADVANCED(
  274. Boost_${basename}_LIBRARY
  275. Boost_${basename}_LIBRARY_RELEASE
  276. Boost_${basename}_LIBRARY_DEBUG
  277. )
  278. ENDMACRO (_Boost_ADJUST_LIB_VARS)
  279. #-------------------------------------------------------------------------------
  280. #
  281. # Runs compiler with "-dumpversion" and parses major/minor
  282. # version with a regex.
  283. #
  284. FUNCTION(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION)
  285. EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
  286. ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
  287. OUTPUT_VARIABLE _boost_COMPILER_VERSION
  288. )
  289. STRING(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
  290. _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
  291. SET(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE)
  292. ENDFUNCTION()
  293. #
  294. # A convenience function for marking desired components
  295. # as found or not
  296. #
  297. function(_Boost_MARK_COMPONENTS_FOUND _yes_or_no)
  298. foreach(COMPONENT ${Boost_FIND_COMPONENTS})
  299. string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  300. set(Boost_${UPPERCOMPONENT}_FOUND ${_yes_or_no} CACHE INTERNAL "Whether the Boost ${COMPONENT} library found" FORCE)
  301. endforeach()
  302. endfunction()
  303. #
  304. # End functions/macros
  305. #
  306. #-------------------------------------------------------------------------------
  307. IF(NOT DEFINED Boost_USE_MULTITHREADED)
  308. SET(Boost_USE_MULTITHREADED TRUE)
  309. ENDIF()
  310. if(NOT DEFINED Boost_COMPAT_STATIC_RUNTIME)
  311. set(Boost_COMPAT_STATIC_RUNTIME TRUE)
  312. endif()
  313. if(Boost_FIND_VERSION_EXACT)
  314. # The version may appear in a directory with or without the patch
  315. # level, even when the patch level is non-zero.
  316. set(_boost_TEST_VERSIONS
  317. "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.${Boost_FIND_VERSION_PATCH}"
  318. "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  319. else(Boost_FIND_VERSION_EXACT)
  320. # The user has not requested an exact version. Among known
  321. # versions, find those that are acceptable to the user request.
  322. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
  323. "1.44.0" "1.44" "1.43.0" "1.43" "1.42.0" "1.42"
  324. "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37"
  325. "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0"
  326. "1.34" "1.33.1" "1.33.0" "1.33")
  327. set(_boost_TEST_VERSIONS)
  328. if(Boost_FIND_VERSION)
  329. set(_Boost_FIND_VERSION_SHORT "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  330. # Select acceptable versions.
  331. foreach(version ${_Boost_KNOWN_VERSIONS})
  332. if(NOT "${version}" VERSION_LESS "${Boost_FIND_VERSION}")
  333. # This version is high enough.
  334. list(APPEND _boost_TEST_VERSIONS "${version}")
  335. elseif("${version}.99" VERSION_EQUAL "${_Boost_FIND_VERSION_SHORT}.99")
  336. # This version is a short-form for the requested version with
  337. # the patch level dropped.
  338. list(APPEND _boost_TEST_VERSIONS "${version}")
  339. endif()
  340. endforeach(version)
  341. else(Boost_FIND_VERSION)
  342. # Any version is acceptable.
  343. set(_boost_TEST_VERSIONS "${_Boost_KNOWN_VERSIONS}")
  344. endif(Boost_FIND_VERSION)
  345. endif(Boost_FIND_VERSION_EXACT)
  346. # The reason that we failed to find Boost. This will be set to a
  347. # user-friendly message when we fail to find some necessary piece of
  348. # Boost.
  349. set(Boost_ERROR_REASON)
  350. SET( _boost_IN_CACHE TRUE)
  351. IF(Boost_INCLUDE_DIR)
  352. # On versions < 1.35, remove the System library from the considered list
  353. # since it wasn't added until 1.35.
  354. if(Boost_VERSION AND Boost_FIND_COMPONENTS)
  355. math(EXPR _boost_maj "${Boost_VERSION} / 100000")
  356. math(EXPR _boost_min "${Boost_VERSION} / 100 % 1000")
  357. if(${_boost_maj}.${_boost_min} VERSION_LESS 1.35)
  358. list(REMOVE_ITEM Boost_FIND_COMPONENTS system)
  359. endif()
  360. endif()
  361. FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
  362. STRING(TOUPPER ${COMPONENT} COMPONENT)
  363. IF(NOT Boost_${COMPONENT}_FOUND)
  364. SET( _boost_IN_CACHE FALSE)
  365. ENDIF(NOT Boost_${COMPONENT}_FOUND)
  366. ENDFOREACH(COMPONENT)
  367. ELSE(Boost_INCLUDE_DIR)
  368. SET( _boost_IN_CACHE FALSE)
  369. ENDIF(Boost_INCLUDE_DIR)
  370. IF (_boost_IN_CACHE)
  371. # in cache already
  372. SET(Boost_FOUND TRUE)
  373. FOREACH(COMPONENT ${Boost_FIND_COMPONENTS})
  374. STRING(TOUPPER ${COMPONENT} COMPONENT)
  375. _Boost_ADJUST_LIB_VARS( ${COMPONENT} )
  376. SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${COMPONENT}_LIBRARY})
  377. ENDFOREACH(COMPONENT)
  378. SET(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
  379. IF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
  380. MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
  381. MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
  382. MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
  383. ENDIF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0")
  384. if(Boost_DEBUG)
  385. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  386. "boost ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION} "
  387. "is already in the cache. To view debugging messages, please clear the cache.")
  388. endif()
  389. ELSE (_boost_IN_CACHE)
  390. # Need to search for boost
  391. if(Boost_DEBUG)
  392. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  393. "Boost not in cache")
  394. # Output some of their choices
  395. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  396. "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
  397. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  398. "Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}")
  399. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  400. "Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}")
  401. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  402. "Boost_USE_STATIC_RUNTIME = ${Boost_USE_STATIC_RUNTIME}")
  403. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  404. "Boost_ADDITIONAL_VERSIONS = ${Boost_ADDITIONAL_VERSIONS}")
  405. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  406. "Boost_NO_SYSTEM_PATHS = ${Boost_NO_SYSTEM_PATHS}")
  407. endif()
  408. IF(WIN32)
  409. # In windows, automatic linking is performed, so you do not have
  410. # to specify the libraries. If you are linking to a dynamic
  411. # runtime, then you can choose to link to either a static or a
  412. # dynamic Boost library, the default is to do a static link. You
  413. # can alter this for a specific library "whatever" by defining
  414. # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be
  415. # linked dynamically. Alternatively you can force all Boost
  416. # libraries to dynamic link by defining BOOST_ALL_DYN_LINK.
  417. # This feature can be disabled for Boost library "whatever" by
  418. # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining
  419. # BOOST_ALL_NO_LIB.
  420. # If you want to observe which libraries are being linked against
  421. # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking
  422. # code to emit a #pragma message each time a library is selected
  423. # for linking.
  424. SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS
  425. "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define")
  426. ENDIF(WIN32)
  427. SET(_boost_INCLUDE_SEARCH_DIRS
  428. C:/boost/include
  429. C:/boost
  430. "$ENV{ProgramFiles}/boost/include"
  431. "$ENV{ProgramFiles}/boost"
  432. /sw/local/include
  433. )
  434. # If Boost_ROOT was defined, gently correct the user
  435. if(Boost_ROOT)
  436. message("WARNING: Boost_ROOT was set which is incorrect and is being ignored. "
  437. "You need to use BOOST_ROOT instead. "
  438. "Also, we suggest setting Boost_NO_SYSTEM_PATHS.")
  439. endif()
  440. # If BOOST_ROOT was defined in the environment, use it.
  441. if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
  442. set(BOOST_ROOT $ENV{BOOST_ROOT})
  443. endif(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "")
  444. # If BOOSTROOT was defined in the environment, use it.
  445. if (NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
  446. set(BOOST_ROOT $ENV{BOOSTROOT})
  447. endif(NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "")
  448. # If BOOST_INCLUDEDIR was defined in the environment, use it.
  449. IF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
  450. set(BOOST_INCLUDEDIR $ENV{BOOST_INCLUDEDIR})
  451. ENDIF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" )
  452. # If BOOST_LIBRARYDIR was defined in the environment, use it.
  453. IF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
  454. set(BOOST_LIBRARYDIR $ENV{BOOST_LIBRARYDIR})
  455. ENDIF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" )
  456. IF( BOOST_ROOT )
  457. file(TO_CMAKE_PATH ${BOOST_ROOT} BOOST_ROOT)
  458. ENDIF( BOOST_ROOT )
  459. if(Boost_DEBUG)
  460. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  461. "Declared as CMake or Environmental Variables:")
  462. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  463. " BOOST_ROOT = ${BOOST_ROOT}")
  464. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  465. " BOOST_INCLUDEDIR = ${BOOST_INCLUDEDIR}")
  466. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  467. " BOOST_LIBRARYDIR = ${BOOST_LIBRARYDIR}")
  468. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  469. "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
  470. endif()
  471. if( BOOST_ROOT )
  472. if( Boost_NO_SYSTEM_PATHS )
  473. set(_boost_INCLUDE_SEARCH_DIRS
  474. ${BOOST_ROOT}/include
  475. ${BOOST_ROOT})
  476. set(_boost_FIND_OPTIONS NO_CMAKE_SYSTEM_PATH)
  477. else()
  478. set(_boost_INCLUDE_SEARCH_DIRS
  479. ${BOOST_ROOT}/include
  480. ${BOOST_ROOT}
  481. ${_boost_INCLUDE_SEARCH_DIRS})
  482. endif()
  483. endif( BOOST_ROOT )
  484. # prepend BOOST_INCLUDEDIR to search path if specified
  485. if( BOOST_INCLUDEDIR )
  486. file(TO_CMAKE_PATH ${BOOST_INCLUDEDIR} BOOST_INCLUDEDIR)
  487. set(_boost_INCLUDE_SEARCH_DIRS
  488. ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS})
  489. endif( BOOST_INCLUDEDIR )
  490. # ------------------------------------------------------------------------
  491. # Search for Boost include DIR
  492. # ------------------------------------------------------------------------
  493. # Try to find Boost by stepping backwards through the Boost versions
  494. # we know about.
  495. IF( NOT Boost_INCLUDE_DIR )
  496. # Build a list of path suffixes for each version.
  497. SET(_boost_PATH_SUFFIXES)
  498. FOREACH(_boost_VER ${_boost_TEST_VERSIONS})
  499. # Add in a path suffix, based on the required version, ideally
  500. # we could read this from version.hpp, but for that to work we'd
  501. # need to know the include dir already
  502. set(_boost_BOOSTIFIED_VERSION)
  503. # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0
  504. IF(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
  505. STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3"
  506. _boost_BOOSTIFIED_VERSION ${_boost_VER})
  507. ELSEIF(_boost_VER MATCHES "[0-9]+\\.[0-9]+")
  508. STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2"
  509. _boost_BOOSTIFIED_VERSION ${_boost_VER})
  510. ENDIF()
  511. list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_BOOSTIFIED_VERSION}")
  512. list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_BOOSTIFIED_VERSION}")
  513. ENDFOREACH(_boost_VER)
  514. if(Boost_DEBUG)
  515. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  516. "Include debugging info:")
  517. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  518. " _boost_INCLUDE_SEARCH_DIRS = ${_boost_INCLUDE_SEARCH_DIRS}")
  519. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  520. " _boost_PATH_SUFFIXES = ${_boost_PATH_SUFFIXES}")
  521. endif()
  522. # Look for a standard boost header file.
  523. FIND_PATH(Boost_INCLUDE_DIR
  524. NAMES boost/config.hpp
  525. HINTS ${_boost_INCLUDE_SEARCH_DIRS}
  526. PATH_SUFFIXES ${_boost_PATH_SUFFIXES}
  527. ${_boost_FIND_OPTIONS}
  528. )
  529. ENDIF( NOT Boost_INCLUDE_DIR )
  530. # ------------------------------------------------------------------------
  531. # Extract version information from version.hpp
  532. # ------------------------------------------------------------------------
  533. IF(Boost_INCLUDE_DIR)
  534. # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp
  535. # Read the whole file:
  536. #
  537. SET(BOOST_VERSION 0)
  538. SET(BOOST_LIB_VERSION "")
  539. FILE(READ "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS)
  540. if(Boost_DEBUG)
  541. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  542. "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp")
  543. endif()
  544. STRING(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}")
  545. STRING(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}")
  546. SET(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE INTERNAL "The library version string for boost libraries")
  547. SET(Boost_VERSION ${Boost_VERSION} CACHE INTERNAL "The version number for boost libraries")
  548. IF(NOT "${Boost_VERSION}" STREQUAL "0")
  549. MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
  550. MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
  551. MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
  552. set(Boost_ERROR_REASON
  553. "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}")
  554. ENDIF(NOT "${Boost_VERSION}" STREQUAL "0")
  555. if(Boost_DEBUG)
  556. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  557. "version.hpp reveals boost "
  558. "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
  559. endif()
  560. ELSE(Boost_INCLUDE_DIR)
  561. set(Boost_ERROR_REASON
  562. "${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.")
  563. ENDIF(Boost_INCLUDE_DIR)
  564. # ------------------------------------------------------------------------
  565. # Suffix initialization and compiler suffix detection.
  566. # ------------------------------------------------------------------------
  567. # Setting some more suffixes for the library
  568. SET (Boost_LIB_PREFIX "")
  569. if ( WIN32 AND Boost_USE_STATIC_LIBS AND NOT CYGWIN)
  570. SET (Boost_LIB_PREFIX "lib")
  571. endif()
  572. if (Boost_COMPILER)
  573. set(_boost_COMPILER ${Boost_COMPILER})
  574. if(Boost_DEBUG)
  575. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  576. "using user-specified Boost_COMPILER = ${_boost_COMPILER}")
  577. endif()
  578. else(Boost_COMPILER)
  579. # Attempt to guess the compiler suffix
  580. # NOTE: this is not perfect yet, if you experience any issues
  581. # please report them and use the Boost_COMPILER variable
  582. # to work around the problems.
  583. if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel"
  584. OR "${CMAKE_CXX_COMPILER}" MATCHES "icl"
  585. OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
  586. if(WIN32)
  587. set (_boost_COMPILER "-iw")
  588. else()
  589. set (_boost_COMPILER "-il")
  590. endif()
  591. elseif (MSVC90)
  592. SET (_boost_COMPILER "-vc90")
  593. elseif (MSVC10)
  594. SET (_boost_COMPILER "-vc100")
  595. elseif (MSVC80)
  596. SET (_boost_COMPILER "-vc80")
  597. elseif (MSVC71)
  598. SET (_boost_COMPILER "-vc71")
  599. elseif (MSVC70) # Good luck!
  600. SET (_boost_COMPILER "-vc7") # yes, this is correct
  601. elseif (MSVC60) # Good luck!
  602. SET (_boost_COMPILER "-vc6") # yes, this is correct
  603. elseif (BORLAND)
  604. SET (_boost_COMPILER "-bcb")
  605. elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "SunPro")
  606. set(_boost_COMPILER "-sw")
  607. elseif (MINGW)
  608. if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
  609. SET(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34
  610. else()
  611. _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
  612. SET (_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}")
  613. endif()
  614. elseif (UNIX)
  615. if (CMAKE_COMPILER_IS_GNUCXX)
  616. if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
  617. SET(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34
  618. else()
  619. _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
  620. # Determine which version of GCC we have.
  621. IF(APPLE)
  622. IF(Boost_MINOR_VERSION)
  623. IF(${Boost_MINOR_VERSION} GREATER 35)
  624. # In Boost 1.36.0 and newer, the mangled compiler name used
  625. # on Mac OS X/Darwin is "xgcc".
  626. SET(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}")
  627. ELSE(${Boost_MINOR_VERSION} GREATER 35)
  628. # In Boost <= 1.35.0, there is no mangled compiler name for
  629. # the Mac OS X/Darwin version of GCC.
  630. SET(_boost_COMPILER "")
  631. ENDIF(${Boost_MINOR_VERSION} GREATER 35)
  632. ELSE(Boost_MINOR_VERSION)
  633. # We don't know the Boost version, so assume it's
  634. # pre-1.36.0.
  635. SET(_boost_COMPILER "")
  636. ENDIF(Boost_MINOR_VERSION)
  637. ELSE()
  638. SET (_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}")
  639. ENDIF()
  640. endif()
  641. endif (CMAKE_COMPILER_IS_GNUCXX)
  642. endif()
  643. if(Boost_DEBUG)
  644. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  645. "guessed _boost_COMPILER = ${_boost_COMPILER}")
  646. endif()
  647. endif(Boost_COMPILER)
  648. set (_boost_MULTITHREADED "-mt")
  649. if( NOT Boost_USE_MULTITHREADED )
  650. set (_boost_MULTITHREADED "")
  651. endif()
  652. if(Boost_DEBUG)
  653. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  654. "_boost_MULTITHREADED = ${_boost_MULTITHREADED}")
  655. endif()
  656. #======================
  657. # Systematically build up the Boost ABI tag
  658. # http://boost.org/doc/libs/1_41_0/more/getting_started/windows.html#library-naming
  659. set( _boost_RELEASE_ABI_TAG "-")
  660. set( _boost_DEBUG_ABI_TAG "-")
  661. # Key Use this library when:
  662. # s linking statically to the C++ standard library and
  663. # compiler runtime support libraries.
  664. if(Boost_USE_STATIC_RUNTIME)
  665. set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}s")
  666. set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}s")
  667. endif()
  668. # g using debug versions of the standard and runtime
  669. # support libraries
  670. if(WIN32)
  671. if(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl"
  672. OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
  673. set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}g")
  674. endif()
  675. endif()
  676. # y using special debug build of python
  677. if(Boost_USE_DEBUG_PYTHON)
  678. set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}y")
  679. endif()
  680. # d using a debug version of your code
  681. set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}d")
  682. # p using the STLport standard library rather than the
  683. # default one supplied with your compiler
  684. if(Boost_USE_STLPORT)
  685. set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}p")
  686. set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}p")
  687. endif()
  688. # n using the STLport deprecated "native iostreams" feature
  689. if(Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS)
  690. set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}n")
  691. set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}n")
  692. endif()
  693. if(Boost_DEBUG)
  694. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  695. "_boost_RELEASE_ABI_TAG = ${_boost_RELEASE_ABI_TAG}")
  696. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  697. "_boost_DEBUG_ABI_TAG = ${_boost_DEBUG_ABI_TAG}")
  698. endif()
  699. # ------------------------------------------------------------------------
  700. # Begin finding boost libraries
  701. # ------------------------------------------------------------------------
  702. set(_boost_LIBRARY_SEARCH_DIRS_ALWAYS
  703. ${BOOST_ROOT}/lib
  704. ${BOOST_ROOT}/stage/lib
  705. ${Boost_INCLUDE_DIR}/lib
  706. ${Boost_INCLUDE_DIR}/../lib
  707. ${Boost_INCLUDE_DIR}/stage/lib
  708. )
  709. set(_boost_LIBRARY_SEARCH_DIRS_SYSTEM
  710. C:/boost/lib
  711. C:/boost
  712. "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}_${Boost_SUBMINOR_VERSION}/lib"
  713. "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}/lib"
  714. "$ENV{ProgramFiles}/boost/lib"
  715. "$ENV{ProgramFiles}/boost"
  716. /sw/local/lib
  717. )
  718. if( BOOST_ROOT )
  719. set(_boost_LIBRARY_SEARCH_DIRS ${_boost_LIBRARY_SEARCH_DIRS_ALWAYS})
  720. if( Boost_NO_SYSTEM_PATHS )
  721. set(_boost_FIND_OPTIONS NO_CMAKE_SYSTEM_PATH)
  722. else()
  723. list(APPEND _boost_LIBRARY_SEARCH_DIRS ${_boost_LIBRARY_SEARCH_DIRS_SYSTEM})
  724. endif()
  725. endif( BOOST_ROOT )
  726. # prepend BOOST_LIBRARYDIR to search path if specified
  727. if( BOOST_LIBRARYDIR )
  728. file(TO_CMAKE_PATH ${BOOST_LIBRARYDIR} BOOST_LIBRARYDIR)
  729. set(_boost_LIBRARY_SEARCH_DIRS
  730. ${BOOST_LIBRARYDIR} ${_boost_LIBRARY_SEARCH_DIRS})
  731. endif()
  732. if(Boost_DEBUG)
  733. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  734. "_boost_LIBRARY_SEARCH_DIRS = ${_boost_LIBRARY_SEARCH_DIRS}")
  735. endif()
  736. # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
  737. if( Boost_USE_STATIC_LIBS )
  738. set( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
  739. if(WIN32)
  740. set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
  741. else()
  742. set(CMAKE_FIND_LIBRARY_SUFFIXES .a )
  743. endif()
  744. endif()
  745. # We want to use the tag inline below without risking double dashes
  746. if(_boost_RELEASE_ABI_TAG)
  747. if(${_boost_RELEASE_ABI_TAG} STREQUAL "-")
  748. set(_boost_RELEASE_ABI_TAG "")
  749. endif()
  750. endif()
  751. if(_boost_DEBUG_ABI_TAG)
  752. if(${_boost_DEBUG_ABI_TAG} STREQUAL "-")
  753. set(_boost_DEBUG_ABI_TAG "")
  754. endif()
  755. endif()
  756. # The previous behavior of FindBoost when Boost_USE_STATIC_LIBS was enabled
  757. # on WIN32 was to:
  758. # 1. Search for static libs compiled against a SHARED C++ standard runtime library (use if found)
  759. # 2. Search for static libs compiled against a STATIC C++ standard runtime library (use if found)
  760. # We maintain this behavior since changing it could break people's builds.
  761. # To disable the ambiguous behavior, the user can
  762. # set Boost_COMPAT_STATIC_RUNTIME to FALSE
  763. set(_boost_STATIC_RUNTIME_WORKAROUND false)
  764. if(Boost_COMPAT_STATIC_RUNTIME AND WIN32 AND Boost_USE_STATIC_LIBS)
  765. if(NOT Boost_USE_STATIC_RUNTIME)
  766. set(_boost_STATIC_RUNTIME_WORKAROUND true)
  767. endif()
  768. endif()
  769. foreach(COMPONENT ${Boost_FIND_COMPONENTS})
  770. string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  771. set( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" )
  772. set( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" )
  773. set( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND")
  774. #
  775. # Find RELEASE libraries
  776. #
  777. set(_boost_RELEASE_NAMES
  778. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
  779. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
  780. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
  781. ${Boost_LIB_PREFIX}boost_${COMPONENT} )
  782. if(_boost_STATIC_RUNTIME_WORKAROUND)
  783. set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}")
  784. list(APPEND _boost_RELEASE_NAMES
  785. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
  786. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}
  787. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
  788. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} )
  789. endif()
  790. if(Boost_DEBUG)
  791. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  792. "Searching for ${UPPERCOMPONENT}_LIBRARY_RELEASE: ${_boost_RELEASE_NAMES}")
  793. endif()
  794. find_library(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE
  795. NAMES ${_boost_RELEASE_NAMES}
  796. HINTS ${_boost_LIBRARY_SEARCH_DIRS}
  797. ${_boost_FIND_OPTIONS}
  798. )
  799. #
  800. # Find DEBUG libraries
  801. #
  802. set(_boost_DEBUG_NAMES
  803. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
  804. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
  805. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}
  806. ${Boost_LIB_PREFIX}boost_${COMPONENT} )
  807. if(_boost_STATIC_RUNTIME_WORKAROUND)
  808. set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}")
  809. list(APPEND _boost_DEBUG_NAMES
  810. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
  811. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}
  812. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
  813. ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} )
  814. endif()
  815. if(Boost_DEBUG)
  816. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
  817. "Searching for ${UPPERCOMPONENT}_LIBRARY_DEBUG: ${_boost_DEBUG_NAMES}")
  818. endif()
  819. find_library(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG
  820. NAMES ${_boost_DEBUG_NAMES}
  821. HINTS ${_boost_LIBRARY_SEARCH_DIRS}
  822. ${_boost_FIND_OPTIONS}
  823. )
  824. _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT})
  825. endforeach(COMPONENT)
  826. # Restore the original find library ordering
  827. if( Boost_USE_STATIC_LIBS )
  828. set(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
  829. endif()
  830. # ------------------------------------------------------------------------
  831. # End finding boost libraries
  832. # ------------------------------------------------------------------------
  833. SET(Boost_INCLUDE_DIRS
  834. ${Boost_INCLUDE_DIR}
  835. )
  836. SET(Boost_FOUND FALSE)
  837. IF(Boost_INCLUDE_DIR)
  838. SET( Boost_FOUND TRUE )
  839. # Check the version of Boost against the requested version.
  840. if (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
  841. 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")
  842. endif (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
  843. if(Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
  844. set( Boost_FOUND FALSE )
  845. set(_Boost_VERSION_AGE "old")
  846. elseif(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
  847. if(Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
  848. set( Boost_FOUND FALSE )
  849. set(_Boost_VERSION_AGE "old")
  850. elseif(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
  851. if( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
  852. set( Boost_FOUND FALSE )
  853. set(_Boost_VERSION_AGE "old")
  854. endif( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" )
  855. endif( Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" )
  856. endif( Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" )
  857. if (NOT Boost_FOUND)
  858. _Boost_MARK_COMPONENTS_FOUND(OFF)
  859. endif()
  860. if (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
  861. # If the user requested an exact version of Boost, check
  862. # that. We already know that the Boost version we have is >= the
  863. # requested version.
  864. set(_Boost_VERSION_AGE "new")
  865. # If the user didn't specify a patchlevel, it's 0.
  866. if (NOT Boost_FIND_VERSION_PATCH)
  867. set(Boost_FIND_VERSION_PATCH 0)
  868. endif (NOT Boost_FIND_VERSION_PATCH)
  869. # We'll set Boost_FOUND true again if we have an exact version match.
  870. set(Boost_FOUND FALSE)
  871. _Boost_MARK_COMPONENTS_FOUND(OFF)
  872. if(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
  873. if(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
  874. if(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
  875. set( Boost_FOUND TRUE )
  876. _Boost_MARK_COMPONENTS_FOUND(ON)
  877. endif(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" )
  878. endif( Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" )
  879. endif( Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" )
  880. endif (Boost_FOUND AND Boost_FIND_VERSION_EXACT)
  881. if(NOT Boost_FOUND)
  882. # State that we found a version of Boost that is too new or too old.
  883. set(Boost_ERROR_REASON
  884. "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
  885. if (Boost_FIND_VERSION_PATCH)
  886. set(Boost_ERROR_REASON
  887. "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}")
  888. endif (Boost_FIND_VERSION_PATCH)
  889. if (NOT Boost_FIND_VERSION_EXACT)
  890. set(Boost_ERROR_REASON "${Boost_ERROR_REASON} (or newer)")
  891. endif (NOT Boost_FIND_VERSION_EXACT)
  892. set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.")
  893. endif (NOT Boost_FOUND)
  894. # Always check for missing components
  895. set(_boost_CHECKED_COMPONENT FALSE)
  896. set(_Boost_MISSING_COMPONENTS "")
  897. foreach(COMPONENT ${Boost_FIND_COMPONENTS})
  898. string(TOUPPER ${COMPONENT} COMPONENT)
  899. set(_boost_CHECKED_COMPONENT TRUE)
  900. if(NOT Boost_${COMPONENT}_FOUND)
  901. string(TOLOWER ${COMPONENT} COMPONENT)
  902. list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT})
  903. set( Boost_FOUND FALSE)
  904. endif(NOT Boost_${COMPONENT}_FOUND)
  905. endforeach(COMPONENT)
  906. if(Boost_DEBUG)
  907. message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] Boost_FOUND = ${Boost_FOUND}")
  908. endif()
  909. if (_Boost_MISSING_COMPONENTS)
  910. # We were unable to find some libraries, so generate a sensible
  911. # error message that lists the libraries we were unable to find.
  912. set(Boost_ERROR_REASON
  913. "${Boost_ERROR_REASON}\nThe following Boost libraries could not be found:\n")
  914. foreach(COMPONENT ${_Boost_MISSING_COMPONENTS})
  915. set(Boost_ERROR_REASON
  916. "${Boost_ERROR_REASON} boost_${COMPONENT}\n")
  917. endforeach(COMPONENT)
  918. list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED)
  919. list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS)
  920. if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
  921. set(Boost_ERROR_REASON
  922. "${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.")
  923. else (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
  924. set(Boost_ERROR_REASON
  925. "${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.")
  926. endif (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
  927. endif (_Boost_MISSING_COMPONENTS)
  928. IF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
  929. # Compatibility Code for backwards compatibility with CMake
  930. # 2.4's FindBoost module.
  931. # Look for the boost library path.
  932. # Note that the user may not have installed any libraries
  933. # so it is quite possible the Boost_LIBRARY_PATH may not exist.
  934. SET(_boost_LIB_DIR ${Boost_INCLUDE_DIR})
  935. IF("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
  936. GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
  937. ENDIF ("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
  938. IF("${_boost_LIB_DIR}" MATCHES "/include$")
  939. # Strip off the trailing "/include" in the path.
  940. GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
  941. ENDIF("${_boost_LIB_DIR}" MATCHES "/include$")
  942. IF(EXISTS "${_boost_LIB_DIR}/lib")
  943. SET (_boost_LIB_DIR ${_boost_LIB_DIR}/lib)
  944. ELSE(EXISTS "${_boost_LIB_DIR}/lib")
  945. IF(EXISTS "${_boost_LIB_DIR}/stage/lib")
  946. SET(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib)
  947. ELSE(EXISTS "${_boost_LIB_DIR}/stage/lib")
  948. SET(_boost_LIB_DIR "")
  949. ENDIF(EXISTS "${_boost_LIB_DIR}/stage/lib")
  950. ENDIF(EXISTS "${_boost_LIB_DIR}/lib")
  951. IF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
  952. SET(Boost_LIBRARY_DIRS ${_boost_LIB_DIR} CACHE FILEPATH "Boost library directory")
  953. ENDIF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
  954. ENDIF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
  955. ELSE(Boost_INCLUDE_DIR)
  956. SET( Boost_FOUND FALSE)
  957. ENDIF(Boost_INCLUDE_DIR)
  958. IF (Boost_FOUND)
  959. IF (NOT Boost_FIND_QUIETLY)
  960. MESSAGE(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
  961. if(Boost_FIND_COMPONENTS)
  962. message(STATUS "Found the following Boost libraries:")
  963. endif()
  964. ENDIF(NOT Boost_FIND_QUIETLY)
  965. FOREACH ( COMPONENT ${Boost_FIND_COMPONENTS} )
  966. STRING( TOUPPER ${COMPONENT} UPPERCOMPONENT )
  967. IF ( Boost_${UPPERCOMPONENT}_FOUND )
  968. IF (NOT Boost_FIND_QUIETLY)
  969. MESSAGE (STATUS " ${COMPONENT}")
  970. ENDIF(NOT Boost_FIND_QUIETLY)
  971. SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${UPPERCOMPONENT}_LIBRARY})
  972. ENDIF ( Boost_${UPPERCOMPONENT}_FOUND )
  973. ENDFOREACH(COMPONENT)
  974. else()
  975. if(Boost_FIND_REQUIRED)
  976. message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")
  977. else()
  978. if(NOT Boost_FIND_QUIETLY)
  979. # we opt not to automatically output Boost_ERROR_REASON here as
  980. # it could be quite lengthy and somewhat imposing in it's requests
  981. # Since Boost is not always a required dependency we'll leave this
  982. # up to the end-user.
  983. if(Boost_DEBUG OR Boost_DETAILED_FAILURE_MSG)
  984. message(STATUS "Could NOT find Boost\n${Boost_ERROR_REASON}")
  985. else()
  986. message(STATUS "Could NOT find Boost")
  987. endif()
  988. endif()
  989. endif(Boost_FIND_REQUIRED)
  990. endif()
  991. # show the Boost_INCLUDE_DIRS AND Boost_LIBRARIES variables only in the advanced view
  992. MARK_AS_ADVANCED(Boost_INCLUDE_DIR
  993. Boost_INCLUDE_DIRS
  994. Boost_LIBRARY_DIRS
  995. )
  996. ENDIF(_boost_IN_CACHE)