TGUI  1.1
Loading...
Searching...
No Matches
Config.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2023 Bruno Van de Velde (vdv_b@tgui.eu)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#ifndef TGUI_CONFIG_HPP
26#define TGUI_CONFIG_HPP
27
28// Config.hpp is generated by CMake, it should not be edited directly.
29
30// Version of the library
31#define TGUI_VERSION_MAJOR 1
32#define TGUI_VERSION_MINOR 0
33#define TGUI_VERSION_PATCH 0
34
35// Detect the platform, to enable platform-specific code
36#if defined(_WIN32)
37 #define TGUI_SYSTEM_WINDOWS // Windows
38#elif defined(__APPLE__) && defined(__MACH__)
39 #include "TargetConditionals.h"
40 #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
41 #define TGUI_SYSTEM_IOS // iOS
42 #elif TARGET_OS_MAC
43 #define TGUI_SYSTEM_MACOS // macOS
44 #endif
45#elif defined(__unix__)
46 #if defined(__ANDROID__)
47 #define TGUI_SYSTEM_ANDROID // Android
48 #else //if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
49 #define TGUI_SYSTEM_LINUX // Linux or BSD
50 #endif
51#endif
52
53// TGUI will link in the same way as SFML, unless TGUI_DYNAMIC or TGUI_STATIC is defined
54#if !defined(TGUI_DYNAMIC) && !defined(TGUI_STATIC)
55 #ifdef SFML_STATIC
56 #define TGUI_STATIC
57 #endif
58#endif
59
60#ifndef TGUI_STATIC
61 #ifdef TGUI_SYSTEM_WINDOWS
62 // Windows compilers need specific (and different) keywords for export and import
63 #ifdef TGUI_EXPORTS
64 #define TGUI_API __declspec(dllexport)
65 #else
66 #define TGUI_API __declspec(dllimport)
67 #endif
68
69 // For Visual C++ compilers, we also need to turn off the annoying C4251 warning
70 #ifdef _MSC_VER
71 #pragma warning(disable: 4251)
72 #endif
73 #else
74 #define TGUI_API __attribute__ ((__visibility__ ("default")))
75 #endif
76#else
77 // Static build doesn't need import/export macros
78 #define TGUI_API
79#endif
80
81// Enables code that relies on a specific backend
82#define TGUI_HAS_WINDOW_BACKEND_SFML 1
83#define TGUI_HAS_WINDOW_BACKEND_SDL 1
84#define TGUI_HAS_WINDOW_BACKEND_GLFW 1
85
86#define TGUI_HAS_RENDERER_BACKEND_SFML_GRAPHICS 1
87#define TGUI_HAS_RENDERER_BACKEND_SDL_RENDERER 1
88#define TGUI_HAS_RENDERER_BACKEND_OPENGL3 1
89#define TGUI_HAS_RENDERER_BACKEND_GLES2 1
90
91#define TGUI_HAS_FONT_BACKEND_SFML_GRAPHICS 1
92#define TGUI_HAS_FONT_BACKEND_SDL_TTF 1
93#define TGUI_HAS_FONT_BACKEND_FREETYPE 1
94
95#define TGUI_HAS_BACKEND_SFML_GRAPHICS 1
96#define TGUI_HAS_BACKEND_SFML_OPENGL3 1
97#define TGUI_HAS_BACKEND_SDL_RENDERER 1
98#define TGUI_HAS_BACKEND_SDL_OPENGL3 1
99#define TGUI_HAS_BACKEND_SDL_GLES2 1
100#define TGUI_HAS_BACKEND_SDL_TTF_OPENGL3 1
101#define TGUI_HAS_BACKEND_SDL_TTF_GLES2 1
102#define TGUI_HAS_BACKEND_GLFW_OPENGL3 1
103#define TGUI_HAS_BACKEND_GLFW_GLES2 1
104
105#define TGUI_USE_SDL3 1
106
107// Some window backends (SFML < 2.6 and SDL) don't support diagonal mouse cursors on Linux in which case TGUI loads them directly with X11.
108// Settig this option to FALSE in CMake will remove the X11 dependency but will cause those cursors to not show up when using them.
109#define TGUI_USE_X11 1
110
111// Options to use system-wide dependencies instead of version TGUI ships in its extlibs folder.
112// This might be useful for package managers.
113#define TGUI_USE_SYSTEM_STB 0
114#define TGUI_USE_SYSTEM_GLAD 0
115#define TGUI_USE_SYSTEM_NANOSVG 0
116#define TGUI_USE_SYSTEM_AURORA 0
117
118// Define that specifies the mininmum c++ support in both the TGUI code and user code.
119// This constant can be lower than the actual c++ standard version used to compile with,
120// as long as this constant is the same when compiling TGUI and when using the TGUI libs.
121#define TGUI_COMPILED_WITH_CPP_VER 17
122
123#define TGUI_BUILD_AS_CXX_MODULE 0
124
125#if TGUI_EXPERIMENTAL_USE_STD_MODULE
126 import std;
127#endif
128
129// When TGUI_BUILD_AS_CXX_MODULE is set to 1, TGUI_MODULE_EXPORT will be defined as "export" while
130// TGUI is being build. This define takes place before this header is included.
131#ifndef TGUI_MODULE_EXPORT
132 #define TGUI_MODULE_EXPORT
133#endif
134
135// Include the version header when c++20 is available to use the library feature-testing macros
136#if TGUI_COMPILED_WITH_CPP_VER >= 20
137 #include <version>
138#elif defined(__has_include)
139 // Try including the header even when TGUI itself wasn't compiled with c++20
140 #if __has_include(<version>)
141 #include <version>
142 #endif
143#endif
144
145// Enable the use of std::filesystem if TGUI is built with c++17 with a new enough compiler.
146// Although GCC and clang supported it before version 9, this is the first version where no
147// additional library has to be linked in order to use std::filesystem. This is also the
148// reason why we can't rely on __cpp_lib_filesystem for this.
149// Xcode 11 supports it on macOS 10.15 only, so we require Xcode 12 which doesn't run on macOS 10.14.
150#if TGUI_COMPILED_WITH_CPP_VER >= 17
151 #if (defined(__apple_build_version__) && defined(__clang_major__) && (__clang_major__ >= 12)) \
152 || (!defined(__apple_build_version__) && defined(__clang_major__) && (__clang_major__ >= 9)) \
153 || (defined(__GNUC__) && (__GNUC__ >= 9)) \
154 || (defined(_MSC_VER) && (_MSC_VER >= 1914))
155 #define TGUI_USE_STD_FILESYSTEM
156
157 // Use clock_cast to convert file time to system time when clock_cast is available
158 #if __cpp_lib_chrono >= 201907L
159 #define TGUI_USE_STD_FILESYSTEM_FILE_TIME
160 #endif
161 #endif
162#endif
163
164#if __cplusplus >= 201703L
165 #define TGUI_EMPLACE_BACK(object, vector) auto& object = vector.emplace_back();
166#else
167 #define TGUI_EMPLACE_BACK(object, vector) vector.emplace_back(); auto& object = vector.back();
168#endif
169
170#ifndef TGUI_NO_DEPRECATED_WARNINGS
171 #define TGUI_DEPRECATED(msg) [[deprecated(msg)]]
172#else
173 #define TGUI_DEPRECATED(msg)
174#endif
175
176#if defined(__has_cpp_attribute) && (__cplusplus >= 201703L)
177# if __has_cpp_attribute(nodiscard)
178# define TGUI_NODISCARD [[nodiscard]]
179# else
180# define TGUI_NODISCARD
181# endif
182#else
183# define TGUI_NODISCARD
184#endif
185
186#if defined(__GNUC__)
187 #define TGUI_IGNORE_DEPRECATED_WARNINGS_START \
188 _Pragma("GCC diagnostic push") \
189 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
190
191 #define TGUI_IGNORE_DEPRECATED_WARNINGS_END _Pragma("GCC diagnostic pop")
192#elif defined (_MSC_VER) && (_MSC_VER >= 1927)
193 #define TGUI_IGNORE_DEPRECATED_WARNINGS_START \
194 _Pragma("warning(push)") \
195 _Pragma("warning(disable: 4996)")
196
197 #define TGUI_IGNORE_DEPRECATED_WARNINGS_END _Pragma("warning(pop)")
198#elif defined (_MSC_VER)
199 #define TGUI_IGNORE_DEPRECATED_WARNINGS_START \
200 __pragma(warning(push)) \
201 __pragma(warning(disable: 4996))
202
203 #define TGUI_IGNORE_DEPRECATED_WARNINGS_END __pragma(warning(pop))
204#endif
205
206#if !defined(NDEBUG) && !defined(TGUI_NO_RUNTIME_WARNINGS)
207 #if !TGUI_EXPERIMENTAL_USE_STD_MODULE
208 #include <iostream>
209 #endif
210 #define TGUI_PRINT_WARNING(msg) { std::cerr << "TGUI warning: " << msg << "\n"; }
211#else
212 #define TGUI_PRINT_WARNING(msg)
213#endif
214
215#if !defined(NDEBUG) && !defined(TGUI_DISABLE_ASSERTS)
216 #include <cassert>
217 #if !TGUI_EXPERIMENTAL_USE_STD_MODULE
218 #include <iostream>
219 #include <exception>
220 #endif
221 #define TGUI_ASSERT(condition, msg) { \
222 if (!(condition)) { \
223 std::cerr << "TGUI assertion: " << msg << "\n"; \
224 assert(condition); \
225 std::terminate(); \
226 } \
227 }
228#else
229 #define TGUI_ASSERT(condition, msg)
230#endif
231
232// Using [=] gives a warning in c++20, but using [=,this] may not compile with older c++ versions
233#if __cplusplus > 201703L
234 #define TGUI_LAMBDA_CAPTURE_EQ_THIS [=,this]
235#else
236 #define TGUI_LAMBDA_CAPTURE_EQ_THIS [=]
237#endif
238
239#if defined(__cpp_if_constexpr) && (__cpp_if_constexpr >= 201606L)
240 #define TGUI_IF_CONSTEXPR if constexpr
241#else
242 #define TGUI_IF_CONSTEXPR if
243
244 // Disable warning in some Visual Studio versions about being able to use "if constexpr",
245 // which we aren't doing because these VS versions didn't define __cpp_if_constexpr yet.
246 #if defined TGUI_SYSTEM_WINDOWS && defined _MSC_VER
247 #pragma warning(disable:4127)
248 #endif
249#endif
250
251#endif // TGUI_CONFIG_HPP