|
25 | 25 |
|
26 | 26 | /// MSVC
|
27 | 27 | #if defined(_MSC_VER) && !defined(__clang__) && !defined(CCMATH_COMPILER_MSVC)
|
28 |
| - #define CCMATH_COMPILER_MSVC |
29 |
| - #define CCMATH_COMPILER_MSVC_VER _MSC_VER |
| 28 | +#define CCMATH_COMPILER_MSVC |
| 29 | +#define CCMATH_COMPILER_MSVC_VER _MSC_VER |
30 | 30 |
|
31 | 31 | /// Intel DPC++ Compiler
|
32 | 32 | #elif defined(SYCL_LANGUAGE_VERSION) || defined(__INTEL_LLVM_COMPILER) && !defined(CCMATH_COMPILER_INTEL)
|
33 | 33 | #define CCMATH_COMPILER_INTEL
|
34 | 34 | #define CCMATH_COMPILER_INTEL_VER __INTEL_LLVM_COMPILER
|
35 | 35 |
|
36 |
| - #ifndef CCMATH_COMPILER_CLANG_BASED |
| 36 | +#ifndef CCMATH_COMPILER_CLANG_BASED |
37 | 37 | #define CCMATH_COMPILER_CLANG_BASED
|
38 |
| - #endif |
| 38 | +#endif |
39 | 39 |
|
40 | 40 | // TODO: Add precise detection for specific compiler versions along with a warning if using unsupported compiler
|
41 | 41 |
|
|
47 | 47 | #define CCMATH_COMPILER_CLANG_CL_VER_MINOR __clang_minor__
|
48 | 48 | #define CCMATH_COMPILER_CLANG_CL_VER_PATCH __clang_patchlevel__
|
49 | 49 |
|
50 |
| - #ifndef CCMATH_COMPILER_CLANG_BASED |
| 50 | +#ifndef CCMATH_COMPILER_CLANG_BASED |
51 | 51 | #define CCMATH_COMPILER_CLANG_BASED
|
52 |
| - #endif |
| 52 | +#endif |
53 | 53 |
|
54 | 54 | // TODO: Add precise detection for specific compiler versions along with a warning if using unsupported compiler
|
55 | 55 |
|
56 | 56 |
|
57 |
| - |
58 | 57 | /// Nvidia HPC SDK
|
59 | 58 | #elif defined(__NVCOMPILER) || defined(__NVCOMPILER_LLVM__) && !defined(CCMATH_COMPILER_NVIDIA_HPC)
|
60 | 59 | #define CCMATH_COMPILER_NVIDIA_HPC
|
|
68 | 67 |
|
69 | 68 | /// Nvidia CUDA
|
70 | 69 | #elif defined(__CUDACC__) && !defined(CCMATH_COMPILER_NVIDIA_CUDA)
|
71 |
| - #if !defined(CUDA_VERSION) |
| 70 | +#if !defined(CUDA_VERSION) |
72 | 71 | #include <cuda.h> // We need to make sure the version is defined since nvcc doesn't define it
|
73 |
| - #endif |
| 72 | +#endif |
74 | 73 |
|
75 | 74 | #define CCMATH_COMPILER_NVIDIA_CUDA
|
76 | 75 | #define CCMATH_COMPILER_NVIDIA_CUDA_VER (CUDA_VERSION / 1000)
|
|
93 | 92 | #define CCMATH_COMPILER_APPLE_CLANG_VER_MINOR __clang_minor__
|
94 | 93 | #define CCMATH_COMPILER_APPLE_CLANG_VER_PATCH __clang_patchlevel__
|
95 | 94 |
|
96 |
| - #ifndef CCMATH_COMPILER_CLANG_BASED |
| 95 | +#ifndef CCMATH_COMPILER_CLANG_BASED |
97 | 96 | #define CCMATH_COMPILER_CLANG_BASED
|
98 |
| - #endif |
| 97 | +#endif |
99 | 98 |
|
100 | 99 | // TODO: Add precise detection for specific compiler versions along with a warning if using unsupported compiler
|
101 | 100 |
|
|
107 | 106 | #define CCMATH_COMPILER_CLANG_VER_MINOR __clang_minor__
|
108 | 107 | #define CCMATH_COMPILER_CLANG_VER_PATCH __clang_patchlevel__
|
109 | 108 |
|
110 |
| - #ifndef CCMATH_COMPILER_CLANG_BASED |
| 109 | +#ifndef CCMATH_COMPILER_CLANG_BASED |
111 | 110 | #define CCMATH_COMPILER_CLANG_BASED
|
112 |
| - #endif |
| 111 | +#endif |
113 | 112 |
|
114 | 113 | // TODO: Add precise detection for specific compiler versions along with a warning if using unsupported compiler
|
115 | 114 |
|
|
125 | 124 | #else
|
126 | 125 | #define CCMATH_COMPILER_UNKNOWN
|
127 | 126 | #endif
|
| 127 | + |
| 128 | +// TODO: Explore this idea further |
| 129 | + |
| 130 | +namespace ccm::internal::platform |
| 131 | +{ |
| 132 | + // NOLINTNEXTLINE |
| 133 | + enum class compiler |
| 134 | + { |
| 135 | + eUnknown, |
| 136 | + eGCC, |
| 137 | + eClang, |
| 138 | + eMSVC, |
| 139 | + eClangCL, |
| 140 | + eIntel, |
| 141 | + eNvidiaHPC |
| 142 | + }; |
| 143 | + |
| 144 | + template <compiler> |
| 145 | + struct native_compiler : std::false_type{}; |
| 146 | + |
| 147 | + template <> |
| 148 | + struct native_compiler<compiler::eUnknown> : std::false_type |
| 149 | + { |
| 150 | + }; |
| 151 | + |
| 152 | + #ifdef CCMATH_COMPILER_GCC |
| 153 | + template <> |
| 154 | + struct native_compiler<compiler::eGCC> : std::true_type |
| 155 | + { |
| 156 | + }; |
| 157 | + #endif |
| 158 | + |
| 159 | + #ifdef CCMATH_COMPILER_CLANG |
| 160 | + template <> |
| 161 | + struct native_compiler<compiler::eClang> : std::true_type |
| 162 | + { |
| 163 | + }; |
| 164 | + #endif |
| 165 | + |
| 166 | + #ifdef CCMATH_COMPILER_MSVC |
| 167 | + template <> |
| 168 | + struct native_compiler<compiler::eMSVC> : std::true_type |
| 169 | + { |
| 170 | + }; |
| 171 | + #endif |
| 172 | + |
| 173 | + #ifdef CCMATH_COMPILER_CLANG_CL |
| 174 | + template <> |
| 175 | + struct native_compiler<compiler::eClangCL> : std::true_type |
| 176 | + { |
| 177 | + }; |
| 178 | + #endif |
| 179 | + |
| 180 | + |
| 181 | + |
| 182 | +} // namespace ccm::internal::platform |
0 commit comments