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