auto_link.hpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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. #ifndef BOOST_VERSION_HPP
  83. # include <boost/version.hpp>
  84. #endif
  85. #ifndef BOOST_LIB_NAME
  86. # error "Macro BOOST_LIB_NAME not set (internal error)"
  87. #endif
  88. //
  89. // error check:
  90. //
  91. #if defined(__MSVC_RUNTIME_CHECKS) && !defined(_DEBUG)
  92. # pragma message("Using the /RTC option without specifying a debug runtime will lead to linker errors")
  93. # pragma message("Hint: go to the code generation options and switch to one of the debugging runtimes")
  94. # error "Incompatible build options"
  95. #endif
  96. //
  97. // select toolset if not defined already:
  98. //
  99. #ifndef BOOST_LIB_TOOLSET
  100. # if defined(BOOST_MSVC) && (BOOST_MSVC < 1200)
  101. // Note: no compilers before 1200 are supported
  102. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
  103. # ifdef UNDER_CE
  104. // eVC4:
  105. # define BOOST_LIB_TOOLSET "evc4"
  106. # else
  107. // vc6:
  108. # define BOOST_LIB_TOOLSET "vc6"
  109. # endif
  110. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1310)
  111. // vc7:
  112. # define BOOST_LIB_TOOLSET "vc7"
  113. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1400)
  114. // vc71:
  115. # define BOOST_LIB_TOOLSET "vc71"
  116. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1500)
  117. // vc80:
  118. # define BOOST_LIB_TOOLSET "vc80"
  119. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1600)
  120. // vc90:
  121. # define BOOST_LIB_TOOLSET "vc90"
  122. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1700)
  123. // vc10:
  124. # define BOOST_LIB_TOOLSET "vc100"
  125. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1800)
  126. // vc11:
  127. # define BOOST_LIB_TOOLSET "vc110"
  128. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1900)
  129. // vc12:
  130. # define BOOST_LIB_TOOLSET "vc120"
  131. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1910)
  132. // vc14:
  133. # define BOOST_LIB_TOOLSET "vc140"
  134. # elif defined(BOOST_MSVC) && (BOOST_MSVC < 1920)
  135. // vc14.1:
  136. # define BOOST_LIB_TOOLSET "vc141"
  137. # elif defined(BOOST_MSVC)
  138. // vc14.2:
  139. # define BOOST_LIB_TOOLSET "vc142"
  140. # elif defined(__BORLANDC__)
  141. // CBuilder 6:
  142. # define BOOST_LIB_TOOLSET "bcb"
  143. # elif defined(__ICL)
  144. // Intel C++, no version number:
  145. # define BOOST_LIB_TOOLSET "iw"
  146. # elif defined(__MWERKS__) && (__MWERKS__ <= 0x31FF )
  147. // Metrowerks CodeWarrior 8.x
  148. # define BOOST_LIB_TOOLSET "cw8"
  149. # elif defined(__MWERKS__) && (__MWERKS__ <= 0x32FF )
  150. // Metrowerks CodeWarrior 9.x
  151. # define BOOST_LIB_TOOLSET "cw9"
  152. # endif
  153. #endif // BOOST_LIB_TOOLSET
  154. //
  155. // select thread opt:
  156. //
  157. #if defined(_MT) || defined(__MT__)
  158. # define BOOST_LIB_THREAD_OPT "-mt"
  159. #else
  160. # define BOOST_LIB_THREAD_OPT
  161. #endif
  162. #if defined(_MSC_VER) || defined(__MWERKS__)
  163. # ifdef _DLL
  164. # if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS))
  165. # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
  166. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  167. # define BOOST_LIB_RT_OPT "-gydp"
  168. # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
  169. # define BOOST_LIB_RT_OPT "-gdp"
  170. # elif defined(_DEBUG)\
  171. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  172. # define BOOST_LIB_RT_OPT "-gydp"
  173. # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
  174. # error "Build options aren't compatible with pre-built libraries"
  175. # elif defined(_DEBUG)
  176. # define BOOST_LIB_RT_OPT "-gdp"
  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. # else
  180. # define BOOST_LIB_RT_OPT "-p"
  181. # endif
  182. # elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
  183. # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
  184. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  185. # define BOOST_LIB_RT_OPT "-gydpn"
  186. # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
  187. # define BOOST_LIB_RT_OPT "-gdpn"
  188. # elif defined(_DEBUG)\
  189. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  190. # define BOOST_LIB_RT_OPT "-gydpn"
  191. # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
  192. # error "Build options aren't compatible with pre-built libraries"
  193. # elif defined(_DEBUG)
  194. # define BOOST_LIB_RT_OPT "-gdpn"
  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. # else
  198. # define BOOST_LIB_RT_OPT "-pn"
  199. # endif
  200. # else
  201. # if defined(_DEBUG) && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  202. # define BOOST_LIB_RT_OPT "-gyd"
  203. # elif defined(_DEBUG)
  204. # define BOOST_LIB_RT_OPT "-gd"
  205. # else
  206. # define BOOST_LIB_RT_OPT
  207. # endif
  208. # endif
  209. # else
  210. # if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS))
  211. # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
  212. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  213. # define BOOST_LIB_RT_OPT "-sgydp"
  214. # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
  215. # define BOOST_LIB_RT_OPT "-sgdp"
  216. # elif defined(_DEBUG)\
  217. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  218. # define BOOST_LIB_RT_OPT "-sgydp"
  219. # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
  220. # error "Build options aren't compatible with pre-built libraries"
  221. # elif defined(_DEBUG)
  222. # define BOOST_LIB_RT_OPT "-sgdp"
  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. # else
  226. # define BOOST_LIB_RT_OPT "-sp"
  227. # endif
  228. # elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
  229. # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
  230. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  231. # define BOOST_LIB_RT_OPT "-sgydpn"
  232. # elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
  233. # define BOOST_LIB_RT_OPT "-sgdpn"
  234. # elif defined(_DEBUG)\
  235. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  236. # define BOOST_LIB_RT_OPT "-sgydpn"
  237. # pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
  238. # error "Build options aren't compatible with pre-built libraries"
  239. # elif defined(_DEBUG)
  240. # define BOOST_LIB_RT_OPT "-sgdpn"
  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. # else
  244. # define BOOST_LIB_RT_OPT "-spn"
  245. # endif
  246. # else
  247. # if defined(_DEBUG)\
  248. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  249. # define BOOST_LIB_RT_OPT "-sgyd"
  250. # elif defined(_DEBUG)
  251. # define BOOST_LIB_RT_OPT "-sgd"
  252. # else
  253. # define BOOST_LIB_RT_OPT "-s"
  254. # endif
  255. # endif
  256. # endif
  257. #elif defined(__BORLANDC__)
  258. //
  259. // figure out whether we want the debug builds or not:
  260. //
  261. #if __BORLANDC__ > 0x561
  262. #pragma defineonoption BOOST_BORLAND_DEBUG -v
  263. #endif
  264. //
  265. // sanity check:
  266. //
  267. #if defined(__STL_DEBUG) || defined(_STLP_DEBUG)
  268. #error "Pre-built versions of the Boost libraries are not provided in STLport-debug form"
  269. #endif
  270. # ifdef _RTLDLL
  271. # if defined(BOOST_BORLAND_DEBUG)\
  272. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  273. # define BOOST_LIB_RT_OPT "-yd"
  274. # elif defined(BOOST_BORLAND_DEBUG)
  275. # define BOOST_LIB_RT_OPT "-d"
  276. # elif defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  277. # define BOOST_LIB_RT_OPT -y
  278. # else
  279. # define BOOST_LIB_RT_OPT
  280. # endif
  281. # else
  282. # if defined(BOOST_BORLAND_DEBUG)\
  283. && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  284. # define BOOST_LIB_RT_OPT "-syd"
  285. # elif defined(BOOST_BORLAND_DEBUG)
  286. # define BOOST_LIB_RT_OPT "-sd"
  287. # elif defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
  288. # define BOOST_LIB_RT_OPT "-sy"
  289. # else
  290. # define BOOST_LIB_RT_OPT "-s"
  291. # endif
  292. # endif
  293. #endif
  294. //
  295. // BOOST_LIB_ARCH_AND_MODEL_OPT
  296. //
  297. #if defined( _M_IX86 )
  298. # define BOOST_LIB_ARCH_AND_MODEL_OPT "-x32"
  299. #elif defined( _M_X64 )
  300. # define BOOST_LIB_ARCH_AND_MODEL_OPT "-x64"
  301. #elif defined( _M_ARM )
  302. # define BOOST_LIB_ARCH_AND_MODEL_OPT "-a32"
  303. #elif defined( _M_ARM64 )
  304. # define BOOST_LIB_ARCH_AND_MODEL_OPT "-a64"
  305. #endif
  306. //
  307. // select linkage opt:
  308. //
  309. #if (defined(_DLL) || defined(_RTLDLL)) && defined(BOOST_DYN_LINK)
  310. # define BOOST_LIB_PREFIX
  311. #elif defined(BOOST_DYN_LINK)
  312. # error "Mixing a dll boost library with a static runtime is a really bad idea..."
  313. #else
  314. # define BOOST_LIB_PREFIX "lib"
  315. #endif
  316. //
  317. // now include the lib:
  318. //
  319. #if defined(BOOST_LIB_NAME) \
  320. && defined(BOOST_LIB_PREFIX) \
  321. && defined(BOOST_LIB_TOOLSET) \
  322. && defined(BOOST_LIB_THREAD_OPT) \
  323. && defined(BOOST_LIB_RT_OPT) \
  324. && defined(BOOST_LIB_ARCH_AND_MODEL_OPT) \
  325. && defined(BOOST_LIB_VERSION)
  326. #ifdef BOOST_AUTO_LINK_TAGGED
  327. # 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")
  328. # ifdef BOOST_LIB_DIAGNOSTIC
  329. # 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")
  330. # endif
  331. #elif defined(BOOST_AUTO_LINK_SYSTEM)
  332. # pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib")
  333. # ifdef BOOST_LIB_DIAGNOSTIC
  334. # pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib")
  335. # endif
  336. #elif defined(BOOST_AUTO_LINK_NOMANGLE)
  337. # pragma comment(lib, BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib")
  338. # ifdef BOOST_LIB_DIAGNOSTIC
  339. # pragma message ("Linking to lib file: " BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib")
  340. # endif
  341. #elif defined(BOOST_LIB_BUILDID)
  342. # 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")
  343. # ifdef BOOST_LIB_DIAGNOSTIC
  344. # 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")
  345. # endif
  346. #else
  347. # 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")
  348. # ifdef BOOST_LIB_DIAGNOSTIC
  349. # 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")
  350. # endif
  351. #endif
  352. #else
  353. # error "some required macros where not defined (internal logic error)."
  354. #endif
  355. #endif // _MSC_VER || __BORLANDC__
  356. //
  357. // finally undef any macros we may have set:
  358. //
  359. #ifdef BOOST_LIB_PREFIX
  360. # undef BOOST_LIB_PREFIX
  361. #endif
  362. #if defined(BOOST_LIB_NAME)
  363. # undef BOOST_LIB_NAME
  364. #endif
  365. // Don't undef this one: it can be set by the user and should be the
  366. // same for all libraries:
  367. //#if defined(BOOST_LIB_TOOLSET)
  368. //# undef BOOST_LIB_TOOLSET
  369. //#endif
  370. #if defined(BOOST_LIB_THREAD_OPT)
  371. # undef BOOST_LIB_THREAD_OPT
  372. #endif
  373. #if defined(BOOST_LIB_RT_OPT)
  374. # undef BOOST_LIB_RT_OPT
  375. #endif
  376. #if defined(BOOST_LIB_ARCH_AND_MODEL_OPT)
  377. # undef BOOST_LIB_ARCH_AND_MODEL_OPT
  378. #endif
  379. #if defined(BOOST_LIB_LINK_OPT)
  380. # undef BOOST_LIB_LINK_OPT
  381. #endif
  382. #if defined(BOOST_LIB_DEBUG_OPT)
  383. # undef BOOST_LIB_DEBUG_OPT
  384. #endif
  385. #if defined(BOOST_DYN_LINK)
  386. # undef BOOST_DYN_LINK
  387. #endif