CMakeLists.txt 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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/VectorTests.cpp"
  50. #"test/modules/ViewTests.cpp"
  51. )
  52. set(SRC_PERFORMANCE
  53. "performance/Main.cpp"
  54. )
  55. if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
  56. set(COMPILE_OPTIONS "")
  57. set(LINK_OPTIONS "")
  58. set(LOG_LEVEL 2)
  59. set(DEFINITIONS CHECK_MEMORY)
  60. else()
  61. set(DEFINITIONS ERROR_SIMULATOR CHECK_MEMORY)
  62. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  63. set(COMPILE_OPTIONS --coverage)
  64. set(LINK_OPTIONS gcov)
  65. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  66. set(COMPILE_OPTIONS -fprofile-instr-generate -fcoverage-mapping)
  67. set(LINK_OPTIONS ${COMPILE_OPTIONS})
  68. endif()
  69. set(LOG_LEVEL 4)
  70. list(APPEND SRC "src/ErrorSimulator.cpp")
  71. endif()
  72. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  73. include("cmake/gcc_warnings.cmake")
  74. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  75. include("cmake/clang_warnings.cmake")
  76. endif()
  77. add_library(core STATIC ${SRC})
  78. target_compile_options(core PUBLIC
  79. ${COMPILE_OPTIONS}
  80. ${WARNINGS}
  81. -fdiagnostics-color=always
  82. )
  83. target_compile_definitions(core
  84. PUBLIC LOG_LEVEL=${LOG_LEVEL}
  85. PRIVATE ${DEFINITIONS}
  86. )
  87. target_link_libraries(core
  88. PRIVATE m ${LINK_OPTIONS}
  89. )
  90. target_sources(core PUBLIC
  91. FILE_SET HEADERS
  92. BASE_DIRS include
  93. FILES
  94. ./include/core/BitArray.hpp
  95. ./include/core/Box.hpp
  96. ./include/core/Buffer.hpp
  97. ./include/core/Check.hpp
  98. ./include/core/Components.hpp
  99. ./include/core/File.hpp
  100. ./include/core/Frustum.hpp
  101. ./include/core/Generic.hpp
  102. ./include/core/HashMap.hpp
  103. ./include/core/List.hpp
  104. ./include/core/Logger.hpp
  105. ./include/core/Matrix.hpp
  106. ./include/core/Plane.hpp
  107. ./include/core/Quaternion.hpp
  108. ./include/core/Queue.hpp
  109. ./include/core/Random.hpp
  110. ./include/core/ReadLine.hpp
  111. ./include/core/SpinLock.hpp
  112. ./include/core/Terminal.hpp
  113. ./include/core/Test.hpp
  114. ./include/core/Thread.hpp
  115. ./include/core/ToString.hpp
  116. ./include/core/Types.hpp
  117. ./include/core/Unicode.hpp
  118. ./include/core/Utility.hpp
  119. ./include/core/Vector.hpp
  120. ./include/core/View.hpp
  121. )
  122. install(TARGETS core FILE_SET HEADERS)
  123. add_executable(test ${SRC_TESTS})
  124. target_link_libraries(test PRIVATE core)
  125. target_compile_definitions(test PRIVATE ${DEFINITIONS})
  126. #add_executable(performance ${SRC_PERFORMANCE})
  127. #target_link_libraries(performance PRIVATE core)
  128. #target_include_directories(performance PRIVATE include)
  129. #target_compile_definitions(performance PRIVATE ${DEFINITIONS})