-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcompiler
107 lines (91 loc) · 3.42 KB
/
compiler
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
Copyright (C) 2018-2024 Geoffrey Daniels. https://gpdaniels.com/
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License only.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#ifndef GTL_PLATFORM_COMPILER_HPP
#define GTL_PLATFORM_COMPILER_HPP
// Summary: Macros and helper function to get the compiler used for the build.
#define GTL_PLATFORM_COMPILER_APPLE_CLANG 0
#define GTL_PLATFORM_COMPILER_CLANG 0
#define GTL_PLATFORM_COMPILER_GCC 0
#define GTL_PLATFORM_COMPILER_MINGW 0
#define GTL_PLATFORM_COMPILER_MSVC 0
#define GTL_PLATFORM_COMPILER_INTEL 0
#define GTL_PLATFORM_COMPILER_UNKNOWN 1
#if (defined(__clang__) && defined(__apple_build_version__))
#undef GTL_PLATFORM_COMPILER_APPLE_CLANG
#define GTL_PLATFORM_COMPILER_APPLE_CLANG 1
#endif
#if (defined(__clang__) && !defined(__apple_build_version__))
#undef GTL_PLATFORM_COMPILER_CLANG
#define GTL_PLATFORM_COMPILER_CLANG 1
#endif
#if ((defined(__GNUC__) || defined(__GNUG__)) && (!defined(__clang__) && (!defined(__INTEL_COMPILER))))
#undef GTL_PLATFORM_COMPILER_GCC
#define GTL_PLATFORM_COMPILER_GCC 1
#endif
#if (defined(__MINGW32__) || defined(__MINGW64__))
#undef GTL_PLATFORM_COMPILER_MINGW
#define GTL_PLATFORM_COMPILER_MINGW 1
#endif
#if (defined(_MSC_VER))
#undef GTL_PLATFORM_COMPILER_MSVC
#define GTL_PLATFORM_COMPILER_MSVC 1
#endif
#if (defined(__INTEL_COMPILER))
#undef GTL_PLATFORM_COMPILER_INTEL
#define GTL_PLATFORM_COMPILER_INTEL 1
#endif
#if ( \
(GTL_PLATFORM_COMPILER_APPLE_CLANG) || \
(GTL_PLATFORM_COMPILER_CLANG) || \
(GTL_PLATFORM_COMPILER_GCC) || \
(GTL_PLATFORM_COMPILER_MINGW) || \
(GTL_PLATFORM_COMPILER_MSVC) || \
(GTL_PLATFORM_COMPILER_INTEL) \
)
#undef GTL_PLATFORM_COMPILER_UNKNOWN
#define GTL_PLATFORM_COMPILER_UNKNOWN 0
#endif
namespace gtl {
/// @brief Enumeration of the known compilers.
enum class compiler_types {
unknown,
apple_clang,
clang,
gcc,
mingw,
msvc,
intel
};
/// @brief Compile time variable holding the detected compiler.
constexpr static const compiler_types compiler = []()constexpr->compiler_types{
#if (GTL_PLATFORM_COMPILER_APPLE_CLANG)
return compiler_types::apple_clang;
#elif (GTL_PLATFORM_COMPILER_CLANG)
return compiler_types::clang;
#elif (GTL_PLATFORM_COMPILER_GCC)
return compiler_types::gcc;
#elif (GTL_PLATFORM_COMPILER_MINGW)
return compiler_types::mingw;
#elif (GTL_PLATFORM_COMPILER_MSVC)
return compiler_types::msvc;
#elif (GTL_PLATFORM_COMPILER_INTEL)
return compiler_types::intel;
#elif (GTL_PLATFORM_COMPILER_UNKNOWN)
return compiler_types::unknown;
#else
#error "Issue detecting platform compiler."
#endif
}();
}
#endif // GTL_PLATFORM_COMPILER_HPP