Statistics
| Branch: | Revision:

root / vision / build / CMakeFiles / CompilerIdCXX / CMakeCXXCompilerId.cpp @ 06738945

History | View | Annotate | Download (5.38 KB)

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
#if defined(__COMO__)
9
# define COMPILER_ID "Comeau"
10

    
11
#elif defined(__INTEL_COMPILER) || defined(__ICC)
12
# define COMPILER_ID "Intel"
13

    
14
#elif defined(__clang__)
15
# define COMPILER_ID "Clang"
16

    
17
#elif defined(__BORLANDC__)
18
# define COMPILER_ID "Borland"
19

    
20
#elif defined(__WATCOMC__)
21
# define COMPILER_ID "Watcom"
22

    
23
#elif defined(__SUNPRO_CC)
24
# define COMPILER_ID "SunPro"
25

    
26
#elif defined(__HP_aCC)
27
# define COMPILER_ID "HP"
28

    
29
#elif defined(__DECCXX)
30
# define COMPILER_ID "Compaq"
31

    
32
#elif defined(__IBMCPP__)
33
# if defined(__COMPILER_VER__)
34
#  define COMPILER_ID "zOS"
35
# elif __IBMCPP__ >= 800
36
#  define COMPILER_ID "XL"
37
# else
38
#  define COMPILER_ID "VisualAge"
39
# endif
40

    
41
#elif defined(__PGI)
42
# define COMPILER_ID "PGI"
43

    
44
#elif defined(__PATHSCALE__)
45
# define COMPILER_ID "PathScale"
46

    
47
#elif defined(__GNUC__)
48
# define COMPILER_ID "GNU"
49

    
50
#elif defined(_MSC_VER)
51
# define COMPILER_ID "MSVC"
52

    
53
#elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
54
/* Analog Devices C++ compiler for Blackfin, TigerSHARC and
55
   SHARC (21000) DSPs */
56
# define COMPILER_ID "ADSP"
57

    
58
#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
59
# define COMPILER_ID "MIPSpro"
60

    
61
/* This compiler is either not known or is too old to define an
62
   identification macro.  Try to identify the platform and guess that
63
   it is the native compiler.  */
64
#elif defined(__sgi)
65
# define COMPILER_ID "MIPSpro"
66

    
67
#elif defined(__hpux) || defined(__hpua)
68
# define COMPILER_ID "HP"
69

    
70
#else /* unknown compiler */
71
# define COMPILER_ID ""
72

    
73
#endif
74

    
75
/* Construct the string literal in pieces to prevent the source from
76
   getting matched.  Store it in a pointer rather than an array
77
   because some compilers will just produce instructions to fill the
78
   array rather than assigning a pointer to a static array.  */
79
char* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
80

    
81
/* Identify known platforms by name.  */
82
#if defined(__linux) || defined(__linux__) || defined(linux)
83
# define PLATFORM_ID "Linux"
84

    
85
#elif defined(__CYGWIN__)
86
# define PLATFORM_ID "Cygwin"
87

    
88
#elif defined(__MINGW32__)
89
# define PLATFORM_ID "MinGW"
90

    
91
#elif defined(__APPLE__)
92
# define PLATFORM_ID "Darwin"
93

    
94
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
95
# define PLATFORM_ID "Windows"
96

    
97
#elif defined(__FreeBSD__) || defined(__FreeBSD)
98
# define PLATFORM_ID "FreeBSD"
99

    
100
#elif defined(__NetBSD__) || defined(__NetBSD)
101
# define PLATFORM_ID "NetBSD"
102

    
103
#elif defined(__OpenBSD__) || defined(__OPENBSD)
104
# define PLATFORM_ID "OpenBSD"
105

    
106
#elif defined(__sun) || defined(sun)
107
# define PLATFORM_ID "SunOS"
108

    
109
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
110
# define PLATFORM_ID "AIX"
111

    
112
#elif defined(__sgi) || defined(__sgi__) || defined(_SGI)
113
# define PLATFORM_ID "IRIX"
114

    
115
#elif defined(__hpux) || defined(__hpux__)
116
# define PLATFORM_ID "HP-UX"
117

    
118
#elif defined(__HAIKU) || defined(__HAIKU__) || defined(_HAIKU)
119
# define PLATFORM_ID "Haiku"
120
/* Haiku also defines __BEOS__ so we must 
121
   put it prior to the check for __BEOS__
122
*/
123

    
124
#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
125
# define PLATFORM_ID "BeOS"
126

    
127
#elif defined(__QNX__) || defined(__QNXNTO__)
128
# define PLATFORM_ID "QNX"
129

    
130
#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
131
# define PLATFORM_ID "Tru64"
132

    
133
#elif defined(__riscos) || defined(__riscos__)
134
# define PLATFORM_ID "RISCos"
135

    
136
#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
137
# define PLATFORM_ID "SINIX"
138

    
139
#elif defined(__UNIX_SV__)
140
# define PLATFORM_ID "UNIX_SV"
141

    
142
#elif defined(__bsdos__)
143
# define PLATFORM_ID "BSDOS"
144

    
145
#elif defined(_MPRAS) || defined(MPRAS)
146
# define PLATFORM_ID "MP-RAS"
147

    
148
#elif defined(__osf) || defined(__osf__)
149
# define PLATFORM_ID "OSF1"
150

    
151
#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
152
# define PLATFORM_ID "SCO_SV"
153

    
154
#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
155
# define PLATFORM_ID "ULTRIX"
156

    
157
#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
158
# define PLATFORM_ID "Xenix"
159

    
160
#else /* unknown platform */
161
# define PLATFORM_ID ""
162

    
163
#endif
164

    
165
/* For windows compilers MSVC and Intel we can determine
166
   the architecture of the compiler being used.  This is becase
167
   the compilers do not have flags that can change the architecture,
168
   but rather depend on which compiler is being used
169
*/
170
#if defined(_WIN32) && defined(_MSC_VER)
171
# if defined(_M_IA64)
172
#  define ARCHITECTURE_ID "IA64"
173

    
174
# elif defined(_M_X64) || defined(_M_AMD64)
175
#  define ARCHITECTURE_ID "x64" 
176

    
177
# elif defined(_M_IX86)
178
#  define ARCHITECTURE_ID "X86"
179

    
180
# else /* unknown architecture */
181
#  define ARCHITECTURE_ID ""
182
# endif
183

    
184
#else
185
#  define ARCHITECTURE_ID ""
186
#endif
187

    
188
/* Construct the string literal in pieces to prevent the source from
189
   getting matched.  Store it in a pointer rather than an array
190
   because some compilers will just produce instructions to fill the
191
   array rather than assigning a pointer to a static array.  */
192
char* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
193
char* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
194

    
195

    
196

    
197
/*--------------------------------------------------------------------------*/
198

    
199
int main(int argc, char* argv[])
200
{
201
  int require = 0;
202
  require += info_compiler[argc];
203
  require += info_platform[argc];
204
  (void)argv;
205
  return require;
206
}