FindBoost.cmake 51 KB

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