Config.h.cmake 8.4 KB

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