Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
target.h
Go to the documentation of this file.
1
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// Report current targeted result.
87#if defined(REPORT_TARGET)
88// Report when GNU GCC is used.
89 #if IS_GNU
90 #pragma message("GNU compiler")
91 #endif
92// Report the Windows target.
93 #if IS_WIN
94 #pragma message("Windows build")
95 #endif
96// Report the GNU C++ compiler.
97 #if IS_GNU
98 #pragma message("GNU C++ Compiler")
99 #endif
100// Report the Visual C++ compiler.
101 #if IS_MSVC
102 #pragma message("Visual C++ Compiler")
103 #endif
104// Report the QT is linked.
105 #if IS_QT
106 #pragma message("Target: QT")
107 #endif
108// Report the target is a dynamic library.
109 #if IS_DL_TARGET
110 #pragma message("Target: Shared Library")
111 #endif
112// Report the target is a static library (archive).
113 #if IS_SL_TARGET
114 #pragma message("Target: Static Library")
115 #endif
116// Report the C++ version using preprocessor directives
117 #define _STRINGIFY_(x) #x
118 #define _TOSTRING_(x) _STRINGIFY_(x)
119 #pragma message("C++: " _TOSTRING_(__cplusplus))
120 #undef _STRINGIFY_
121 #undef _TOSTRING_
122#endif// REPORT_TARGET