Blender  V3.3
build_config.h
Go to the documentation of this file.
1 // Copyright (c) 2020 libmv authors.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to
5 // deal in the Software without restriction, including without limitation the
6 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 // sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 // IN THE SOFTWARE.
20 
21 #ifndef LIBMV_BUILD_BUILD_CONFIG_H_
22 #define LIBMV_BUILD_BUILD_CONFIG_H_
23 
24 #include <climits>
25 #include <cstdint>
26 
27 // Initially is based on Chromium's build_config.h, with tweaks and extensions
28 // needed for this project.
29 //
30 // NOTE: All commonly used symbols (which are checked on a "top" level, from
31 // outside of any platform-specific ifdef block) are to be explicitly defined
32 // to 0 when they are not "active". This is extra lines of code in this file,
33 // but is not being edited that often. Such approach helps catching cases when
34 // one attempted to access build configuration variable without including the
35 // header by simply using -Wundef compiler attribute.
36 //
37 // NOTE: Not having things explicitly defined to 0 is harmless (in terms it
38 // follows same rules as Google projects) and will simply cause compiler to
39 // become more noisy, which is simple to correct.
40 
42 // A set of macros to use for platform detection.
43 
44 #if defined(__native_client__)
45 // __native_client__ must be first, so that other OS_ defines are not set.
46 # define OS_NACL 1
47 // OS_NACL comes in two sandboxing technology flavors, SFI or Non-SFI.
48 // PNaCl toolchain defines __native_client_nonsfi__ macro in Non-SFI build
49 // mode, while it does not in SFI build mode.
50 # if defined(__native_client_nonsfi__)
51 # define OS_NACL_NONSFI
52 # else
53 # define OS_NACL_SFI
54 # endif
55 #elif defined(_AIX)
56 # define OS_AIX 1
57 #elif defined(ANDROID)
58 # define OS_ANDROID 1
59 #elif defined(__APPLE__)
60 // Only include TargetConditions after testing ANDROID as some android builds
61 // on mac don't have this header available and it's not needed unless the target
62 // is really mac/ios.
63 # include <TargetConditionals.h>
64 # define OS_MACOSX 1
65 # if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
66 # define OS_IOS 1
67 # endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
68 #elif defined(__HAIKU__)
69 # define OS_HAIKU 1
70 #elif defined(__hpux)
71 # define OS_HPUX 1
72 #elif defined(__linux__)
73 # define OS_LINUX 1
74 // Include a system header to pull in features.h for glibc/uclibc macros.
75 # include <unistd.h>
76 # if defined(__GLIBC__) && !defined(__UCLIBC__)
77 // We really are using glibc, not uClibc pretending to be glibc.
78 # define LIBC_GLIBC 1
79 # endif
80 #elif defined(__sgi)
81 # define OS_IRIX 1
82 #elif defined(_WIN32)
83 # define OS_WIN 1
84 #elif defined(__Fuchsia__)
85 # define OS_FUCHSIA 1
86 #elif defined(__FreeBSD__)
87 # define OS_FREEBSD 1
88 #elif defined(__NetBSD__)
89 # define OS_NETBSD 1
90 #elif defined(__OpenBSD__)
91 # define OS_OPENBSD 1
92 #elif defined(__sun)
93 # define OS_SOLARIS 1
94 #elif defined(__QNXNTO__)
95 # define OS_QNX 1
96 #elif defined(__asmjs__) || defined(__wasm__)
97 # define OS_ASMJS
98 #else
99 # error Please add support for your platform in build/build_config.h
100 #endif
101 
102 #if !defined(OS_AIX)
103 # define OS_AIX 0
104 #endif
105 #if !defined(OS_ASMJS)
106 # define OS_ASMJS 0
107 #endif
108 #if !defined(OS_NACL)
109 # define OS_NACL 0
110 #endif
111 #if !defined(OS_NACL_NONSFI)
112 # define OS_NACL_NONSFI 0
113 #endif
114 #if !defined(OS_NACL_SFI)
115 # define OS_NACL_SFI 0
116 #endif
117 #if !defined(OS_ANDROID)
118 # define OS_ANDROID 0
119 #endif
120 #if !defined(OS_MACOSX)
121 # define OS_MACOSX 0
122 #endif
123 #if !defined(OS_IOS)
124 # define OS_IOS 0
125 #endif
126 #if !defined(OS_HAIKU)
127 # define OS_HAIKU 0
128 #endif
129 #if !defined(OS_HPUX)
130 # define OS_HPUX 0
131 #endif
132 #if !defined(OS_IRIX)
133 # define OS_IRIX 0
134 #endif
135 #if !defined(OS_LINUX)
136 # define OS_LINUX 0
137 #endif
138 #if !defined(LIBC_GLIBC)
139 # define LIBC_GLIBC 0
140 #endif
141 #if !defined(OS_WIN)
142 # define OS_WIN 0
143 #endif
144 #if !defined(OS_FUCHSIA)
145 # define OS_FUCHSIA 0
146 #endif
147 #if !defined(OS_FREEBSD)
148 # define OS_FREEBSD 0
149 #endif
150 #if !defined(OS_NETBSD)
151 # define OS_NETBSD 0
152 #endif
153 #if !defined(OS_OPENBSD)
154 # define OS_OPENBSD 0
155 #endif
156 #if !defined(OS_SOLARIS)
157 # define OS_SOLARIS 0
158 #endif
159 #if !defined(OS_QNX)
160 # define OS_QNX 0
161 #endif
162 
164 // Apple OS family detection.
165 
166 #if defined(OS_MAC) || defined(OS_IOS)
167 # define OS_APPLE 1
168 #else
169 # define OS_APPLE 0
170 #endif
171 
173 // *BSD OS family detection.
174 //
175 // For access to standard BSD features, use OS_BSD instead of a
176 // more specific macro.
177 
178 #if OS_FREEBSD || OS_OPENBSD || OS_NETBSD
179 # define OS_BSD 1
180 #else
181 # define OS_BSD 0
182 #endif
183 
185 // POSIX system detection.
186 //
187 // For access to standard POSIXish features use OS_POSIX instead of a
188 // more specific macro.
189 
190 #if OS_AIX || OS_ANDROID || OS_ASMJS || OS_FREEBSD || OS_LINUX || OS_MACOSX || \
191  OS_NACL || OS_NETBSD || OS_OPENBSD || OS_QNX || OS_SOLARIS
192 # define OS_POSIX 1
193 #else
194 # define OS_POSIX 0
195 #endif
196 
198 // Compiler detection, including its capabilities.
199 
200 #if defined(__clang__)
201 # define COMPILER_CLANG 1
202 #elif defined(__GNUC__)
203 # define COMPILER_GCC 1
204 # define COMPILER_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
205 #elif defined(_MSC_VER)
206 # define COMPILER_MSVC 1
207 # define COMPILER_MSVC_VERSION (_MSC_VER)
208 #elif defined(__MINGW32__)
209 # define COMPILER_MINGW32 1
210 #elif defined(__MINGW64__)
211 # define COMPILER_MINGW64 1
212 #else
213 # error Please add support for your compiler in build/build_config.h
214 #endif
215 
216 #if !defined(COMPILER_CLANG)
217 # define COMPILER_CLANG 0
218 #endif
219 #if !defined(COMPILER_GCC)
220 # define COMPILER_GCC 0
221 #endif
222 #if !defined(COMPILER_MSVC)
223 # define COMPILER_MSVC 0
224 #endif
225 #if !defined(COMPILER_MINGW32)
226 # define COMPILER_MINGW32 0
227 #endif
228 #if !defined(COMPILER_MINGW64)
229 # define COMPILER_MINGW64 0
230 #endif
231 
232 // Compiler is any of MinGW family.
233 #if COMPILER_MINGW32 || COMPILER_MINGW64
234 # define COMPILER_MINGW 1
235 #else
236 # define COMPILER_MINGW 0
237 #endif
238 
239 // Check what is the latest C++ specification the compiler supports.
240 //
241 // NOTE: Use explicit definition here to avoid expansion-to-defined warning from
242 // being generated. While this will most likely a false-positive warning in this
243 // particular case, that warning might be helpful to catch errors elsewhere.
244 
245 // C++11 check.
246 #if ((defined(__cplusplus) && (__cplusplus > 199711L)) || \
247  (defined(_MSC_VER) && (_MSC_VER >= 1800)))
248 # define COMPILER_SUPPORTS_CXX11 1
249 #else
250 # define COMPILER_SUPPORTS_CXX11 0
251 #endif
252 // C++14 check.
253 #if (defined(__cplusplus) && (__cplusplus > 201311L))
254 # define COMPILER_SUPPORTS_CXX14 1
255 #else
256 # define COMPILER_SUPPORTS_CXX14 0
257 #endif
258 // C++17 check.
259 #if (defined(__cplusplus) && (__cplusplus > 201611L))
260 # define COMPILER_SUPPORTS_CXX17 1
261 #else
262 # define COMPILER_SUPPORTS_CXX17 0
263 #endif
264 // C++20 check.
265 #if (defined(__cplusplus) && (__cplusplus > 201911L))
266 # define COMPILER_SUPPORTS_CXX20 1
267 #else
268 # define COMPILER_SUPPORTS_CXX20 0
269 #endif
270 
272 // Processor architecture detection.
273 //
274 // For more info on what's defined, see:
275 //
276 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx
277 // http://www.agner.org/optimize/calling_conventions.pdf
278 //
279 // or with gcc, run: "echo | gcc -E -dM -"
280 #if defined(_M_X64) || defined(__x86_64__)
281 # define ARCH_CPU_X86_FAMILY 1
282 # define ARCH_CPU_X86_64 1
283 # define ARCH_CPU_64_BITS 1
284 # define ARCH_CPU_LITTLE_ENDIAN 1
285 #elif defined(_M_IX86) || defined(__i386__)
286 # define ARCH_CPU_X86_FAMILY 1
287 # define ARCH_CPU_X86 1
288 # define ARCH_CPU_32_BITS 1
289 # define ARCH_CPU_LITTLE_ENDIAN 1
290 #elif defined(__s390x__)
291 # define ARCH_CPU_S390_FAMILY 1
292 # define ARCH_CPU_S390X 1
293 # define ARCH_CPU_64_BITS 1
294 # define ARCH_CPU_BIG_ENDIAN 1
295 #elif defined(__s390__)
296 # define ARCH_CPU_S390_FAMILY 1
297 # define ARCH_CPU_S390 1
298 # define ARCH_CPU_31_BITS 1
299 # define ARCH_CPU_BIG_ENDIAN 1
300 #elif (defined(__PPC64__) || defined(__PPC__)) && /* NOLINT */ \
301  defined(__BIG_ENDIAN__) // NOLINT
302 # define ARCH_CPU_PPC64_FAMILY 1
303 # define ARCH_CPU_PPC64 1
304 # define ARCH_CPU_64_BITS 1
305 # define ARCH_CPU_BIG_ENDIAN 1
306 #elif defined(__PPC64__)
307 # define ARCH_CPU_PPC64_FAMILY 1
308 # define ARCH_CPU_PPC64 1
309 # define ARCH_CPU_64_BITS 1
310 # define ARCH_CPU_LITTLE_ENDIAN 1
311 #elif defined(__ARMEL__)
312 # define ARCH_CPU_ARM_FAMILY 1
313 # define ARCH_CPU_ARMEL 1
314 # define ARCH_CPU_32_BITS 1
315 # define ARCH_CPU_LITTLE_ENDIAN 1
316 #elif defined(__aarch64__) || defined(_M_ARM64)
317 # define ARCH_CPU_ARM_FAMILY 1
318 # define ARCH_CPU_ARM64 1
319 # define ARCH_CPU_64_BITS 1
320 # define ARCH_CPU_LITTLE_ENDIAN 1
321 #elif defined(__pnacl__) || defined(__asmjs__) || defined(__wasm__)
322 # define ARCH_CPU_32_BITS 1
323 # define ARCH_CPU_LITTLE_ENDIAN 1
324 #elif defined(__MIPSEL__)
325 # if defined(__LP64__)
326 # define ARCH_CPU_MIPS_FAMILY 1
327 # define ARCH_CPU_MIPS64EL 1
328 # define ARCH_CPU_64_BITS 1
329 # define ARCH_CPU_LITTLE_ENDIAN 1
330 # else
331 # define ARCH_CPU_MIPS_FAMILY 1
332 # define ARCH_CPU_MIPSEL 1
333 # define ARCH_CPU_32_BITS 1
334 # define ARCH_CPU_LITTLE_ENDIAN 1
335 # endif
336 #elif defined(__MIPSEB__)
337 # if defined(__LP64__)
338 # define ARCH_CPU_MIPS_FAMILY 1
339 # define ARCH_CPU_MIPS64 1
340 # define ARCH_CPU_64_BITS 1
341 # define ARCH_CPU_BIG_ENDIAN 1
342 # else
343 # define ARCH_CPU_MIPS_FAMILY 1
344 # define ARCH_CPU_MIPS 1
345 # define ARCH_CPU_32_BITS 1
346 # define ARCH_CPU_BIG_ENDIAN 1
347 # endif
348 #else
349 # error Please add support for your architecture in build/build_config.h
350 #endif
351 
352 #if !defined(ARCH_CPU_LITTLE_ENDIAN)
353 # define ARCH_CPU_LITTLE_ENDIAN 0
354 #endif
355 #if !defined(ARCH_CPU_BIG_ENDIAN)
356 # define ARCH_CPU_BIG_ENDIAN 0
357 #endif
358 
359 #if !defined(ARCH_CPU_32_BITS)
360 # define ARCH_CPU_32_BITS 0
361 #endif
362 #if !defined(ARCH_CPU_64_BITS)
363 # define ARCH_CPU_64_BITS 0
364 #endif
365 
366 #if !defined(ARCH_CPU_X86_FAMILY)
367 # define ARCH_CPU_X86_FAMILY 0
368 #endif
369 #if !defined(ARCH_CPU_ARM_FAMILY)
370 # define ARCH_CPU_ARM_FAMILY 0
371 #endif
372 #if !defined(ARCH_CPU_MIPS_FAMILY)
373 # define ARCH_CPU_MIPS_FAMILY 0
374 #endif
375 #if !defined(ARCH_CPU_PPC64_FAMILY)
376 # define ARCH_CPU_PPC64_FAMILY 0
377 #endif
378 #if !defined(ARCH_CPU_S390_FAMILY)
379 # define ARCH_CPU_S390_FAMILY 0
380 #endif
381 
382 #endif // LIBMV_BUILD_BUILD_CONFIG_H_