CMakeLists.txt 6.5 KB

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