Config.h.cmake 9.2 KB

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