FindBoost.cmake 52 KB

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