CMakeLists.txt 6.5 KB

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