Scanframe DevOps Trial App 0.1.0
target.h
Go to the documentation of this file.
1/*
2Making it easier to build libraries for the various targets and platforms.
3Defines these with true (1) or false (0):
4 * IS_GCC > GNU compiler detected.
5 * IS_QT > QT compile target is detected.
6 * IS_WIN > Windows compile target is detected.
7
8 * IS_AB_TARGET > An application binary is the current target.
9 * IS_DL_TARGET > A dynamic library is the current target.
10 * IS_SL_TARGET > A static library is the current target.
11*/
12
13#pragma once
14
15// Detect usage of the GCC GNU compiler.
16#if defined(__GNUC__)
17 #define IS_GNU 1
18//#pragma GCC visibility
19#else
20 #define IS_GNU 0
21#endif
22
23// Check when the MSVC compiler is active for a Windows target.
24#if defined(_MSC_VER)
25 #define IS_MSVC 1
26#else
27 #define IS_MSVC 0
28#endif
29
30// Check when a compiler is active for a Windows target.
31#if defined(WIN32)
32 #define IS_WIN 1
33#else
34 #define IS_WIN 0
35#endif
36
37// Determine if the build target a dynamically shared library.
38#if defined(TARGET_DYNAMIC_LIB)
39 #define IS_DL_TARGET 1
40#else
41 #define IS_DL_TARGET 0
42#endif
43
44// Determine if the build target a dynamically shared library.
45#if defined(TARGET_STATIC_LIB)
46 #define IS_SL_TARGET 1
47#else
48 #define IS_SL_TARGET 0
49#endif
50
51// CHeck if an application binary is targeted
52#if IS_DL_TARGET || IS_SL_TARGET
53 #define IS_AB_TARGET 0
54#else
55 #define IS_AB_TARGET 1
56#endif
57
58// Determine if QT is used in the target.
59#if defined(TARGET_QT) || defined(QT_VERSION)
60 #define IS_QT 1
61#else
62 #define IS_QT 0
63#endif
64
65#if IS_WIN
66 #if IS_GNU
67 #define TARGET_EXPORT __attribute__((dllexport))
68 #define TARGET_IMPORT __attribute__((dllimport))
69 #define TARGET_HIDDEN __attribute__((visibility("hidden")))
70 #elif IS_MSVC
71 #define TARGET_EXPORT __declspec(dllexport)
72 #define TARGET_IMPORT __declspec(dllimport)
73 #define TARGET_HIDDEN
74 #else
75 #error "Failed to detect compiler."
76 #endif
77#else
78 #define TARGET_EXPORT __attribute__((visibility("default")))
79 #define TARGET_IMPORT
80 #define TARGET_HIDDEN __attribute__((visibility("hidden")))
81#endif
82
83// Report current targeted result.
84#if defined(REPORT_TARGET)
85// Report when GNU GCC is used.
86 #if IS_GNU
87 #pragma message("GNU compiler")
88 #endif
89// Report the Windows target.
90 #if IS_WIN
91 #pragma message("Windows build")
92 #endif
93// Report the GNU C++ compiler.
94 #if IS_GNU
95 #pragma message("GNU C++ Compiler")
96 #endif
97// Report the Visual C++ compiler.
98 #if IS_MSVC
99 #pragma message("Visual C++ Compiler")
100 #endif
101// Report the QT is linked.
102 #if IS_QT
103 #pragma message("Target: QT")
104 #endif
105// Report the target is a dynamic shared library.
106 #if IS_DL_TARGET
107 #pragma message("Target: Shared Library")
108 #endif
109// Report the target is a static library (archive).
110 #if IS_SL_TARGET
111 #pragma message("Target: Static Library")
112 #endif
113#endif// REPORT_TARGET