auto_link.hpp 14 KB

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