CMakeLists.txt 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. cmake_minimum_required(VERSION 3.25)
  2. project(core CXX)
  3. set(CMAKE_CXX_STANDARD 23)
  4. set(SRC
  5. "src/BitArray.cpp"
  6. "src/Box.cpp"
  7. "src/Buffer.cpp"
  8. "src/Clock.cpp"
  9. "src/File.cpp"
  10. "src/Frustum.cpp"
  11. "src/Logger.cpp"
  12. "src/Matrix.cpp"
  13. "src/Plane.cpp"
  14. "src/Quaternion.cpp"
  15. "src/Random.cpp"
  16. "src/ReadLine.cpp"
  17. "src/Terminal.cpp"
  18. "src/Test.cpp"
  19. "src/Thread.cpp"
  20. "src/ToString.cpp"
  21. "src/Unicode.cpp"
  22. "src/Utility.cpp"
  23. "src/Vector.cpp"
  24. "src/View.cpp"
  25. )
  26. set(SRC_TESTS
  27. "test/Main.cpp"
  28. "test/modules/ArrayListTests.cpp"
  29. "test/modules/ArrayTests.cpp"
  30. "test/modules/BitArrayTests.cpp"
  31. "test/modules/BoxTests.cpp"
  32. "test/modules/BufferTests.cpp"
  33. "test/modules/ClockTests.cpp"
  34. "test/modules/ColorTests.cpp"
  35. "test/modules/ComponentsTests.cpp"
  36. "test/modules/FileTests.cpp"
  37. "test/modules/FrustumTests.cpp"
  38. "test/modules/HashMapTests.cpp"
  39. "test/modules/HashedStringTests.cpp"
  40. "test/modules/ListTests.cpp"
  41. "test/modules/MathTests.cpp"
  42. "test/modules/MatrixTests.cpp"
  43. "test/modules/PlaneTests.cpp"
  44. "test/modules/QuaternionTests.cpp"
  45. "test/modules/QueueTests.cpp"
  46. "test/modules/RandomTests.cpp"
  47. "test/modules/ReadLineTests.cpp"
  48. "test/modules/TerminalTests.cpp"
  49. "test/modules/TestTests.cpp"
  50. "test/modules/ThreadTests.cpp"
  51. "test/modules/UnicodeTests.cpp"
  52. "test/modules/UniquePointerTests.cpp"
  53. "test/modules/UtilityTests.cpp"
  54. "test/modules/VectorTests.cpp"
  55. "test/modules/ViewTests.cpp"
  56. )
  57. set(SRC_PERFORMANCE
  58. "performance/Main.cpp"
  59. )
  60. if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
  61. set(COMPILE_OPTIONS "")
  62. set(LINK_OPTIONS "")
  63. set(LOG_LEVEL 2)
  64. set(DEFINITIONS CHECK_MEMORY)
  65. elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
  66. set(COMPILE_OPTIONS "")
  67. set(LINK_OPTIONS "")
  68. set(LOG_LEVEL 3)
  69. set(DEFINITIONS CHECK_MEMORY)
  70. else()
  71. set(DEFINITIONS ERROR_SIMULATOR CHECK_MEMORY)
  72. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  73. set(COMPILE_OPTIONS --coverage)
  74. set(LINK_OPTIONS gcov)
  75. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  76. set(COMPILE_OPTIONS -fprofile-instr-generate -fcoverage-mapping)
  77. set(LINK_OPTIONS ${COMPILE_OPTIONS})
  78. endif()
  79. set(LOG_LEVEL 4)
  80. list(APPEND SRC "src/ErrorSimulator.cpp")
  81. endif()
  82. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  83. include("cmake/gcc_warnings.cmake")
  84. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  85. include("cmake/clang_warnings.cmake")
  86. endif()
  87. add_library(core STATIC ${SRC})
  88. target_compile_options(core PUBLIC
  89. ${COMPILE_OPTIONS}
  90. ${WARNINGS}
  91. -fdiagnostics-color=always
  92. )
  93. target_compile_definitions(core
  94. PRIVATE LOG_LEVEL=${LOG_LEVEL}
  95. PRIVATE ${DEFINITIONS}
  96. )
  97. target_link_libraries(core
  98. PRIVATE m ${LINK_OPTIONS}
  99. )
  100. target_sources(core PUBLIC
  101. FILE_SET HEADERS
  102. BASE_DIRS include
  103. FILES
  104. ./include/core/AlignedData.hpp
  105. ./include/core/Array.hpp
  106. ./include/core/ArrayList.hpp
  107. ./include/core/BitArray.hpp
  108. ./include/core/Box.hpp
  109. ./include/core/Buffer.hpp
  110. ./include/core/Clock.hpp
  111. ./include/core/Color.hpp
  112. ./include/core/Components.hpp
  113. ./include/core/File.hpp
  114. ./include/core/Frustum.hpp
  115. ./include/core/HashMap.hpp
  116. ./include/core/HashedString.hpp
  117. ./include/core/List.hpp
  118. ./include/core/Logger.hpp
  119. ./include/core/Math.hpp
  120. ./include/core/Matrix.hpp
  121. ./include/core/Meta.hpp
  122. ./include/core/Plane.hpp
  123. ./include/core/Quaternion.hpp
  124. ./include/core/Queue.hpp
  125. ./include/core/Random.hpp
  126. ./include/core/ReadLine.hpp
  127. ./include/core/Terminal.hpp
  128. ./include/core/Test.hpp
  129. ./include/core/Thread.hpp
  130. ./include/core/ToString.hpp
  131. ./include/core/Types.hpp
  132. ./include/core/Unicode.hpp
  133. ./include/core/UniquePointer.hpp
  134. ./include/core/Utility.hpp
  135. ./include/core/Vector.hpp
  136. ./include/core/View.hpp
  137. )
  138. install(TARGETS core FILE_SET HEADERS)
  139. add_executable(test ${SRC_TESTS})
  140. target_link_libraries(test PRIVATE core)
  141. target_compile_definitions(test PRIVATE ${DEFINITIONS})
  142. target_compile_definitions(test
  143. PRIVATE LOG_LEVEL=4
  144. )
  145. add_executable(performance ${SRC_PERFORMANCE})
  146. target_link_libraries(performance PRIVATE core)
  147. target_include_directories(performance PRIVATE include)
  148. target_compile_definitions(performance PRIVATE ${DEFINITIONS})
  149. target_compile_definitions(performance
  150. PRIVATE LOG_LEVEL=4
  151. )