Project

General

Profile

Statistics
| Branch: | Revision:

scoutos / scout / analog / build / CMakeFiles / CompilerIdC / CMakeCCompilerId.c @ a826ac0f

History | View | Annotate | Download (5.78 KB)

1 a826ac0f Dev Gurjar
#ifdef __cplusplus
2
# error "A C++ compiler has been selected for C."
3
#endif
4
5
#if defined(__18CXX)
6
# define ID_VOID_MAIN
7
#endif
8
9
#if defined(__INTEL_COMPILER) || defined(__ICC)
10
# define COMPILER_ID "Intel"
11
12
#elif defined(__clang__)
13
# define COMPILER_ID "Clang"
14
15
#elif defined(__BORLANDC__)
16
# define COMPILER_ID "Borland"
17
18
#elif defined(__WATCOMC__)
19
# define COMPILER_ID "Watcom"
20
21
#elif defined(__SUNPRO_C)
22
# define COMPILER_ID "SunPro"
23
24
#elif defined(__HP_cc)
25
# define COMPILER_ID "HP"
26
27
#elif defined(__DECC)
28
# define COMPILER_ID "Compaq"
29
30
#elif defined(__IBMC__)
31
# if defined(__COMPILER_VER__)
32
#  define COMPILER_ID "zOS"
33
# elif __IBMC__ >= 800
34
#  define COMPILER_ID "XL"
35
# else
36
#  define COMPILER_ID "VisualAge"
37
# endif
38
39
#elif defined(__PGI)
40
# define COMPILER_ID "PGI"
41
42
#elif defined(__PATHSCALE__)
43
# define COMPILER_ID "PathScale"
44
45
#elif defined(_CRAYC)
46
# define COMPILER_ID "Cray"
47
48
#elif defined(__TI_COMPILER_VERSION__)
49
# define COMPILER_ID "TI_DSP"
50
51
#elif defined(__SCO_VERSION__)
52
# define COMPILER_ID "SCO"
53
54
#elif defined(__GNUC__)
55
# define COMPILER_ID "GNU"
56
57
#elif defined(_MSC_VER)
58
# define COMPILER_ID "MSVC"
59
60
#elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
61
/* Analog Devices C++ compiler for Blackfin, TigerSHARC and
62
   SHARC (21000) DSPs */
63
# define COMPILER_ID "ADSP"
64
65
/* IAR Systems compiler for embedded systems.
66
   http://www.iar.com
67
   Not supported yet by CMake
68
#elif defined(__IAR_SYSTEMS_ICC__)
69
# define COMPILER_ID "IAR" */
70
71
/* sdcc, the small devices C compiler for embedded systems,
72
   http://sdcc.sourceforge.net  */
73
#elif defined(SDCC)
74
# define COMPILER_ID "SDCC"
75
76
#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
77
# define COMPILER_ID "MIPSpro"
78
79
/* This compiler is either not known or is too old to define an
80
   identification macro.  Try to identify the platform and guess that
81
   it is the native compiler.  */
82
#elif defined(__sgi)
83
# define COMPILER_ID "MIPSpro"
84
85
#elif defined(__hpux) || defined(__hpua)
86
# define COMPILER_ID "HP"
87
88
#else /* unknown compiler */
89
# define COMPILER_ID ""
90
91
#endif
92
93
/* Construct the string literal in pieces to prevent the source from
94
   getting matched.  Store it in a pointer rather than an array
95
   because some compilers will just produce instructions to fill the
96
   array rather than assigning a pointer to a static array.  */
