TGUI  0.9-dev
Config.hpp
1 //
3 // TGUI - Texus' Graphical User Interface
4 // Copyright (C) 2012-2020 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 // Include the SFML config header to check the SFML version
29 #include <SFML/Config.hpp>
30 
31 // Detect the platform, to enable platform-specific code
32 #if defined(_WIN32)
33  #define TGUI_SYSTEM_WINDOWS // Windows
34 #elif defined(__APPLE__) && defined(__MACH__)
35  #include "TargetConditionals.h"
36  #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
37  #define TGUI_SYSTEM_IOS // iOS
38  #elif TARGET_OS_MAC
39  #define TGUI_SYSTEM_MACOS // macOS
40  #endif
41 #elif defined(__unix__)
42  #if defined(__ANDROID__)
43  #define TGUI_SYSTEM_ANDROID // Android
44  #else //if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
45  #define TGUI_SYSTEM_LINUX // Linux or BSD
46  #endif
47 #endif
48 
49 // TGUI will link in the same way as SFML, unless TGUI_DYNAMIC or TGUI_STATIC is defined
50 #if !defined(TGUI_DYNAMIC) && !defined(TGUI_STATIC)
51  #ifdef SFML_STATIC
52  #define TGUI_STATIC
53  #endif
54 #endif
55 
56 #ifndef TGUI_STATIC
57  #ifdef TGUI_SYSTEM_WINDOWS
58  // Windows compilers need specific (and different) keywords for export and import
59  #ifdef TGUI_EXPORTS
60  #define TGUI_API __declspec(dllexport)
61  #else
62  #define TGUI_API __declspec(dllimport)
63  #endif
64  #else
65  #define TGUI_API __attribute__ ((__visibility__ ("default")))
66  #endif
67 #else
68  // Static build doesn't need import/export macros
69  #define TGUI_API
70  #define TGUI_API
71 #endif
72 
73 
74 // Define that specifies the mininmum c++ support in both the TGUI code and user code.
75 // This constant can be lower than the actual c++ standard version used to compile with,
76 // as long as this constant is the same when compiling TGUI and when using the TGUI libs.
77 #define TGUI_COMPILED_WITH_CPP_VER 14
78 
79 // Enable the use of std::filesystem if TGUI is built with c++17 with a new enough compiler.
80 // Although GCC and clang supported it before version 9, this is the first version where no
81 // additional library has to be linked in order to use std::filesystem. This is also the
82 // reason why we can't rely on __cpp_lib_filesystem for this.
83 #if TGUI_COMPILED_WITH_CPP_VER >= 17
84  #if defined(__clang_major__) && (__clang_major__ >= 9) \
85  || defined(__GNUC__) && (__GNUC___ >= 9) \
86  || defined(_MSC_VER) && (_MSC_VER >= 1914)
87  #define TGUI_USE_STD_FILESYSTEM
88  #endif
89 #endif
90 
91 // Include the version header when c++20 is available to use the library feature-testing macros
92 #ifdef TGUI_COMPILED_WITH_CPP_VER >= 20
93  #include <version>
94 #endif
95 
96 #if defined(__cpp_constexpr) && (__cpp_constexpr >= 201304L)
97  #define TGUI_CONSTEXPR constexpr
98 #else
99  #define TGUI_CONSTEXPR inline
100 #endif
101 
102 #if __cplusplus >= 201703L
103  #define TGUI_EMPLACE_BACK(object, vector) auto& object = vector.emplace_back();
104 #else
105  #define TGUI_EMPLACE_BACK(object, vector) vector.emplace_back(); auto& object = vector.back();
106 #endif
107 
108 #ifndef TGUI_NO_DEPRECATED_WARNINGS
109  #define TGUI_DEPRECATED(msg) [[deprecated(msg)]]
110 #else
111  #define TGUI_DEPRECATED(msg)
112 #endif
113 
114 #ifndef TGUI_NO_RUNTIME_WARNINGS
115  #define TGUI_PRINT_WARNING(msg) { sf::err() << "TGUI Warning: " << msg << std::endl; }
116 #else
117  #define TGUI_PRINT_WARNING(msg) {}
118 #endif
119 
120 // Using [=] gives a warning in c++20, but using [=,this] may not compile with older c++ versions
121 #if __cplusplus > 201703L
122  #define TGUI_LAMBDA_CAPTURE_EQ_THIS [=,this]
123 #else
124  #define TGUI_LAMBDA_CAPTURE_EQ_THIS [=]
125 #endif
126 
127 
128 // Version of the library
129 #define TGUI_VERSION_MAJOR 0
130 #define TGUI_VERSION_MINOR 9
131 #define TGUI_VERSION_PATCH 0
132 
133 #endif // TGUI_CONFIG_HPP