CMakeLists.txt 3.9 KB

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