FindBoost.cmake 53 KB

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