CMakeLists.txt 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. cmake_minimum_required(VERSION 3.25)
  2. project(core)
  3. set(CMAKE_CXX_STANDARD 20)
  4. set(SRC
  5. "src/Logger.c"
  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/Vector.cpp"
  14. #"src/Quaternion.cpp"
  15. #"src/Matrix.cpp"
  16. #"src/Box.cpp"
  17. #"src/Plane.cpp"
  18. #"src/Frustum.cpp"
  19. #"src/View.cpp"
  20. #"src/Thread.cpp"
  21. #"src/Mutex.cpp"
  22. #"src/SpinLock.cpp"
  23. #"src/FileReader.cpp"
  24. #"src/ErrorSimulator.cpp"
  25. #"src/ArrayString.cpp"
  26. )
  27. set(SRC_TESTS
  28. "test/Main.c"
  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/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. #"test/modules/HashedStringTests.cpp"
  61. )
  62. set(SRC_PERFORMANCE
  63. #"performance/Main.cpp"
  64. #"test/Test.cpp"
  65. )
  66. if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
  67. set(COMPILE_OPTIONS -flto)
  68. set(LINK_OPTIONS -flto)
  69. set(LOG_LEVEL 2)
  70. set(ERROR_SIMULATOR "")
  71. else()
  72. if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
  73. set(COMPILE_OPTIONS --coverage)
  74. endif()
  75. set(LINK_OPTIONS gcov)
  76. set(LOG_LEVEL 4)
  77. set(ERROR_SIMULATOR "ERROR_SIMULATOR")
  78. endif()
  79. if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
  80. set(MORE_WARNINGS
  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. -Wduplicated-branches
  89. -Wduplicated-cond
  90. -Wformat-overflow=2
  91. -Wformat-signedness
  92. -Wformat-truncation=2
  93. -Wimplicit-fallthrough=5
  94. -Wjump-misses-init
  95. -Wlogical-op
  96. -Wnormalized=nfkc
  97. -Wshift-overflow=2
  98. -Wstack-usage=8388608
  99. -Wstringop-overflow=4
  100. -Wtrampolines
  101. -Wtrivial-auto-var-init
  102. -Wunused-const-variable=2
  103. -Wuse-after-free=3
  104. )
  105. endif()
  106. add_library(core STATIC ${SRC})
  107. target_compile_options(core PUBLIC
  108. ${COMPILE_OPTIONS}
  109. -Wall
  110. -Walloca
  111. -Warray-parameter
  112. -Wbad-function-cast
  113. -Wcast-qual
  114. -Wconversion
  115. -Wdate-time
  116. -Wdisabled-optimization
  117. -Wdouble-promotion
  118. -Wenum-compare
  119. -Wenum-conversion
  120. -Werror
  121. -Wextra
  122. -Wfloat-equal
  123. -Wformat=2
  124. -Wframe-larger-than=8388608
  125. -Winfinite-recursion
  126. -Winit-self
  127. -Winvalid-pch
  128. -Wlarger-than=1073741824
  129. -Wmissing-braces
  130. -Wmissing-declarations
  131. -Wmissing-include-dirs
  132. -Wmissing-prototypes
  133. -Wmultichar
  134. -Wnarrowing
  135. -Wnested-externs
  136. -Wnull-dereference
  137. -Wold-style-definition
  138. -Woverlength-strings
  139. -Wredundant-decls
  140. -Wshadow
  141. -Wsign-conversion
  142. -Wstack-protector
  143. -Wstrict-overflow=2
  144. -Wstrict-prototypes
  145. -Wswitch-enum
  146. -Wundef
  147. -Wunreachable-code
  148. -Wvla
  149. -Wwrite-strings
  150. -fdiagnostics-color=always
  151. -pedantic
  152. -pedantic-errors
  153. ${MORE_WARNINGS}
  154. )
  155. target_compile_definitions(core
  156. PUBLIC CORE_LOG_LEVEL=${LOG_LEVEL}
  157. PRIVATE ${ERROR_SIMULATOR}
  158. )
  159. target_link_libraries(core
  160. PUBLIC -nodefaultlibs c m
  161. PRIVATE ${LINK_OPTIONS}
  162. )
  163. #target_sources(core PUBLIC
  164. # FILE_SET HEADERS
  165. # BASE_DIRS include
  166. # FILES
  167. # ./include/core/data/Stack.hpp
  168. # ./include/core/data/HashMap.hpp
  169. # ./include/core/data/Components.hpp
  170. # ./include/core/data/ArrayList.hpp
  171. # ./include/core/data/ProbingHashMap.hpp
  172. # ./include/core/data/List.hpp
  173. # ./include/core/data/LinkedList.hpp
  174. # ./include/core/data/BitArray.hpp
  175. # ./include/core/data/Array.hpp
  176. # ./include/core/data/RingBuffer.hpp
  177. # ./include/core/thread/Thread.hpp
  178. # ./include/core/utils/HashCode.hpp
  179. # ./include/core/utils/New.hpp
  180. # ./include/core/utils/Check.hpp
  181. # ./include/core/utils/Buffer.hpp
  182. # ./include/core/utils/Random.hpp
  183. # ./include/core/utils/UniquePointer.hpp
  184. # ./include/core/utils/Types.hpp
  185. # ./include/core/utils/Color.hpp
  186. # ./include/core/utils/Logger.hpp
  187. # ./include/core/utils/ArrayString.hpp
  188. # ./include/core/utils/Utility.hpp
  189. # ./include/core/utils/Meta.hpp
  190. # ./include/core/utils/AlignedData.hpp
  191. # ./include/core/utils/Clock.hpp
  192. # ./include/core/utils/Error.hpp
  193. # ./include/core/math/Quaternion.hpp
  194. # ./include/core/math/Box.hpp
  195. # ./include/core/math/Frustum.hpp
  196. # ./include/core/math/Vector.hpp
  197. # ./include/core/math/Matrix.hpp
  198. # ./include/core/math/View.hpp
  199. # ./include/core/math/BufferedValue.hpp
  200. # ./include/core/math/Plane.hpp
  201. # ./include/core/math/MatrixStack.hpp
  202. # ./include/core/math/Math.hpp
  203. # ./include/core/io/File.hpp
  204. # ./include/core/io/FileReader.hpp
  205. #)
  206. #install(TARGETS core FILE_SET HEADERS)
  207. add_executable(test ${SRC_TESTS})
  208. target_link_libraries(test PRIVATE core)
  209. target_compile_definitions(test PRIVATE ${ERROR_SIMULATOR})
  210. #add_executable(performance ${SRC_PERFORMANCE})
  211. #target_link_libraries(performance PRIVATE core)