1/****************************************************************************
2**
3** Copyright (C) 2019 The Qt Company Ltd.
4** Copyright (C) 2019 Intel Corporation.
5** Contact: https://www.qt.io/licensing/
6**
7** This file is part of the QtCore module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial License Usage
11** Licensees holding valid commercial Qt licenses may use this file in
12** accordance with the commercial license agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and The Qt Company. For licensing terms
15** and conditions see https://www.qt.io/terms-conditions. For further
16** information use the contact form at https://www.qt.io/contact-us.
17**
18** GNU Lesser General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU Lesser
20** General Public License version 3 as published by the Free Software
21** Foundation and appearing in the file LICENSE.LGPL3 included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU Lesser General Public License version 3 requirements
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25**
26** GNU General Public License Usage
27** Alternatively, this file may be used under the terms of the GNU
28** General Public License version 2.0 or (at your option) the GNU General
29** Public license version 3 or any later version approved by the KDE Free
30** Qt Foundation. The licenses are as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32** included in the packaging of this file. Please review the following
33** information to ensure the GNU General Public License requirements will
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35** https://www.gnu.org/licenses/gpl-3.0.html.
36**
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41#ifndef QGLOBAL_H
42# include <QtCore/qglobal.h>
43#endif
44
45#ifndef QSYSTEMDETECTION_H
46#define QSYSTEMDETECTION_H
47
48/*
49 The operating system, must be one of: (Q_OS_x)
50
51 DARWIN - Any Darwin system (macOS, iOS, watchOS, tvOS)
52 MACOS - macOS
53 IOS - iOS
54 WATCHOS - watchOS
55 TVOS - tvOS
56 WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008)
57 WINRT - WinRT (Windows Runtime)
58 CYGWIN - Cygwin
59 SOLARIS - Sun Solaris
60 HPUX - HP-UX
61 LINUX - Linux [has variants]
62 FREEBSD - FreeBSD [has variants]
63 NETBSD - NetBSD
64 OPENBSD - OpenBSD
65 INTERIX - Interix
66 AIX - AIX
67 HURD - GNU Hurd
68 QNX - QNX [has variants]
69 QNX6 - QNX RTP 6.1
70 LYNX - LynxOS
71 BSD4 - Any BSD 4.4 system
72 UNIX - Any UNIX BSD/SYSV system
73 ANDROID - Android platform
74 HAIKU - Haiku
75 WEBOS - LG WebOS
76
77 The following operating systems have variants:
78 LINUX - both Q_OS_LINUX and Q_OS_ANDROID are defined when building for Android
79 - only Q_OS_LINUX is defined if building for other Linux systems
80 MACOS - both Q_OS_BSD4 and Q_OS_IOS are defined when building for iOS
81 - both Q_OS_BSD4 and Q_OS_MACOS are defined when building for macOS
82 FREEBSD - Q_OS_FREEBSD is defined only when building for FreeBSD with a BSD userland
83 - Q_OS_FREEBSD_KERNEL is always defined on FreeBSD, even if the userland is from GNU
84*/
85
86#if defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__))
87# include <TargetConditionals.h>
88# if defined(TARGET_OS_MAC) && TARGET_OS_MAC
89# define Q_OS_DARWIN
90# define Q_OS_BSD4
91# ifdef __LP64__
92# define Q_OS_DARWIN64
93# else
94# define Q_OS_DARWIN32
95# endif
96# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
97# define QT_PLATFORM_UIKIT
98# if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH
99# define Q_OS_WATCHOS
100# elif defined(TARGET_OS_TV) && TARGET_OS_TV
101# define Q_OS_TVOS
102# else
103# // TARGET_OS_IOS is only available in newer SDKs,
104# // so assume any other iOS-based platform is iOS for now
105# define Q_OS_IOS
106# endif
107# else
108# // TARGET_OS_OSX is only available in newer SDKs,
109# // so assume any non iOS-based platform is macOS for now
110# define Q_OS_MACOS
111# endif
112# else
113# error "Qt has not been ported to this Apple platform - see http://www.qt.io/developers"
114# endif
115#elif defined(__WEBOS__)
116# define Q_OS_WEBOS
117# define Q_OS_LINUX
118#elif defined(__ANDROID__) || defined(ANDROID)
119# define Q_OS_ANDROID
120# define Q_OS_LINUX
121#elif defined(__CYGWIN__)
122# define Q_OS_CYGWIN
123#elif !defined(SAG_COM) && (!defined(WINAPI_FAMILY) || WINAPI_FAMILY==WINAPI_FAMILY_DESKTOP_APP) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))
124# define Q_OS_WIN32
125# define Q_OS_WIN64
126#elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
127# if defined(WINAPI_FAMILY)
128# ifndef WINAPI_FAMILY_PC_APP
129# define WINAPI_FAMILY_PC_APP WINAPI_FAMILY_APP
130# endif
131# if defined(WINAPI_FAMILY_PHONE_APP) && WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP
132# define Q_OS_WINRT
133# elif WINAPI_FAMILY==WINAPI_FAMILY_PC_APP
134# define Q_OS_WINRT
135# else
136# define Q_OS_WIN32
137# endif
138# else
139# define Q_OS_WIN32
140# endif
141#elif defined(__sun) || defined(sun)
142# define Q_OS_SOLARIS
143#elif defined(hpux) || defined(__hpux)
144# define Q_OS_HPUX
145#elif defined(__native_client__)
146# define Q_OS_NACL
147#elif defined(__EMSCRIPTEN__)
148# define Q_OS_WASM
149#elif defined(__linux__) || defined(__linux)
150# define Q_OS_LINUX
151#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
152# ifndef __FreeBSD_kernel__
153# define Q_OS_FREEBSD
154# endif
155# define Q_OS_FREEBSD_KERNEL
156# define Q_OS_BSD4
157#elif defined(__NetBSD__)
158# define Q_OS_NETBSD
159# define Q_OS_BSD4
160#elif defined(__OpenBSD__)
161# define Q_OS_OPENBSD
162# define Q_OS_BSD4
163#elif defined(__INTERIX)
164# define Q_OS_INTERIX
165# define Q_OS_BSD4
166#elif defined(_AIX)
167# define Q_OS_AIX
168#elif defined(__Lynx__)
169# define Q_OS_LYNX
170#elif defined(__GNU__)
171# define Q_OS_HURD
172#elif defined(__QNXNTO__)
173# define Q_OS_QNX
174#elif defined(__INTEGRITY)
175# define Q_OS_INTEGRITY
176#elif defined(__rtems__)
177# define Q_OS_RTEMS
178#elif defined(VXWORKS) /* there is no "real" VxWorks define - this has to be set in the mkspec! */
179# define Q_OS_VXWORKS
180#elif defined(__HAIKU__)
181# define Q_OS_HAIKU
182#elif defined(__MAKEDEPEND__)
183#else
184# error "Qt has not been ported to this OS - see http://www.qt-project.org/"
185#endif
186
187#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINRT)
188# define Q_OS_WINDOWS
189# define Q_OS_WIN
190# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
191// On Windows, pointers to dllimport'ed variables are not constant expressions,
192// so to keep to certain initializations (like QMetaObject) constexpr, we need
193// to use functions instead.
194# define QT_NO_DATA_RELOCATION
195# endif
196#endif
197
198#if defined(Q_OS_WIN)
199# undef Q_OS_UNIX
200#elif !defined(Q_OS_UNIX)
201# define Q_OS_UNIX
202#endif
203
204// Compatibility synonyms
205#ifdef Q_OS_DARWIN
206#define Q_OS_MAC
207#endif
208#ifdef Q_OS_DARWIN32
209#define Q_OS_MAC32
210#endif
211#ifdef Q_OS_DARWIN64
212#define Q_OS_MAC64
213#endif
214#ifdef Q_OS_MACOS
215#define Q_OS_MACX
216#define Q_OS_OSX
217#endif
218
219#ifdef Q_OS_DARWIN
220# include <Availability.h>
221# include <AvailabilityMacros.h>
222#
223# ifdef Q_OS_MACOS
224# if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_6
225# undef __MAC_OS_X_VERSION_MIN_REQUIRED
226# define __MAC_OS_X_VERSION_MIN_REQUIRED __MAC_10_6
227# endif
228# if !defined(MAC_OS_X_VERSION_MIN_REQUIRED) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
229# undef MAC_OS_X_VERSION_MIN_REQUIRED
230# define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_6
231# endif
232# endif
233#
234# // Numerical checks are preferred to named checks, but to be safe
235# // we define the missing version names in case Qt uses them.
236#
237# if !defined(__MAC_10_11)
238# define __MAC_10_11 101100
239# endif
240# if !defined(__MAC_10_12)
241# define __MAC_10_12 101200
242# endif
243# if !defined(__MAC_10_13)
244# define __MAC_10_13 101300
245# endif
246# if !defined(__MAC_10_14)
247# define __MAC_10_14 101400
248# endif
249# if !defined(__MAC_10_15)
250# define __MAC_10_15 101500
251# endif
252# if !defined(__MAC_10_16)
253# define __MAC_10_16 101600
254# endif
255# if !defined(MAC_OS_X_VERSION_10_11)
256# define MAC_OS_X_VERSION_10_11 __MAC_10_11
257# endif
258# if !defined(MAC_OS_X_VERSION_10_12)
259# define MAC_OS_X_VERSION_10_12 __MAC_10_12
260# endif
261# if !defined(MAC_OS_X_VERSION_10_13)
262# define MAC_OS_X_VERSION_10_13 __MAC_10_13
263# endif
264# if !defined(MAC_OS_X_VERSION_10_14)
265# define MAC_OS_X_VERSION_10_14 __MAC_10_14
266# endif
267# if !defined(MAC_OS_X_VERSION_10_15)
268# define MAC_OS_X_VERSION_10_15 __MAC_10_15
269# endif
270# if !defined(MAC_OS_X_VERSION_10_16)
271# define MAC_OS_X_VERSION_10_16 __MAC_10_16
272# endif
273#
274# if !defined(__IPHONE_10_0)
275# define __IPHONE_10_0 100000
276# endif
277# if !defined(__IPHONE_10_1)
278# define __IPHONE_10_1 100100
279# endif
280# if !defined(__IPHONE_10_2)
281# define __IPHONE_10_2 100200
282# endif
283# if !defined(__IPHONE_10_3)
284# define __IPHONE_10_3 100300
285# endif
286# if !defined(__IPHONE_11_0)
287# define __IPHONE_11_0 110000
288# endif
289# if !defined(__IPHONE_12_0)
290# define __IPHONE_12_0 120000
291# endif
292#endif
293
294#ifdef __LSB_VERSION__
295# if __LSB_VERSION__ < 40
296# error "This version of the Linux Standard Base is unsupported"
297# endif
298#ifndef QT_LINUXBASE
299# define QT_LINUXBASE
300#endif
301#endif
302
303#endif // QSYSTEMDETECTION_H
304

source code of qtbase/src/corelib/global/qsystemdetection.h