Scanframe DevOps Trial App 0.1.0
Loading...
Searching...
No Matches
target.h
Go to the documentation of this file.
1
15
16#pragma once
17
18// Detect usage of the GCC GNU compiler.
19#if defined(__GNUC__)
20 #define IS_GNU 1
21// #pragma GCC visibility
22#else
23 #define IS_GNU 0
24#endif
25
26// Check when the MSVC compiler is active for a Windows target.
27#if defined(_MSC_VER)
28 #define IS_MSVC 1
29#else
30 #define IS_MSVC 0
31#endif
32
33// Check when a compiler is active for a Windows target.
34#if defined(WIN32)
35 #define IS_WIN 1
36#else
37 #define IS_WIN 0
38#endif
39
40// Determine if the build target a dynamically shared library.
41#if defined(TARGET_DYNAMIC_LIB)
42 #define IS_DL_TARGET 1
43#else
44 #define IS_DL_TARGET 0
45#endif
46
47// Determine if the build target a dynamically shared library.
48#if defined(TARGET_STATIC_LIB)
49 #define IS_SL_TARGET 1
50#else
51 #define IS_SL_TARGET 0
52#endif
53
54// CHeck if an application binary is targeted
55#if IS_DL_TARGET || IS_SL_TARGET
56 #define IS_AB_TARGET 0
57#else
58 #define IS_AB_TARGET 1
59#endif
60
61// Determine if QT is used in the target.
62#if defined(TARGET_QT) || defined(QT_VERSION)
63 #define IS_QT 1
64#else
65 #define IS_QT 0
66#endif
67
68#if IS_WIN
69 #if IS_GNU
70 #define TARGET_EXPORT __attribute__((dllexport))
71 #define TARGET_IMPORT __attribute__((dllimport))
72 #define TARGET_HIDDEN __attribute__((visibility("hidden")))
73 #elif IS_MSVC
74 #define TARGET_EXPORT __declspec(dllexport)
75 #define TARGET_IMPORT __declspec(dllimport)
76 #define TARGET_HIDDEN
77 #else
78 #error "Failed to detect compiler."
79 #endif
80#else
81 #define TARGET_EXPORT __attribute__((visibility("default")))
82 #define TARGET_IMPORT
83 #define TARGET_HIDDEN __attribute__((visibility("hidden")))
84#endif
85
86// MinGW GCC < 13.4 detection for thread_local destructor ordering bug GCC #116159"
87#if (defined(__MINGW32__) || defined(__MINGW64__)) && ((__GNUC__ < 13) || (__GNUC__ == 13 && __GNUC_MINOR__ < 4))
88 #define IS_MINGW_THREADLOCAL_BUGGY 1
89#else
90 #define IS_MINGW_THREADLOCAL_BUGGY 0
91#endif
92
93// Report current targeted result.
94#if defined(REPORT_TARGET)
95 // Report when GNU GCC is used.
96 #if IS_GNU
97 #pragma message("GNU compiler")
98 #endif
99 // Report the Windows target.
100 #if IS_WIN
101 #pragma message("Windows build")
102 #endif
103 // Report the GNU C++ compiler.
104 #if IS_GNU
105 #pragma message("GNU C++ Compiler")
106 #endif
107 // Report the Visual C++ compiler.
108 #if IS_MSVC
109 #pragma message("Visual C++ Compiler")
110 #endif
111 // Report the QT is linked.
112 #if IS_QT
113 #pragma message("Target: QT")
114 #endif
115 // Report the QT designer widgets are exported.
116 #ifdef QDESIGNER_EXPORT_WIDGETS
117 #pragma message("Target: QT Export designer widgets")
118 #endif
119 // Report the target is a dynamic library.
120 #if IS_DL_TARGET
121 #pragma message("Target: Shared Library")
122 #endif
123 // Report the target is a static library (archive).
124 #if IS_SL_TARGET
125 #pragma message("Target: Static Library")
126 #endif
127 // Report the C++ version using preprocessor directives
128 #define _STRINGIFY_(x) #x
129 #define _TOSTRING_(x) _STRINGIFY_(x)
130 #pragma message("C++: " _TOSTRING_(__cplusplus))
131 #undef _STRINGIFY_
132 #undef _TOSTRING_
133 // Report the thread local bug.
134 #if IS_MINGW_THREADLOCAL_BUGGY
135 #pragma message("MinGW GCC < 13.4 detected: thread_local destructor ordering bug present (GCC #116159)")
136 #endif
137#endif// REPORT_TARGET