aura  0.1
 All Data Structures Functions Variables Modules Pages
CMakeCXXCompilerId.cpp
1 /* This source file must have a .cpp extension so that all C++ compilers
2  recognize the extension without flags. Borland does not know .cxx for
3  example. */
4 #ifndef __cplusplus
5 # error "A C compiler has been selected for C++."
6 #endif
7 
8 /* Version number components: V=Version, R=Revision, P=Patch
9  Version date components: YYYY=Year, MM=Month, DD=Day */
10 
11 #if defined(__COMO__)
12 # define COMPILER_ID "Comeau"
13  /* __COMO_VERSION__ = VRR */
14 # define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100)
15 # define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100)
16 
17 #elif defined(__INTEL_COMPILER) || defined(__ICC)
18 # define COMPILER_ID "Intel"
19  /* __INTEL_COMPILER = VRP */
20 # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
21 # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
22 # if defined(__INTEL_COMPILER_UPDATE)
23 # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
24 # else
25 # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
26 # endif
27 # if defined(__INTEL_COMPILER_BUILD_DATE)
28  /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
29 # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
30 # endif
31 # if defined(_MSC_VER)
32 # define SIMULATE_ID "MSVC"
33  /* _MSC_VER = VVRR */
34 # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
35 # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
36 # endif
37 
38 #elif defined(__PATHCC__)
39 # define COMPILER_ID "PathScale"
40 # define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
41 # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
42 # if defined(__PATHCC_PATCHLEVEL__)
43 # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
44 # endif
45 
46 #elif defined(__clang__)
47 # if defined(__apple_build_version__)
48 # define COMPILER_ID "AppleClang"
49 # define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
50 # else
51 # define COMPILER_ID "Clang"
52 # endif
53 # define COMPILER_VERSION_MAJOR DEC(__clang_major__)
54 # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
55 # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
56 # if defined(_MSC_VER)
57 # define SIMULATE_ID "MSVC"
58  /* _MSC_VER = VVRR */
59 # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
60 # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
61 # endif
62 
63 #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
64 # define COMPILER_ID "Embarcadero"
65 # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
66 # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
67 # define COMPILER_VERSION_PATCH HEX(__CODEGEARC_VERSION__ & 0xFFFF)
68 
69 #elif defined(__BORLANDC__)
70 # define COMPILER_ID "Borland"
71  /* __BORLANDC__ = 0xVRR */
72 # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
73 # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
74 
75 #elif defined(__WATCOMC__)
76 # define COMPILER_ID "Watcom"
77  /* __WATCOMC__ = VVRR */
78 # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
79 # define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100)
80 
81 #elif defined(__SUNPRO_CC)
82 # define COMPILER_ID "SunPro"
83 # if __SUNPRO_CC >= 0x5100
84  /* __SUNPRO_CC = 0xVRRP */
85 # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12)
86 # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF)
87 # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
88 # else
89  /* __SUNPRO_CC = 0xVRP */
90 # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8)
91 # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF)
92 # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
93 # endif
94 
95 #elif defined(__HP_aCC)
96 # define COMPILER_ID "HP"
97  /* __HP_aCC = VVRRPP */
98 # define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000)
99 # define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100)
100 # define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100)
101 
102 #elif defined(__DECCXX)
103 # define COMPILER_ID "Compaq"
104  /* __DECCXX_VER = VVRRTPPPP */
105 # define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000)
106 # define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100)
107 # define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000)
108 
109 #elif defined(__IBMCPP__)
110 # if defined(__COMPILER_VER__)
111 # define COMPILER_ID "zOS"
112 # else
113 # if __IBMCPP__ >= 800
114 # define COMPILER_ID "XL"
115 # else
116 # define COMPILER_ID "VisualAge"
117 # endif
118  /* __IBMCPP__ = VRP */
119 # define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
120 # define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
121 # define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
122 # endif
123 
124 #elif defined(__PGI)
125 # define COMPILER_ID "PGI"
126 # define COMPILER_VERSION_MAJOR DEC(__PGIC__)
127 # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
128 # if defined(__PGIC_PATCHLEVEL__)
129 # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
130 # endif
131 
132 #elif defined(_CRAYC)
133 # define COMPILER_ID "Cray"
134 # define COMPILER_VERSION_MAJOR DEC(_RELEASE)
135 # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
136 
137 #elif defined(__TI_COMPILER_VERSION__)
138 # define COMPILER_ID "TI"
139  /* __TI_COMPILER_VERSION__ = VVVRRRPPP */
140 # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
141 # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
142 # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
143 
144 #elif defined(__SCO_VERSION__)
145 # define COMPILER_ID "SCO"
146 
147 #elif defined(__GNUC__)
148 # define COMPILER_ID "GNU"
149 # define COMPILER_VERSION_MAJOR DEC(__GNUC__)
150 # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
151 # if defined(__GNUC_PATCHLEVEL__)
152 # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
153 # endif
154 
155 #elif defined(_MSC_VER)
156 # define COMPILER_ID "MSVC"
157  /* _MSC_VER = VVRR */
158 # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
159 # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
160 # if defined(_MSC_FULL_VER)
161 # if _MSC_VER >= 1400
162  /* _MSC_FULL_VER = VVRRPPPPP */
163 # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
164 # else
165  /* _MSC_FULL_VER = VVRRPPPP */
166 # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
167 # endif
168 # endif
169 # if defined(_MSC_BUILD)
170 # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
171 # endif
172 
173 /* Analog VisualDSP++ >= 4.5.6 */
174 #elif defined(__VISUALDSPVERSION__)
175 # define COMPILER_ID "ADSP"
176  /* __VISUALDSPVERSION__ = 0xVVRRPP00 */
177 # define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
178 # define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
179 # define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
180 
181 /* Analog VisualDSP++ < 4.5.6 */
182 #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
183 # define COMPILER_ID "ADSP"
184 
185 /* IAR Systems compiler for embedded systems.
186  http://www.iar.com */
187 #elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC)
188 # define COMPILER_ID "IAR"
189 
190 #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
191 # define COMPILER_ID "MIPSpro"
192 # if defined(_SGI_COMPILER_VERSION)
193  /* _SGI_COMPILER_VERSION = VRP */
194 # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
195 # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
196 # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10)
197 # else
198  /* _COMPILER_VERSION = VRP */
199 # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
200 # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
201 # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10)
202 # endif
203 
204 /* This compiler is either not known or is too old to define an
205  identification macro. Try to identify the platform and guess that
206  it is the native compiler. */
207 #elif defined(__sgi)
208 # define COMPILER_ID "MIPSpro"
209 
210 #elif defined(__hpux) || defined(__hpua)
211 # define COMPILER_ID "HP"
212 
213 #else /* unknown compiler */
214 # define COMPILER_ID ""
215 
216 #endif
217 
218 /* Construct the string literal in pieces to prevent the source from
219  getting matched. Store it in a pointer rather than an array
220  because some compilers will just produce instructions to fill the
221  array rather than assigning a pointer to a static array. */
222 char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
223 #ifdef SIMULATE_ID
224 char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
225 #endif
226 
227 #ifdef __QNXNTO__
228 char const* qnxnto = "INFO" ":" "qnxnto";
229 #endif
230 
231 /* Identify known platforms by name. */
232 #if defined(__linux) || defined(__linux__) || defined(linux)
233 # define PLATFORM_ID "Linux"
234 
235 #elif defined(__CYGWIN__)
236 # define PLATFORM_ID "Cygwin"
237 
238 #elif defined(__MINGW32__)
239 # define PLATFORM_ID "MinGW"
240 
241 #elif defined(__APPLE__)
242 # define PLATFORM_ID "Darwin"
243 
244 #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
245 # define PLATFORM_ID "Windows"
246 
247 #elif defined(__FreeBSD__) || defined(__FreeBSD)
248 # define PLATFORM_ID "FreeBSD"
249 
250 #elif defined(__NetBSD__) || defined(__NetBSD)
251 # define PLATFORM_ID "NetBSD"
252 
253 #elif defined(__OpenBSD__) || defined(__OPENBSD)
254 # define PLATFORM_ID "OpenBSD"
255 
256 #elif defined(__sun) || defined(sun)
257 # define PLATFORM_ID "SunOS"
258 
259 #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
260 # define PLATFORM_ID "AIX"
261 
262 #elif defined(__sgi) || defined(__sgi__) || defined(_SGI)
263 # define PLATFORM_ID "IRIX"
264 
265 #elif defined(__hpux) || defined(__hpux__)
266 # define PLATFORM_ID "HP-UX"
267 
268 #elif defined(__HAIKU__)
269 # define PLATFORM_ID "Haiku"
270 
271 #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
272 # define PLATFORM_ID "BeOS"
273 
274 #elif defined(__QNX__) || defined(__QNXNTO__)
275 # define PLATFORM_ID "QNX"
276 
277 #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
278 # define PLATFORM_ID "Tru64"
279 
280 #elif defined(__riscos) || defined(__riscos__)
281 # define PLATFORM_ID "RISCos"
282 
283 #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
284 # define PLATFORM_ID "SINIX"
285 
286 #elif defined(__UNIX_SV__)
287 # define PLATFORM_ID "UNIX_SV"
288 
289 #elif defined(__bsdos__)
290 # define PLATFORM_ID "BSDOS"
291 
292 #elif defined(_MPRAS) || defined(MPRAS)
293 # define PLATFORM_ID "MP-RAS"
294 
295 #elif defined(__osf) || defined(__osf__)
296 # define PLATFORM_ID "OSF1"
297 
298 #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
299 # define PLATFORM_ID "SCO_SV"
300 
301 #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
302 # define PLATFORM_ID "ULTRIX"
303 
304 #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
305 # define PLATFORM_ID "Xenix"
306 
307 #else /* unknown platform */
308 # define PLATFORM_ID ""
309 
310 #endif
311 
312 /* For windows compilers MSVC and Intel we can determine
313  the architecture of the compiler being used. This is because
314  the compilers do not have flags that can change the architecture,
315  but rather depend on which compiler is being used
316 */
317 #if defined(_WIN32) && defined(_MSC_VER)
318 # if defined(_M_IA64)
319 # define ARCHITECTURE_ID "IA64"
320 
321 # elif defined(_M_X64) || defined(_M_AMD64)
322 # define ARCHITECTURE_ID "x64"
323 
324 # elif defined(_M_IX86)
325 # define ARCHITECTURE_ID "X86"
326 
327 # elif defined(_M_ARM)
328 # define ARCHITECTURE_ID "ARM"
329 
330 # elif defined(_M_MIPS)
331 # define ARCHITECTURE_ID "MIPS"
332 
333 # elif defined(_M_SH)
334 # define ARCHITECTURE_ID "SHx"
335 
336 # else /* unknown architecture */
337 # define ARCHITECTURE_ID ""
338 # endif
339 
340 #else
341 # define ARCHITECTURE_ID ""
342 #endif
343 
344 /* Convert integer to decimal digit literals. */
345 #define DEC(n) \
346  ('0' + (((n) / 10000000)%10)), \
347  ('0' + (((n) / 1000000)%10)), \
348  ('0' + (((n) / 100000)%10)), \
349  ('0' + (((n) / 10000)%10)), \
350  ('0' + (((n) / 1000)%10)), \
351  ('0' + (((n) / 100)%10)), \
352  ('0' + (((n) / 10)%10)), \
353  ('0' + ((n) % 10))
354 
355 /* Convert integer to hex digit literals. */
356 #define HEX(n) \
357  ('0' + ((n)>>28 & 0xF)), \
358  ('0' + ((n)>>24 & 0xF)), \
359  ('0' + ((n)>>20 & 0xF)), \
360  ('0' + ((n)>>16 & 0xF)), \
361  ('0' + ((n)>>12 & 0xF)), \
362  ('0' + ((n)>>8 & 0xF)), \
363  ('0' + ((n)>>4 & 0xF)), \
364  ('0' + ((n) & 0xF))
365 
366 /* Construct a string literal encoding the version number components. */
367 #ifdef COMPILER_VERSION_MAJOR
368 char const info_version[] = {
369  'I', 'N', 'F', 'O', ':',
370  'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
371  COMPILER_VERSION_MAJOR,
372 # ifdef COMPILER_VERSION_MINOR
373  '.', COMPILER_VERSION_MINOR,
374 # ifdef COMPILER_VERSION_PATCH
375  '.', COMPILER_VERSION_PATCH,
376 # ifdef COMPILER_VERSION_TWEAK
377  '.', COMPILER_VERSION_TWEAK,
378 # endif
379 # endif
380 # endif
381  ']','\0'};
382 #endif
383 
384 /* Construct a string literal encoding the version number components. */
385 #ifdef SIMULATE_VERSION_MAJOR
386 char const info_simulate_version[] = {
387  'I', 'N', 'F', 'O', ':',
388  's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
389  SIMULATE_VERSION_MAJOR,
390 # ifdef SIMULATE_VERSION_MINOR
391  '.', SIMULATE_VERSION_MINOR,
392 # ifdef SIMULATE_VERSION_PATCH
393  '.', SIMULATE_VERSION_PATCH,
394 # ifdef SIMULATE_VERSION_TWEAK
395  '.', SIMULATE_VERSION_TWEAK,
396 # endif
397 # endif
398 # endif
399  ']','\0'};
400 #endif
401 
402 /* Construct the string literal in pieces to prevent the source from
403  getting matched. Store it in a pointer rather than an array
404  because some compilers will just produce instructions to fill the
405  array rather than assigning a pointer to a static array. */
406 char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
407 char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
408 
409 
410 
411 
412 /*--------------------------------------------------------------------------*/
413 
414 int main(int argc, char* argv[])
415 {
416  int require = 0;
417  require += info_compiler[argc];
418  require += info_platform[argc];
419 #ifdef COMPILER_VERSION_MAJOR
420  require += info_version[argc];
421 #endif
422 #ifdef SIMULATE_ID
423  require += info_simulate[argc];
424 #endif
425 #ifdef SIMULATE_VERSION_MAJOR
426  require += info_simulate_version[argc];
427 #endif
428  (void)argv;
429  return require;
430 }