CMakeLists.txt 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
  66. set(DEBUG_COMPILE "")
  67. set(DEBUG_LINK "")
  68. set(LOG_LEVEL 2)
  69. set(ERROR_SIMULATOR "")
  70. else()
  71. set(DEBUG_COMPILE --coverage)
  72. set(DEBUG_LINK gcov)
  73. set(LOG_LEVEL 4)
  74. set(ERROR_SIMULATOR "ERROR_SIMULATOR")
  75. endif()
  76. add_library(core STATIC ${SRC})
  77. target_compile_options(core PUBLIC
  78. ${DEBUG_COMPILE}
  79. -fdiagnostics-color=always
  80. -fno-exceptions
  81. -fno-rtti
  82. -fno-threadsafe-statics
  83. -nostdinc++
  84. -pedantic
  85. -pedantic-errors
  86. -Waligned-new=all
  87. -Wall
  88. -Walloca
  89. -Walloc-zero
  90. -Wanalyzer-too-complex
  91. -Warith-conversion
  92. -Warray-bounds=2
  93. -Warray-parameter
  94. -Wattribute-alias=2
  95. -Wbidi-chars=any
  96. -Wcast-align=strict
  97. -Wcast-qual
  98. -Wcatch-value=3
  99. -Wcomma-subscript
  100. -Wconditionally-supported
  101. -Wconversion
  102. -Wctad-maybe-unsupported
  103. -Wctor-dtor-privacy
  104. -Wdate-time
  105. -Wdeprecated-copy-dtor
  106. -Wdeprecated-enum-enum-conversion
  107. -Wdeprecated-enum-float-conversion
  108. -Wdisabled-optimization
  109. -Wdouble-promotion
  110. -Wduplicated-branches
  111. -Wduplicated-cond
  112. -Weffc++
  113. -Wenum-compare
  114. -Wenum-conversion
  115. -Werror
  116. -Wextra
  117. -Wextra-semi
  118. -Wfloat-equal
  119. -Wformat=2
  120. -Wformat-overflow=2
  121. -Wformat-signedness
  122. -Wformat-truncation=2
  123. -Wframe-larger-than=8388608
  124. -Wimplicit-fallthrough=5
  125. -Winfinite-recursion
  126. -Winit-self
  127. -Winvalid-imported-macros
  128. -Winvalid-pch
  129. -Wlarger-than=1073741824
  130. -Wlogical-op
  131. -Wmismatched-tags
  132. -Wmissing-braces
  133. -Wmissing-declarations
  134. -Wmissing-include-dirs
  135. -Wmultichar
  136. -Wmultiple-inheritance
  137. -Wnoexcept
  138. -Wnon-virtual-dtor
  139. -Wnormalized=nfkc
  140. -Wnull-dereference
  141. -Wold-style-cast
  142. -Woverlength-strings
  143. -Woverloaded-virtual
  144. -Wplacement-new=2
  145. -Wredundant-decls
  146. -Wredundant-tags
  147. -Wregister
  148. -Wshadow
  149. -Wshift-overflow=2
  150. -Wsign-conversion
  151. -Wsign-promo
  152. -Wstack-protector
  153. -Wstack-usage=8388608
  154. -Wstrict-null-sentinel
  155. -Wstrict-overflow=5
  156. -Wstringop-overflow=4
  157. -Wsuggest-final-methods
  158. -Wsuggest-final-types
  159. -Wsuggest-override
  160. -Wswitch-enum
  161. -Wsynth
  162. -Wtrampolines
  163. -Wtrivial-auto-var-init
  164. -Wundef
  165. -Wunreachable-code
  166. -Wunused-const-variable=2
  167. -Wunused-macros
  168. -Wuse-after-free=3
  169. -Wvirtual-inheritance
  170. -Wvla
  171. -Wvolatile
  172. -Wwrite-strings
  173. -Wzero-as-null-pointer-constant
  174. )
  175. target_compile_definitions(core
  176. PUBLIC CORE_LOG_LEVEL=${LOG_LEVEL}
  177. PRIVATE ${ERROR_SIMULATOR}
  178. )
  179. target_link_libraries(core
  180. PUBLIC -nodefaultlibs c m
  181. PRIVATE ${DEBUG_LINK}
  182. )
  183. target_sources(core PUBLIC
  184. FILE_SET HEADERS
  185. BASE_DIRS include
  186. FILES
  187. ./include/core/data/Stack.hpp
  188. ./include/core/data/HashMap.hpp
  189. ./include/core/data/Components.hpp
  190. ./include/core/data/ArrayList.hpp
  191. ./include/core/data/ProbingHashMap.hpp
  192. ./include/core/data/List.hpp
  193. ./include/core/data/LinkedList.hpp
  194. ./include/core/data/BitArray.hpp
  195. ./include/core/data/Array.hpp
  196. ./include/core/data/RingBuffer.hpp
  197. ./include/core/thread/Thread.hpp
  198. ./include/core/utils/HashCode.hpp
  199. ./include/core/utils/New.hpp
  200. ./include/core/utils/Check.hpp
  201. ./include/core/utils/Buffer.hpp
  202. ./include/core/utils/Random.hpp
  203. ./include/core/utils/UniquePointer.hpp
  204. ./include/core/utils/Types.hpp
  205. ./include/core/utils/Color.hpp
  206. ./include/core/utils/Logger.hpp
  207. ./include/core/utils/ArrayString.hpp
  208. ./include/core/utils/Utility.hpp
  209. ./include/core/utils/Meta.hpp
  210. ./include/core/utils/AlignedData.hpp
  211. ./include/core/utils/Clock.hpp
  212. ./include/core/utils/Error.hpp
  213. ./include/core/math/Quaternion.hpp
  214. ./include/core/math/Box.hpp
  215. ./include/core/math/Frustum.hpp
  216. ./include/core/math/Vector.hpp
  217. ./include/core/math/Matrix.hpp
  218. ./include/core/math/View.hpp
  219. ./include/core/math/BufferedValue.hpp
  220. ./include/core/math/Plane.hpp
  221. ./include/core/math/MatrixStack.hpp
  222. ./include/core/math/Math.hpp
  223. ./include/core/io/File.hpp
  224. ./include/core/io/FileReader.hpp
  225. )
  226. install(TARGETS core FILE_SET HEADERS)
  227. add_executable(test ${SRC_TESTS})
  228. target_link_libraries(test PRIVATE core)
  229. target_compile_definitions(test PRIVATE ${ERROR_SIMULATOR})
  230. add_executable(performance ${SRC_PERFORMANCE})
  231. target_link_libraries(performance PRIVATE core)