cmake_minimum_required(VERSION 3.25) project(core CXX) set(CMAKE_CXX_STANDARD 23) set(SRC "src/BitArray.cpp" "src/Box.cpp" "src/Buffer.cpp" "src/Clock.cpp" "src/File.cpp" "src/Frustum.cpp" "src/Logger.cpp" "src/Matrix.cpp" "src/Plane.cpp" "src/Quaternion.cpp" "src/Random.cpp" "src/ReadLine.cpp" "src/Terminal.cpp" "src/Test.cpp" "src/Thread.cpp" "src/ToString.cpp" "src/Unicode.cpp" "src/Utility.cpp" "src/Vector.cpp" "src/View.cpp" ) set(SRC_TESTS "test/Main.cpp" "test/modules/ArrayListTests.cpp" "test/modules/ArrayTests.cpp" "test/modules/BitArrayTests.cpp" "test/modules/BoxTests.cpp" "test/modules/BufferTests.cpp" "test/modules/ClockTests.cpp" "test/modules/ColorTests.cpp" "test/modules/ComponentsTests.cpp" "test/modules/FileTests.cpp" "test/modules/FrustumTests.cpp" "test/modules/HashMapTests.cpp" "test/modules/HashedStringTests.cpp" "test/modules/ListTests.cpp" "test/modules/MathTests.cpp" "test/modules/MatrixTests.cpp" "test/modules/PlaneTests.cpp" "test/modules/QuaternionTests.cpp" "test/modules/QueueTests.cpp" "test/modules/RandomTests.cpp" "test/modules/ReadLineTests.cpp" "test/modules/TerminalTests.cpp" "test/modules/TestTests.cpp" "test/modules/ThreadTests.cpp" "test/modules/UnicodeTests.cpp" "test/modules/UniquePointerTests.cpp" "test/modules/UtilityTests.cpp" "test/modules/VectorTests.cpp" "test/modules/ViewTests.cpp" ) set(SRC_PERFORMANCE "performance/Main.cpp" ) if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") set(COMPILE_OPTIONS "") set(LINK_OPTIONS "") set(LOG_LEVEL 2) set(DEFINITIONS CHECK_MEMORY) elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") set(COMPILE_OPTIONS "") set(LINK_OPTIONS "") set(LOG_LEVEL 3) set(DEFINITIONS CHECK_MEMORY) else() set(DEFINITIONS ERROR_SIMULATOR CHECK_MEMORY) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(COMPILE_OPTIONS --coverage) set(LINK_OPTIONS gcov) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set(COMPILE_OPTIONS -fprofile-instr-generate -fcoverage-mapping) set(LINK_OPTIONS ${COMPILE_OPTIONS}) endif() set(LOG_LEVEL 4) list(APPEND SRC "src/ErrorSimulator.cpp") endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") include("cmake/gcc_warnings.cmake") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") include("cmake/clang_warnings.cmake") endif() add_library(core STATIC ${SRC}) target_compile_options(core PUBLIC ${COMPILE_OPTIONS} ${WARNINGS} -fdiagnostics-color=always ) target_compile_definitions(core PRIVATE LOG_LEVEL=${LOG_LEVEL} PRIVATE ${DEFINITIONS} ) target_link_libraries(core PRIVATE m ${LINK_OPTIONS} ) target_sources(core PUBLIC FILE_SET HEADERS BASE_DIRS include FILES ./include/core/AlignedData.hpp ./include/core/Array.hpp ./include/core/ArrayList.hpp ./include/core/BitArray.hpp ./include/core/Box.hpp ./include/core/Buffer.hpp ./include/core/Clock.hpp ./include/core/Color.hpp ./include/core/Components.hpp ./include/core/File.hpp ./include/core/Frustum.hpp ./include/core/HashMap.hpp ./include/core/HashedString.hpp ./include/core/List.hpp ./include/core/Logger.hpp ./include/core/Math.hpp ./include/core/Matrix.hpp ./include/core/Meta.hpp ./include/core/Plane.hpp ./include/core/Quaternion.hpp ./include/core/Queue.hpp ./include/core/Random.hpp ./include/core/ReadLine.hpp ./include/core/Terminal.hpp ./include/core/Test.hpp ./include/core/Thread.hpp ./include/core/ToString.hpp ./include/core/Types.hpp ./include/core/Unicode.hpp ./include/core/UniquePointer.hpp ./include/core/Utility.hpp ./include/core/Vector.hpp ./include/core/View.hpp ) install(TARGETS core FILE_SET HEADERS) add_executable(test ${SRC_TESTS}) target_link_libraries(test PRIVATE core) target_compile_definitions(test PRIVATE ${DEFINITIONS}) target_compile_definitions(test PRIVATE LOG_LEVEL=4 ) add_executable(performance ${SRC_PERFORMANCE}) target_link_libraries(performance PRIVATE core) target_include_directories(performance PRIVATE include) target_compile_definitions(performance PRIVATE ${DEFINITIONS}) target_compile_definitions(performance PRIVATE LOG_LEVEL=4 )