TGUI 1.14-dev
Loading...
Searching...
No Matches
Config.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2026 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 13
33#define TGUI_VERSION_PATCH 0
34
35// Detect the platform, to enable platform-specific code
36#if defined(__EMSCRIPTEN__)
37 #define TGUI_SYSTEM_EMSCRIPTEN // Emscripten
38#elif defined(_WIN32)
39 #define TGUI_SYSTEM_WINDOWS // Windows
40#elif defined(__APPLE__) && defined(__MACH__)
41 #include "TargetConditionals.h"
42 #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
43 #define TGUI_SYSTEM_IOS // iOS
44 #elif TARGET_OS_MAC
45 #define TGUI_SYSTEM_MACOS // macOS
46 #endif
47#elif defined(__unix__)
48 #if defined(__ANDROID__)
49 #define TGUI_SYSTEM_ANDROID // Android
50 #else //if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
51 #define TGUI_SYSTEM_LINUX // Linux or BSD
52 #endif
53#endif
54
55// TGUI will link in the same way as SFML, unless TGUI_DYNAMIC or TGUI_STATIC is defined
56#if !defined(TGUI_DYNAMIC) && !defined(TGUI_STATIC)
57 #ifdef SFML_STATIC
58 #define TGUI_STATIC
59 #endif
60#endif
61
62#ifndef TGUI_STATIC
63 #ifdef TGUI_SYSTEM_WINDOWS
64 // Windows compilers need specific (and different) keywords for export and import
65 #ifdef TGUI_EXPORTS
66 #define TGUI_API __declspec(dllexport)
67 #else
68 #define TGUI_API __declspec(dllimport)
69 #endif
70
71 // For Visual C++ compilers, we also need to turn off the annoying C4251 warning
72 #ifdef _MSC_VER
73 #pragma warning(disable : 4251)
74 #endif
75 #else
76 #define TGUI_API __attribute__((__visibility__("default")))
77 #endif
78#else
79 // Static build doesn't need import/export macros
80 #define TGUI_API
81#endif
82
83// Enables code that relies on a specific backend
84#define TGUI_HAS_WINDOW_BACKEND_SFML 0
85#define TGUI_HAS_WINDOW_BACKEND_SDL 1
86#define TGUI_HAS_WINDOW_BACKEND_GLFW 0
87#define TGUI_HAS_WINDOW_BACKEND_RAYLIB 0
88
89#define TGUI_HAS_RENDERER_BACKEND_SFML_GRAPHICS 0
90#define TGUI_HAS_RENDERER_BACKEND_SDL_GPU 0
91#define TGUI_HAS_RENDERER_BACKEND_SDL_RENDERER 0
92#define TGUI_HAS_RENDERER_BACKEND_OPENGL3 0
93#define TGUI_HAS_RENDERER_BACKEND_GLES2 0
94#define TGUI_HAS_RENDERER_BACKEND_VULKAN 1
95#define TGUI_HAS_RENDERER_BACKEND_RAYLIB 0
96
97#define TGUI_HAS_FONT_BACKEND_SFML_GRAPHICS 0
98#define TGUI_HAS_FONT_BACKEND_SDL_TTF 0
99#define TGUI_HAS_FONT_BACKEND_FREETYPE 1
100#define TGUI_HAS_FONT_BACKEND_RAYLIB 0
101
102#define TGUI_HAS_BACKEND_SFML_GRAPHICS 0
103#define TGUI_HAS_BACKEND_SFML_OPENGL3 0
104#define TGUI_HAS_BACKEND_SDL_GPU 0
105#define TGUI_HAS_BACKEND_SDL_RENDERER 0
106#define TGUI_HAS_BACKEND_SDL_OPENGL3 0
107#define TGUI_HAS_BACKEND_SDL_GLES2 0
108#define TGUI_HAS_BACKEND_SDL_TTF_OPENGL3 0
109#define TGUI_HAS_BACKEND_SDL_TTF_GLES2 0
110#define TGUI_HAS_BACKEND_SDL_VULKAN 1
111#define TGUI_HAS_BACKEND_GLFW_OPENGL3 0
112#define TGUI_HAS_BACKEND_GLFW_GLES2 0
113#define TGUI_HAS_BACKEND_GLFW_VULKAN 0
114#define TGUI_HAS_BACKEND_RAYLIB 0
115
116#define TGUI_USE_SDL3 1
117
118// Some window backends (SFML < 2.6 and SDL < 3) don't support diagonal mouse cursors on Linux in which case TGUI loads them directly with X11.
119// Settig this option to FALSE in CMake will remove the X11 dependency but will cause those cursors to not show up when using them.
120#define TGUI_USE_X11 0
121
122// Options to use system-wide dependencies instead of version TGUI ships in its extlibs folder.
123// This might be useful for package managers.
124#define TGUI_USE_SYSTEM_STB 0
125#define TGUI_USE_SYSTEM_GLAD 0
126#define TGUI_USE_SYSTEM_NANOSVG 0
127#define TGUI_USE_SYSTEM_AURORA 0
128
129// Define that specifies the mininmum C++ support in both the TGUI code and user code.
130// This constant can be lower than the actual C++ standard version used to compile with,
131// as long as this constant is the same when compiling TGUI and when using the TGUI libs.
132#define TGUI_COMPILED_WITH_CPP_VER 20
133
134// Include the version header when C++20 is available to use the library feature-testing macros
135#if TGUI_COMPILED_WITH_CPP_VER >= 20
136 #include <version>
137#else
138 // Try including the header even when TGUI itself wasn't compiled with C++20
139 #if __has_include(<version>)
140 #include <version>
141 #endif
142#endif
143
144// GCC and clang supported std filesystem before version 9, this is the first version where no
145// additional library has to be linked in order to use std::filesystem. This is also the
146// reason why we can't rely on __cpp_lib_filesystem for this.
147// Xcode 11 supports it on macOS 10.15 only, so we require Xcode 12 which doesn't run on macOS 10.14.
148#if (defined(__apple_build_version__) && defined(__clang_major__) && (__clang_major__ >= 12)) \
149 || (!defined(__apple_build_version__) && defined(__clang_major__) && (__clang_major__ >= 9)) \
150 || (defined(__GNUC__) && (__GNUC__ >= 9)) || (defined(_MSC_VER) && (_MSC_VER >= 1914))
151 #define TGUI_USE_STD_FILESYSTEM
152
153 // Use clock_cast to convert file time to system time when clock_cast is available
154 #if __cpp_lib_chrono >= 201907L
155 #define TGUI_USE_STD_FILESYSTEM_FILE_TIME
156 #endif
157#endif
158
159// TGUI_NEXT: Remove TGUI_EMPLACE_BACK, TGUI_IF_CONSTEXPR and TGUI_NODISCARD defines, they should no longer be used
160#define TGUI_EMPLACE_BACK(object, vector) auto&(object) = (vector).emplace_back();
161#define TGUI_IF_CONSTEXPR if constexpr
162#define TGUI_NODISCARD [[nodiscard]]
163
164#ifndef TGUI_NO_DEPRECATED_WARNINGS
165 #define TGUI_DEPRECATED(msg) [[deprecated(msg)]]
166#else
167 #define TGUI_DEPRECATED(msg)
168#endif
169
170#if defined(__GNUC__)
171 #define TGUI_IGNORE_DEPRECATED_WARNINGS_START \
172 _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
173
174 #define TGUI_IGNORE_DEPRECATED_WARNINGS_END _Pragma("GCC diagnostic pop")
175#elif defined(_MSC_VER) && (_MSC_VER >= 1927)
176 #define TGUI_IGNORE_DEPRECATED_WARNINGS_START _Pragma("warning(push)") _Pragma("warning(disable: 4996)")
177
178 #define TGUI_IGNORE_DEPRECATED_WARNINGS_END _Pragma("warning(pop)")
179#elif defined(_MSC_VER)
180 #define TGUI_IGNORE_DEPRECATED_WARNINGS_START __pragma(warning(push)) __pragma(warning(disable : 4996))
181
182 #define TGUI_IGNORE_DEPRECATED_WARNINGS_END __pragma(warning(pop))
183#endif
184
185#if !defined(NDEBUG) && !defined(TGUI_NO_RUNTIME_WARNINGS)
186 #include <iostream>
187 #define TGUI_PRINT_WARNING(msg) \
188 { \
189 std::cerr << "TGUI warning: " << msg << "\n"; \
190 }
191#else
192 #define TGUI_PRINT_WARNING(msg)
193#endif
194
195#include <cassert>
196#if !defined(NDEBUG) && !defined(TGUI_DISABLE_ASSERTS)
197 #include <exception>
198 #include <iostream>
199 #define TGUI_ASSERT(condition, msg) \
200 { \
201 if (!(condition)) \
202 { \
203 std::cerr << "TGUI assertion: " << msg << "\n"; \
204 assert(condition); \
205 std::terminate(); \
206 } \
207 }
208#else
209 #define TGUI_ASSERT(condition, msg)
210#endif
211
212// Using [=] gives a warning in C++20, but using [=, this] may not compile with older C++ versions
213#if __cplusplus > 201703L
214 #define TGUI_LAMBDA_CAPTURE_EQ_THIS [=, this]
215#else
216 #define TGUI_LAMBDA_CAPTURE_EQ_THIS [=]
217#endif
218
219#endif // TGUI_CONFIG_HPP