auto_link.hpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. // (C) Copyright John Maddock 2003.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. /*
  6. * LOCATION: see http://www.boost.org for most recent version.
  7. * FILE auto_link.hpp
  8. * VERSION see <boost/version.hpp>
  9. * DESCRIPTION: Automatic library inclusion for Borland/Microsoft compilers.
  10. */
  11. /*************************************************************************
  12. USAGE:
  13. ~~~~~~
  14. Before including this header you must define one or more of define the following macros:
  15. BOOST_LIB_NAME: Required: A string containing the basename of the library,
  16. for example boost_regex.
  17. BOOST_LIB_TOOLSET: Optional: the base name of the toolset.
  18. BOOST_DYN_LINK: Optional: when set link to dll rather than static library.
  19. BOOST_LIB_DIAGNOSTIC: Optional: when set the header will print out the name
  20. of the library selected (useful for debugging).
  21. BOOST_AUTO_LINK_NOMANGLE: Specifies that we should link to BOOST_LIB_NAME.lib,
  22. rather than a mangled-name version.
  23. BOOST_AUTO_LINK_TAGGED: Specifies that we link to libraries built with the --layout=tagged option.
  24. This is essentially the same as the default name-mangled version, but without
  25. the compiler name and version, or the Boost version. Just the build options.
  26. BOOST_AUTO_LINK_SYSTEM: Specifies that we link to libraries built with the --layout=system option.
  27. This is essentially the same as the non-name-mangled version, but with
  28. the prefix to differentiate static and dll builds
  29. These macros will be undef'ed at the end of the header, further this header
  30. has no include guards - so be sure to include it only once from your library!
  31. Algorithm:
  32. ~~~~~~~~~~
  33. Libraries for Borland and Microsoft compilers are automatically
  34. selected here, the name of the lib is selected according to the following
  35. formula:
  36. BOOST_LIB_PREFIX
  37. + BOOST_LIB_NAME
  38. + "_"
  39. + BOOST_LIB_TOOLSET
  40. + BOOST_LIB_THREAD_OPT
  41. + BOOST_LIB_RT_OPT
  42. + BOOST_LIB_ARCH_AND_MODEL_OPT
  43. "-"
  44. + BOOST_LIB_VERSION
  45. These are defined as:
  46. BOOST_LIB_PREFIX: "lib" for static libraries otherwise "".
  47. BOOST_LIB_NAME: The base name of the lib ( for example boost_regex).
  48. BOOST_LIB_TOOLSET: The compiler toolset name (vc6, vc7, bcb5 etc).
  49. BOOST_LIB_THREAD_OPT: "-mt" for multithread builds, otherwise nothing.
  50. BOOST_LIB_RT_OPT: A suffix that indicates the runtime library used,
  51. contains one or more of the following letters after
  52. a hyphen:
  53. s static runtime (dynamic if not present).
  54. g debug/diagnostic runtime (release if not present).
  55. y Python debug/diagnostic runtime (release if not present).
  56. d debug build (release if not present).
  57. p STLport build.
  58. n STLport build without its IOStreams.
  59. BOOST_LIB_ARCH_AND_MODEL_OPT: The architecture and address model
  60. (-x32 or -x64 for x86/32 and x86/64 respectively)
  61. BOOST_LIB_VERSION: The Boost version, in the form x_y, for Boost version x.y.
  62. ***************************************************************************/
  63. #ifdef __cplusplus
  64. # ifndef BOOST_CONFIG_HPP
  65. # include <boost/config.hpp>
  66. # endif
  67. #elif defined(_MSC_VER) && !defined(__MWERKS__) && !defined(__EDG_VERSION__)
  68. //
  69. // C language compatability (no, honestly)
  70. //
  71. # define BOOST_MSVC _MSC_VER
  72. # define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X)
  73. # define BOOST_DO_STRINGIZE(X) #X
  74. #endif
  75. //
  76. // Only include what follows for known and supported compilers:
  77. //
  78. #if defined(BOOST_MSVC) \
  79. || defined(__BORLANDC__) \
  80. || (defined(__MWERKS__) && defined(_WIN32) && (__MWERKS__ >= 0x3000)) \
  81. || (defined(__ICL) && defined(_MSC_EXTENSIONS) && (_MSC_VER >= 1200)) \
  82. || (defined(BOOST_CLANG) && defined(BOOST_WINDOWS) && defined(_MSC_VER) && (__clang_major__ >= 4))
  83. #ifndef BOOST_VERSION_HPP
  84. # include <boost/version.hpp>
  85. #endif
  86. #ifndef BOOST_LIB_NAME
  87. # error "Macro BOOST_LIB_NAME not set (internal error)"
  88. #endif
  89. //
  90. // error check:
  91. //
  92. #if defined(__MSVC_RUNTIME_CHECKS) && !defined(_DEBUG)
  93. # pragma message("Using the /RTC option without specifying a debug runtime will lead to linker errors")
  94. # pragma message("Hint: go to the code generation options and switch to one of the debugging runtimes")
  95. # error "Incompatible build options"
  96. #endif
  97. //
  98. // select toolset if not defined already:
  99. //
  100. #ifndef BOOST_LIB_TOOLSET
  101. # if defined(BOOST_MSVC) && (BOOST_MSVC < 1200)
  102. // Note: no compilers before 1200 are supported
  103. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
  104. # ifdef UNDER_CE
  105. // eVC4:
  106. # define BOOST_LIB_TOOLSET "evc4"
  107. # else
  108. // vc6:
  109. # define BOOST_LIB_TOOLSET "vc6"
  110. # endif
  111. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1310)
  112. // vc7:
  113. # define BOOST_LIB_TOOLSET "vc7"
  114. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1400)
  115. // vc71:
  116. # define BOOST_LIB_TOOLSET "vc71"
  117. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1500)
  118. // vc80:
  119. # define BOOST_LIB_TOOLSET "vc80"
  120. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1600)
  121. // vc90:
  122. # define BOOST_LIB_TOOLSET "vc90"
  123. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1700)
  124. // vc10:
  125. # define BOOST_LIB_TOOLSET "vc100"
  126. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1800)
  127. // vc11:
  128. # define BOOST_LIB_TOOLSET "vc110"
  129. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1900)
  130. // vc12:
  131. # define BOOST_LIB_TOOLSET "vc120"
  132. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1910)
  133. // vc14:
  134. # define BOOST_LIB_TOOLSET "vc140"
  135. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1920)
  136. // vc14.1:
  137. # define BOOST_LIB_TOOLSET "vc141"
  138. # elif defined(BOOST_MSVC)
  139. // vc14.2:
  140. # define BOOST_LIB_TOOLSET "vc142"
  141. # elif defined(__BORLANDC__)
  142. // CBuilder 6:
  143. # define BOOST_LIB_TOOLSET "bcb"
  144. # elif defined(__ICL)
  145. // Intel C++, no version number:
  146. # define BOOST_LIB_TOOLSET "iw"
  147. # elif defined(__MWERKS__) && (__MWERKS__ <= 0x31FF )
  148. // Metrowerks CodeWarrior 8.x
  149. # define BOOST_LIB_TOOLSET "cw8"
  150. # elif defined(__MWERKS__) && (__MWERKS__ <= 0x32FF )
  151. // Metrowerks CodeWarrior 9.x
  152. # define BOOST_LIB_TOOLSET "cw9"
  153. # elif defined(BOOST_CLANG) && defined(BOOST_WINDOWS) && defined(_MSC_VER) && (__clang_major__ >= 4)
  154. // Clang on Windows
  155. # define BOOST_LIB_TOOLSET "clangw" BOOST_STRINGIZE(__clang_major__)
  156. # endif
  157. #endif // BOOST_LIB_TOOLSET
  158. //
  159. // select thread opt:
  160. //
  161. #if defined(_MT) || defined(__MT__)
  162. # define BOOST_LIB_THREAD_OPT "-mt"
  163. #else
  164. # define BOOST_LIB_THREAD_OPT
  165. #endif
  166. #if defined(_MSC_VER) || defined(__MWERKS__)
  167. # ifdef _DLL
  168. # if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS))
  169. # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
  170. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  171. # define BOOST_LIB_RT_OPT "-gydp"
  172. # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
  173. # define BOOST_LIB_RT_OPT "-gdp"
  174. # elif defined(_DEBUG)\
  175. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  176. # define BOOST_LIB_RT_OPT "-gydp"
  177. # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
  178. # error "Build options aren't compatible with pre-built libraries"
  179. # elif defined(_DEBUG)
  180. # define BOOST_LIB_RT_OPT "-gdp"
  181. # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
  182. # error "Build options aren't compatible with pre-built libraries"
  183. # else
  184. # define BOOST_LIB_RT_OPT "-p"
  185. # endif
  186. # elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
  187. # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
  188. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  189. # define BOOST_LIB_RT_OPT "-gydpn"
  190. # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
  191. # define BOOST_LIB_RT_OPT "-gdpn"
  192. # elif defined(_DEBUG)\
  193. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  194. # define BOOST_LIB_RT_OPT "-gydpn"
  195. # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
  196. # error "Build options aren't compatible with pre-built libraries"
  197. # elif defined(_DEBUG)
  198. # define BOOST_LIB_RT_OPT "-gdpn"
  199. # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
  200. # error "Build options aren't compatible with pre-built libraries"
  201. # else
  202. # define BOOST_LIB_RT_OPT "-pn"
  203. # endif
  204. # else
  205. # if defined(_DEBUG) && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  206. # define BOOST_LIB_RT_OPT "-gyd"
  207. # elif defined(_DEBUG)
  208. # define BOOST_LIB_RT_OPT "-gd"
  209. # else
  210. # define BOOST_LIB_RT_OPT
  211. # endif
  212. # endif
  213. # else
  214. # if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS))
  215. # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
  216. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  217. # define BOOST_LIB_RT_OPT "-sgydp"
  218. # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
  219. # define BOOST_LIB_RT_OPT "-sgdp"
  220. # elif defined(_DEBUG)\
  221. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  222. # define BOOST_LIB_RT_OPT "-sgydp"
  223. # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
  224. # error "Build options aren't compatible with pre-built libraries"
  225. # elif defined(_DEBUG)
  226. # define BOOST_LIB_RT_OPT "-sgdp"
  227. # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
  228. # error "Build options aren't compatible with pre-built libraries"
  229. # else
  230. # define BOOST_LIB_RT_OPT "-sp"
  231. # endif
  232. # elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
  233. # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
  234. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  235. # define BOOST_LIB_RT_OPT "-sgydpn"
  236. # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
  237. # define BOOST_LIB_RT_OPT "-sgdpn"
  238. # elif defined(_DEBUG)\
  239. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  240. # define BOOST_LIB_RT_OPT "-sgydpn"
  241. # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
  242. # error "Build options aren't compatible with pre-built libraries"
  243. # elif defined(_DEBUG)
  244. # define BOOST_LIB_RT_OPT "-sgdpn"
  245. # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
  246. # error "Build options aren't compatible with pre-built libraries"
  247. # else
  248. # define BOOST_LIB_RT_OPT "-spn"
  249. # endif
  250. # else
  251. # if defined(_DEBUG)\
  252. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  253. # define BOOST_LIB_RT_OPT "-sgyd"
  254. # elif defined(_DEBUG)
  255. # define BOOST_LIB_RT_OPT "-sgd"
  256. # else
  257. # define BOOST_LIB_RT_OPT "-s"
  258. # endif
  259. # endif
  260. # endif
  261. #elif defined(__BORLANDC__)
  262. //
  263. // figure out whether we want the debug builds or not:
  264. //
  265. #if __BORLANDC__ > 0x561
  266. #pragma defineonoption BOOST_BORLAND_DEBUG -v
  267. #endif
  268. //
  269. // sanity check:
  270. //
  271. #if defined(__STL_DEBUG) || defined(_STLP_DEBUG)
  272. #error "Pre-built versions of the Boost libraries are not provided in STLport-debug form"
  273. #endif
  274. # ifdef _RTLDLL
  275. # if defined(BOOST_BORLAND_DEBUG)\
  276. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  277. # define BOOST_LIB_RT_OPT "-yd"
  278. # elif defined(BOOST_BORLAND_DEBUG)
  279. # define BOOST_LIB_RT_OPT "-d"
  280. # elif defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  281. # define BOOST_LIB_RT_OPT -y
  282. # else
  283. # define BOOST_LIB_RT_OPT
  284. # endif
  285. # else
  286. # if defined(BOOST_BORLAND_DEBUG)\
  287. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  288. # define BOOST_LIB_RT_OPT "-syd"
  289. # elif defined(BOOST_BORLAND_DEBUG)
  290. # define BOOST_LIB_RT_OPT "-sd"
  291. # elif defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  292. # define BOOST_LIB_RT_OPT "-sy"
  293. # else
  294. # define BOOST_LIB_RT_OPT "-s"
  295. # endif
  296. # endif
  297. #endif
  298. //
  299. // BOOST_LIB_ARCH_AND_MODEL_OPT
  300. //
  301. #if defined( _M_IX86 )
  302. # define BOOST_LIB_ARCH_AND_MODEL_OPT "-x32"
  303. #elif defined( _M_X64 )
  304. # define BOOST_LIB_ARCH_AND_MODEL_OPT "-x64"
  305. #elif defined( _M_ARM )
  306. # define BOOST_LIB_ARCH_AND_MODEL_OPT "-a32"
  307. #elif defined( _M_ARM64 )
  308. # define BOOST_LIB_ARCH_AND_MODEL_OPT "-a64"
  309. #endif
  310. //
  311. // select linkage opt:
  312. //
  313. #if (defined(_DLL) || defined(_RTLDLL)) && defined(BOOST_DYN_LINK)
  314. # define BOOST_LIB_PREFIX
  315. #elif defined(BOOST_DYN_LINK)
  316. # error "Mixing a dll boost library with a static runtime is a really bad idea..."
  317. #else
  318. # define BOOST_LIB_PREFIX "lib"
  319. #endif
  320. //
  321. // now include the lib:
  322. //
  323. #if defined(BOOST_LIB_NAME) \
  324. && defined(BOOST_LIB_PREFIX) \
  325. && defined(BOOST_LIB_TOOLSET) \
  326. && defined(BOOST_LIB_THREAD_OPT) \
  327. && defined(BOOST_LIB_RT_OPT) \
  328. && defined(BOOST_LIB_ARCH_AND_MODEL_OPT) \
  329. && defined(BOOST_LIB_VERSION)
  330. #ifdef BOOST_AUTO_LINK_TAGGED
  331. # pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_ARCH_AND_MODEL_OPT ".lib")
  332. # ifdef BOOST_LIB_DIAGNOSTIC
  333. # pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_ARCH_AND_MODEL_OPT ".lib")
  334. # endif
  335. #elif defined(BOOST_AUTO_LINK_SYSTEM)
  336. # pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib")
  337. # ifdef BOOST_LIB_DIAGNOSTIC
  338. # pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib")
  339. # endif
  340. #elif defined(BOOST_AUTO_LINK_NOMANGLE)
  341. # pragma comment(lib, BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib")
  342. # ifdef BOOST_LIB_DIAGNOSTIC
  343. # pragma message ("Linking to lib file: " BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib")
  344. # endif
  345. #elif defined(BOOST_LIB_BUILDID)
  346. # pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_ARCH_AND_MODEL_OPT "-" BOOST_LIB_VERSION "-" BOOST_STRINGIZE(BOOST_LIB_BUILDID) ".lib")
  347. # ifdef BOOST_LIB_DIAGNOSTIC
  348. # pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_ARCH_AND_MODEL_OPT "-" BOOST_LIB_VERSION "-" BOOST_STRINGIZE(BOOST_LIB_BUILDID) ".lib")
  349. # endif
  350. #else
  351. # pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_ARCH_AND_MODEL_OPT "-" BOOST_LIB_VERSION ".lib")
  352. # ifdef BOOST_LIB_DIAGNOSTIC
  353. # pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_ARCH_AND_MODEL_OPT "-" BOOST_LIB_VERSION ".lib")
  354. # endif
  355. #endif
  356. #else
  357. # error "some required macros where not defined (internal logic error)."
  358. #endif
  359. #endif // _MSC_VER || __BORLANDC__
  360. //
  361. // finally undef any macros we may have set:
  362. //
  363. #ifdef BOOST_LIB_PREFIX
  364. # undef BOOST_LIB_PREFIX
  365. #endif
  366. #if defined(BOOST_LIB_NAME)
  367. # undef BOOST_LIB_NAME
  368. #endif
  369. // Don't undef this one: it can be set by the user and should be the
  370. // same for all libraries:
  371. //#if defined(BOOST_LIB_TOOLSET)
  372. //# undef BOOST_LIB_TOOLSET
  373. //#endif
  374. #if defined(BOOST_LIB_THREAD_OPT)
  375. # undef BOOST_LIB_THREAD_OPT
  376. #endif
  377. #if defined(BOOST_LIB_RT_OPT)
  378. # undef BOOST_LIB_RT_OPT
  379. #endif
  380. #if defined(BOOST_LIB_ARCH_AND_MODEL_OPT)
  381. # undef BOOST_LIB_ARCH_AND_MODEL_OPT
  382. #endif
  383. #if defined(BOOST_LIB_LINK_OPT)
  384. # undef BOOST_LIB_LINK_OPT
  385. #endif
  386. #if defined(BOOST_LIB_DEBUG_OPT)
  387. # undef BOOST_LIB_DEBUG_OPT
  388. #endif
  389. #if defined(BOOST_DYN_LINK)
  390. # undef BOOST_DYN_LINK
  391. #endif