auto_link.hpp 15 KB

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