Config.h.cmake 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. // Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. // ====================== WARNING: THIS FILE IS AUTO-GENERATED BY THE BUILD SYSTEM. DON'T ALTER IT =====================
  6. #pragma once
  7. /// @addtogroup config
  8. /// @{
  9. #define _ANKI_STR_HELPER(x) #x
  10. #define _ANKI_STR(x) _ANKI_STR_HELPER(x)
  11. #define ANKI_VERSION_MINOR ${ANKI_VERSION_MINOR}
  12. #define ANKI_VERSION_MAJOR ${ANKI_VERSION_MAJOR}
  13. #define ANKI_REVISION ${ANKI_REVISION}
  14. #define ANKI_EXTRA_CHECKS ${_ANKI_EXTRA_CHECKS}
  15. #define ANKI_DEBUG_SYMBOLS ${ANKI_DEBUG_SYMBOLS}
  16. #define ANKI_OPTIMIZE ${ANKI_OPTIMIZE}
  17. #define ANKI_TESTS ${ANKI_TESTS}
  18. #define ANKI_ENABLE_TRACE ${_ANKI_ENABLE_TRACE}
  19. #define ANKI_SOURCE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  20. #define ANKI_DLSS ${_ANKI_DLSS_ENABLED}
  21. // Compiler
  22. #if defined(__clang__)
  23. # define ANKI_COMPILER_CLANG 1
  24. # define ANKI_COMPILER_GCC 0
  25. # define ANKI_COMPILER_MSVC 0
  26. # define ANKI_COMPILER_GCC_COMPATIBLE 1
  27. # define ANKI_COMPILER_STR "clang " __VERSION__
  28. #elif defined(__GNUC__) || defined(__GNUG__)
  29. # define ANKI_COMPILER_CLANG 0
  30. # define ANKI_COMPILER_GCC 1
  31. # define ANKI_COMPILER_MSVC 0
  32. # define ANKI_COMPILER_GCC_COMPATIBLE 1
  33. # define ANKI_COMPILER_STR "gcc " __VERSION__
  34. #elif defined(_MSC_VER)
  35. # define ANKI_COMPILER_CLANG 0
  36. # define ANKI_COMPILER_GCC 0
  37. # define ANKI_COMPILER_MSVC 1
  38. # define ANKI_COMPILER_GCC_COMPATIBLE 0
  39. # define ANKI_COMPILER_STR "MSVC " _ANKI_STR(_MSC_FULL_VER)
  40. #else
  41. # error Unknown compiler
  42. #endif
  43. // Operating system
  44. #if defined(__WIN32__) || defined(_WIN32)
  45. # define ANKI_OS_LINUX 0
  46. # define ANKI_OS_ANDROID 0
  47. # define ANKI_OS_MACOS 0
  48. # define ANKI_OS_IOS 0
  49. # define ANKI_OS_WINDOWS 1
  50. # define ANKI_OS_STR "Windows"
  51. #elif defined(__APPLE_CC__)
  52. # if (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 40000) || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 40000)
  53. # define ANKI_OS_LINUX 0
  54. # define ANKI_OS_ANDROID 0
  55. # define ANKI_OS_MACOS 0
  56. # define ANKI_OS_IOS 1
  57. # define ANKI_OS_WINDOWS 0
  58. # define ANKI_OS_STR "iOS"
  59. # else
  60. # define ANKI_OS_LINUX 0
  61. # define ANKI_OS_ANDROID 0
  62. # define ANKI_OS_MACOS 1
  63. # define ANKI_OS_IOS 0
  64. # define ANKI_OS_WINDOWS 0
  65. # define ANKI_OS_STR "MacOS"
  66. # endif
  67. #elif defined(__ANDROID__)
  68. # define ANKI_OS_LINUX 0
  69. # define ANKI_OS_ANDROID 1
  70. # define ANKI_OS_MACOS 0
  71. # define ANKI_OS_IOS 0
  72. # define ANKI_OS_WINDOWS 0
  73. # define ANKI_OS_STR "Android"
  74. #elif defined(__linux__)
  75. # define ANKI_OS_LINUX 1
  76. # define ANKI_OS_ANDROID 0
  77. # define ANKI_OS_MACOS 0
  78. # define ANKI_OS_IOS 0
  79. # define ANKI_OS_WINDOWS 0
  80. # define ANKI_OS_STR "Linux"
  81. #else
  82. # error Unknown OS
  83. #endif
  84. // POSIX system or not
  85. #if ANKI_OS_LINUX || ANKI_OS_ANDROID || ANKI_OS_MACOS || ANKI_OS_IOS
  86. # define ANKI_POSIX 1
  87. #else
  88. # define ANKI_POSIX 0
  89. #endif
  90. // CPU architecture
  91. #if ANKI_COMPILER_GCC_COMPATIBLE
  92. # if defined(__arm__) || defined(__aarch64__)
  93. # define ANKI_CPU_ARCH_X86 0
  94. # define ANKI_CPU_ARCH_ARM 1
  95. # elif defined(__i386__) || defined(__amd64__)
  96. # define ANKI_CPU_ARCH_X86 1
  97. # define ANKI_CPU_ARCH_ARM 0
  98. # endif
  99. #elif ANKI_COMPILER_MSVC
  100. # if defined(_M_ARM)
  101. # define ANKI_CPU_ARCH_X86 0
  102. # define ANKI_CPU_ARCH_ARM 1
  103. # elif defined(_M_X64) || defined(_M_IX86)
  104. # define ANKI_CPU_ARCH_X86 1
  105. # define ANKI_CPU_ARCH_ARM 0
  106. # endif
  107. #endif
  108. #if defined(ANKI_CPU_ARCH_X86) && ANKI_CPU_ARCH_X86
  109. # define ANKI_GPU_ARCH_STR "x86"
  110. #elif defined(ANKI_CPU_ARCH_ARM) && ANKI_CPU_ARCH_ARM
  111. # define ANKI_GPU_ARCH_STR "arm"
  112. #else
  113. # error Unknown CPU arch
  114. #endif
  115. // SIMD
  116. #define ANKI_ENABLE_SIMD ${_ANKI_ENABLE_SIMD}
  117. #if !ANKI_ENABLE_SIMD
  118. # define ANKI_SIMD_NONE 1
  119. # define ANKI_SIMD_SSE 0
  120. # define ANKI_SIMD_NEON 0
  121. #elif ANKI_CPU_ARCH_X86
  122. # define ANKI_SIMD_NONE 0
  123. # define ANKI_SIMD_SSE 1
  124. # define ANKI_SIMD_NEON 0
  125. #else
  126. # define ANKI_SIMD_NONE 0
  127. # define ANKI_SIMD_SSE 0
  128. # define ANKI_SIMD_NEON 1
  129. #endif
  130. // Graphics backend
  131. #define ANKI_GR_BACKEND_GL 0
  132. #define ANKI_GR_BACKEND_VULKAN 1
  133. // Windowing system
  134. #if ${_ANKI_WINDOWING_SYSTEM} == 0
  135. # define ANKI_WINDOWING_SYSTEM_HEADLESS 1
  136. # define ANKI_WINDOWING_SYSTEM_SDL 0
  137. # define ANKI_WINDOWING_SYSTEM_ANDROID 0
  138. #elif ${_ANKI_WINDOWING_SYSTEM} == 1
  139. # define ANKI_WINDOWING_SYSTEM_HEADLESS 0
  140. # define ANKI_WINDOWING_SYSTEM_SDL 1
  141. # define ANKI_WINDOWING_SYSTEM_ANDROID 0
  142. #elif ${_ANKI_WINDOWING_SYSTEM} == 2
  143. # define ANKI_WINDOWING_SYSTEM_HEADLESS 0
  144. # define ANKI_WINDOWING_SYSTEM_SDL 0
  145. # define ANKI_WINDOWING_SYSTEM_ANDROID 1
  146. #endif
  147. // Mobile or not
  148. #define ANKI_PLATFORM_MOBILE (ANKI_CPU_ARCH_ARM)
  149. // Some compiler attributes
  150. #if ANKI_COMPILER_GCC_COMPATIBLE
  151. # define ANKI_RESTRICT __restrict
  152. # define ANKI_FORCE_INLINE __attribute__((always_inline))
  153. # define ANKI_DONT_INLINE __attribute__((noinline))
  154. # define ANKI_UNUSED __attribute__((__unused__))
  155. # define ANKI_COLD __attribute__((cold, optimize("Os")))
  156. # define ANKI_HOT __attribute__ ((hot))
  157. # define ANKI_UNREACHABLE() __builtin_unreachable()
  158. # define ANKI_PREFETCH_MEMORY(addr) __builtin_prefetch(addr)
  159. # define ANKI_CHECK_FORMAT(fmtArgIdx, firstArgIdx) __attribute__((format(printf, fmtArgIdx + 1, firstArgIdx + 1))) // On methods you need to include "this"
  160. # define ANKI_PURE __attribute__((pure))
  161. #else
  162. # define ANKI_RESTRICT
  163. # define ANKI_FORCE_INLINE
  164. # define ANKI_DONT_INLINE
  165. # define ANKI_UNUSED
  166. # define ANKI_COLD
  167. # define ANKI_HOT
  168. # define ANKI_UNREACHABLE() __assume(false)
  169. # define ANKI_PREFETCH_MEMORY(addr) (void)(addr)
  170. # define ANKI_CHECK_FORMAT(fmtArgIdx, firstArgIdx)
  171. # define ANKI_PURE
  172. #endif
  173. // Pack structs
  174. #if ANKI_COMPILER_MSVC
  175. # define ANKI_BEGIN_PACKED_STRUCT __pragma(pack (push, 1))
  176. # define ANKI_END_PACKED_STRUCT __pragma(pack (pop))
  177. #else
  178. # define ANKI_BEGIN_PACKED_STRUCT _Pragma("pack (push, 1)")
  179. # define ANKI_END_PACKED_STRUCT _Pragma("pack (pop)")
  180. #endif
  181. // Builtins
  182. #if ANKI_COMPILER_MSVC
  183. # include <intrin.h>
  184. # define __builtin_popcount __popcnt
  185. # define __builtin_popcountl(x) int(__popcnt64(x))
  186. # define __builtin_clzll(x) int(__lzcnt64(x))
  187. #pragma intrinsic(_BitScanForward)
  188. inline int __builtin_ctzll(unsigned long long x)
  189. {
  190. unsigned long o;
  191. _BitScanForward64(&o, x);
  192. return o;
  193. }
  194. #endif
  195. // Constants
  196. #define ANKI_SAFE_ALIGNMENT 16
  197. #define ANKI_CACHE_LINE_SIZE 64
  198. // Misc
  199. #define ANKI_FILE __FILE__
  200. #define ANKI_FUNC __func__
  201. // A macro used to mark some functions or variables as AnKi internal.
  202. #ifdef ANKI_SOURCE_FILE
  203. # define ANKI_INTERNAL
  204. #else
  205. # define ANKI_INTERNAL [[deprecated("This is an AnKi internal interface. Don't use it")]]
  206. #endif
  207. // Macro that temporarily disable the ANKI_INTERNAL. It's needed in some cases where an ANKI_INTERNAL is called in a
  208. // header
  209. #if ANKI_COMPILER_MSVC
  210. # define ANKI_CALL_INTERNAL(...) \
  211. __pragma(warning(push)) \
  212. __pragma(warning(disable:4996)) \
  213. __VA_ARGS__ \
  214. __pragma(warning(pop))
  215. #elif ANKI_COMPILER_GCC_COMPATIBLE
  216. # define ANKI_CALL_INTERNAL(...) \
  217. _Pragma("GCC diagnostic push") \
  218. _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
  219. __VA_ARGS__ \
  220. _Pragma("GCC diagnostic pop")
  221. #else
  222. # define ANKI_CALL_INTERNAL(...)
  223. #endif
  224. // Define the main() function.
  225. namespace anki {
  226. void preMain();
  227. void postMain();
  228. }
  229. #if ANKI_OS_ANDROID
  230. extern "C" {
  231. struct android_app;
  232. }
  233. namespace anki {
  234. extern android_app* g_androidApp;
  235. void* getAndroidCommandLineArguments(int& argc, char**& argv);
  236. void cleanupGetAndroidCommandLineArguments(void* ptr);
  237. }
  238. # define ANKI_MAIN_FUNCTION(myMain) \
  239. int myMain(int argc, char* argv[]); \
  240. extern "C" void android_main(android_app* app) \
  241. { \
  242. anki::g_androidApp = app; \
  243. preMain(); \
  244. char** argv; \
  245. int argc; \
  246. void* cleanupToken = anki::getAndroidCommandLineArguments(argc, argv); \
  247. myMain(argc, argv); \
  248. anki::cleanupGetAndroidCommandLineArguments(cleanupToken); \
  249. postMain(); \
  250. }
  251. #else
  252. # define ANKI_MAIN_FUNCTION(myMain) \
  253. int myMain(int argc, char* argv[]); \
  254. int main(int argc, char* argv[]) \
  255. { \
  256. preMain(); \
  257. const int exitCode = myMain(argc, argv); \
  258. postMain(); \
  259. return exitCode; \
  260. }
  261. #endif
  262. /// @}