CMakeLists.txt 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. cmake_minimum_required(VERSION 3.25)
  2. project(core)
  3. set(CMAKE_CXX_STANDARD 20)
  4. set(SRC
  5. "src/Logger.cpp"
  6. "src/Utility.cpp"
  7. "src/Error.cpp"
  8. "src/New.cpp"
  9. "src/Buffer.cpp"
  10. "src/Clock.cpp"
  11. "src/Random.cpp"
  12. "src/BitArray.cpp"
  13. "src/Math.cpp"
  14. "src/Vector.cpp"
  15. "src/Quaternion.cpp"
  16. "src/Matrix.cpp"
  17. "src/Box.cpp"
  18. "src/Plane.cpp"
  19. "src/Frustum.cpp"
  20. "src/View.cpp"
  21. "src/Thread.cpp"
  22. "src/Mutex.cpp"
  23. "src/FileReader.cpp"
  24. "src/ErrorSimulator.cpp"
  25. )
  26. set(SRC_TESTS
  27. "test/Main.cpp"
  28. "test/Test.cpp"
  29. "test/modules/ArrayTests.cpp"
  30. "test/modules/ArrayStringTests.cpp"
  31. "test/modules/UtilityTests.cpp"
  32. "test/modules/ArrayListTests.cpp"
  33. "test/modules/BitArrayTests.cpp"
  34. "test/modules/MathTests.cpp"
  35. "test/modules/ListTests.cpp"
  36. "test/modules/LinkedListTests.cpp"
  37. "test/modules/UniquePointerTests.cpp"
  38. "test/modules/HashMapTests.cpp"
  39. "test/modules/ProbingHashMapTests.cpp"
  40. "test/modules/StackTests.cpp"
  41. "test/modules/RingBufferTests.cpp"
  42. "test/modules/ComponentsTests.cpp"
  43. "test/modules/VectorTests.cpp"
  44. "test/modules/QuaternionTests.cpp"
  45. "test/modules/MatrixTests.cpp"
  46. "test/modules/BoxTests.cpp"
  47. "test/modules/BufferedValueTests.cpp"
  48. "test/modules/PlaneTests.cpp"
  49. "test/modules/FrustumTests.cpp"
  50. "test/modules/ViewTests.cpp"
  51. "test/modules/MatrixStackTests.cpp"
  52. "test/modules/ColorTests.cpp"
  53. "test/modules/BufferTests.cpp"
  54. "test/modules/ClockTests.cpp"
  55. "test/modules/RandomTests.cpp"
  56. "test/modules/ThreadTests.cpp"
  57. "test/modules/FileReaderTests.cpp"
  58. "test/modules/ErrorTests.cpp"
  59. "test/modules/NewTests.cpp"
  60. )
  61. set(SRC_PERFORMANCE
  62. "performance/Main.cpp"
  63. "test/Test.cpp"
  64. )
  65. set(DEBUG_COMPILE "")
  66. set(DEBUG_LINK "")
  67. set(LOG_LEVEL 4)
  68. if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  69. set(DEBUG_COMPILE --coverage)
  70. set(DEBUG_LINK gcov)
  71. set(LOG_LEVEL 4)
  72. endif()
  73. add_library(core STATIC ${SRC})
  74. target_compile_options(core PUBLIC
  75. ${DEBUG_COMPILE}
  76. -fdiagnostics-color=always
  77. -fno-exceptions
  78. -fno-rtti
  79. -fno-threadsafe-statics
  80. -nostdinc++
  81. -pedantic
  82. -pedantic-errors
  83. -Waligned-new=all
  84. -Wall
  85. -Walloca
  86. -Walloc-zero
  87. -Wanalyzer-too-complex
  88. -Warith-conversion
  89. -Warray-bounds=2
  90. -Warray-parameter
  91. -Wattribute-alias=2
  92. -Wbidi-chars=any
  93. -Wcast-align=strict
  94. -Wcast-qual
  95. -Wcatch-value=3
  96. -Wcomma-subscript
  97. -Wconditionally-supported
  98. -Wconversion
  99. -Wctad-maybe-unsupported
  100. -Wctor-dtor-privacy
  101. -Wdate-time
  102. -Wdeprecated-copy-dtor
  103. -Wdeprecated-enum-enum-conversion
  104. -Wdeprecated-enum-float-conversion
  105. -Wdisabled-optimization
  106. -Wdouble-promotion
  107. -Wduplicated-branches
  108. -Wduplicated-cond
  109. -Weffc++
  110. -Wenum-compare
  111. -Wenum-conversion
  112. -Werror
  113. -Wextra
  114. -Wextra-semi
  115. -Wfloat-equal
  116. -Wformat=2
  117. -Wformat-overflow=2
  118. -Wformat-signedness
  119. -Wformat-truncation=2
  120. -Wframe-larger-than=8388608
  121. -Wimplicit-fallthrough=5
  122. -Winfinite-recursion
  123. -Winit-self
  124. -Winvalid-imported-macros
  125. -Winvalid-pch
  126. -Wlarger-than=1073741824
  127. -Wlogical-op
  128. -Wmismatched-tags
  129. -Wmissing-braces
  130. -Wmissing-declarations
  131. -Wmissing-include-dirs
  132. -Wmultichar
  133. -Wmultiple-inheritance
  134. -Wnoexcept
  135. -Wnon-virtual-dtor
  136. -Wnormalized=nfkc
  137. -Wnull-dereference
  138. -Wold-style-cast
  139. -Woverlength-strings
  140. -Woverloaded-virtual
  141. -Wplacement-new=2
  142. -Wredundant-decls
  143. -Wredundant-tags
  144. -Wregister
  145. -Wshadow
  146. -Wshift-overflow=2
  147. -Wsign-conversion
  148. -Wsign-promo
  149. -Wstack-protector
  150. -Wstack-usage=8388608
  151. -Wstrict-null-sentinel
  152. -Wstrict-overflow=5
  153. -Wstringop-overflow=4
  154. -Wsuggest-final-methods
  155. -Wsuggest-final-types
  156. -Wsuggest-override
  157. -Wswitch-enum
  158. -Wsynth
  159. -Wtrampolines
  160. -Wtrivial-auto-var-init
  161. -Wundef
  162. -Wunreachable-code
  163. -Wunused-const-variable=2
  164. -Wunused-macros
  165. -Wuse-after-free=3
  166. -Wvirtual-inheritance
  167. -Wvla
  168. -Wvolatile
  169. -Wwrite-strings
  170. -Wzero-as-null-pointer-constant
  171. )
  172. target_compile_definitions(core
  173. PUBLIC CORE_LOG_LEVEL=${LOG_LEVEL}
  174. PRIVATE ERROR_SIMULATOR=true
  175. )
  176. target_link_libraries(core
  177. PUBLIC -nodefaultlibs c m
  178. PRIVATE ${DEBUG_LINK}
  179. )
  180. target_sources(core PUBLIC
  181. FILE_SET HEADERS
  182. BASE_DIRS include
  183. FILES
  184. ./include/core/data/Stack.hpp
  185. ./include/core/data/HashMap.hpp
  186. ./include/core/data/Components.hpp
  187. ./include/core/data/ArrayList.hpp
  188. ./include/core/data/ProbingHashMap.hpp
  189. ./include/core/data/List.hpp
  190. ./include/core/data/LinkedList.hpp
  191. ./include/core/data/BitArray.hpp
  192. ./include/core/data/Array.hpp
  193. ./include/core/data/RingBuffer.hpp
  194. ./include/core/thread/Thread.hpp
  195. ./include/core/utils/HashCode.hpp
  196. ./include/core/utils/New.hpp
  197. ./include/core/utils/Check.hpp
  198. ./include/core/utils/Buffer.hpp
  199. ./include/core/utils/Random.hpp
  200. ./include/core/utils/UniquePointer.hpp
  201. ./include/core/utils/Types.hpp
  202. ./include/core/utils/Color.hpp
  203. ./include/core/utils/Logger.hpp
  204. ./include/core/utils/ArrayString.hpp
  205. ./include/core/utils/Utility.hpp
  206. ./include/core/utils/Meta.hpp
  207. ./include/core/utils/AlignedData.hpp
  208. ./include/core/utils/Clock.hpp
  209. ./include/core/utils/Error.hpp
  210. ./include/core/math/Quaternion.hpp
  211. ./include/core/math/Box.hpp
  212. ./include/core/math/Frustum.hpp
  213. ./include/core/math/Vector.hpp
  214. ./include/core/math/Matrix.hpp
  215. ./include/core/math/View.hpp
  216. ./include/core/math/BufferedValue.hpp
  217. ./include/core/math/Plane.hpp
  218. ./include/core/math/MatrixStack.hpp
  219. ./include/core/math/Math.hpp
  220. ./include/core/io/File.hpp
  221. ./include/core/io/FileReader.hpp
  222. )
  223. install(TARGETS core FILE_SET HEADERS)
  224. add_executable(test ${SRC_TESTS})
  225. target_link_libraries(test PRIVATE core)
  226. target_compile_definitions(test PRIVATE ERROR_SIMULATOR=true)
  227. add_executable(performance ${SRC_PERFORMANCE})
  228. target_link_libraries(performance PRIVATE core)