97
char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
98
99
/* Identify known platforms by name.  */
100
#if defined(__linux) || defined(__linux__) || defined(linux)
101
# define PLATFORM_ID "Linux"
102
103
#elif defined(__CYGWIN__)
104
# define PLATFORM_ID "Cygwin"
105
106
#elif defined(__MINGW32__)
107
# define PLATFORM_ID "MinGW"
108
109
#elif defined(__APPLE__)
110
# define PLATFORM_ID "Darwin"
111
112
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
113
# define PLATFORM_ID "Windows"
114
115
#elif defined(__FreeBSD__) || defined(__FreeBSD)
116
# define PLATFORM_ID "FreeBSD"
117
118
#elif defined(__NetBSD__) || defined(__NetBSD)
119
# define PLATFORM_ID "NetBSD"
120
121
#elif defined(__OpenBSD__) || defined(__OPENBSD)
122
# define PLATFORM_ID "OpenBSD"
123
124
#elif defined(__sun) || defined(sun)
125
# define PLATFORM_ID "SunOS"
126
127
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
128
# define PLATFORM_ID "AIX"
129
130
#elif defined(__sgi) || defined(__sgi__) || defined(_SGI)
131
# define PLATFORM_ID "IRIX"
132
133
#elif defined(__hpux) || defined(__hpux__)
134
# define PLATFORM_ID "HP-UX"
135
136
#elif defined(__HAIKU) || defined(__HAIKU__) || defined(_HAIKU)
137
# define PLATFORM_ID "Haiku"
138
/* Haiku also defines __BEOS__ so we must 
139
   put it prior to the check for __BEOS__
140
*/
141
142
#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
143
# define PLATFORM_ID "BeOS"
144
145
#elif defined(__QNX__) || defined(__QNXNTO__)
146
# define PLATFORM_ID "QNX"
147
148
#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
149
# define PLATFORM_ID "Tru64"
150
151
#elif defined(__riscos) || defined(__riscos__)
152
# define PLATFORM_ID "RISCos"
153
154
#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
155
# define PLATFORM_ID "SINIX"
156
157
#elif defined(__UNIX_SV__)
158
# define PLATFORM_ID "UNIX_SV"
159
160
#elif defined(__bsdos__)
161
# define PLATFORM_ID "BSDOS"
162
163
#elif defined(_MPRAS) || defined(MPRAS)
164
# define PLATFORM_ID "MP-RAS"
165
166
#elif defined(__osf) || defined(__osf__)
167
# define PLATFORM_ID "OSF1"
168
169
#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
170
# define PLATFORM_ID "SCO_SV"
171
172
#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
173
# define PLATFORM_ID "ULTRIX"
174
175
#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
176
# define PLATFORM_ID "Xenix"
177
178
#else /* unknown platform */
179
# define PLATFORM_ID ""
180
181
#endif
182
183
/* For windows compilers MSVC and Intel we can determine
184
   the architecture of the compiler being used.  This is because
185
   the compilers do not have flags that can change the architecture,
186
   but rather depend on which compiler is being used
187
*/
188
#if defined(_WIN32) && defined(_MSC_VER)
189
# if defined(_M_IA64)
190
#  define ARCHITECTURE_ID "IA64"
191
192
# elif defined(_M_X64) || defined(_M_AMD64)
193
#  define ARCHITECTURE_ID "x64" 
194
195
# elif defined(_M_IX86)
196
#  define ARCHITECTURE_ID "X86"
197
198
# else /* unknown architecture */
199
#  define ARCHITECTURE_ID ""
200
# endif
201
202
#else
203
#  define ARCHITECTURE_ID ""
204
#endif
205
206
/* Construct the string literal in pieces to prevent the source from
207
   getting matched.  Store it in a pointer rather than an array
208
   because some compilers will just produce instructions to fill the
209
   array rather than assigning a pointer to a static array.  */
210
char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
211
char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
212
213
214
215
/*--------------------------------------------------------------------------*/
216
217
#ifdef ID_VOID_MAIN
218
void main() {}
219
#else
220
int main(int argc, char* argv[])
221
{
222
  int require = 0;
223
  require += info_compiler[argc];
224
  require += info_platform[argc];
225
  require += info_arch[argc];
226
  (void)argv;
227
  return require;
228
}
229
#endif