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/Components.cpp" "src/File.cpp" #"src/Frustum.cpp" #"src/HashMap.cpp" "src/Logger.cpp" "src/Matrix.cpp" #"src/Plane.cpp" "src/Quaternion.cpp" "src/Random.cpp" #"src/ReadLine.cpp" #"src/SpinLock.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/BitArrayTests.cpp" #"test/modules/BoxTests.cpp" #"test/modules/BufferTests.cpp" #"test/modules/ComponentsTests.cpp" "test/modules/FileTests.cpp" #"test/modules/FrustumTests.cpp" #"test/modules/HashMapTests.cpp" #"test/modules/ListTests.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/SpinLockTests.cpp" #"test/modules/TerminalTests.cpp" "test/modules/TestTests.cpp" #"test/modules/UnicodeTests.cpp" "test/modules/UtilityTests.cpp" #"test/modules/VectorTests.cpp" #"test/modules/ViewTests.cpp" "test/modules/ListTests.cpp" "test/modules/UniquePointerTests.cpp" "test/modules/VectorTests.cpp" "test/modules/MathTests.cpp" "test/modules/ArrayTests.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) 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 PUBLIC 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/BitArray.hpp ./include/core/Box.hpp ./include/core/Buffer.hpp ./include/core/Check.hpp ./include/core/Components.hpp ./include/core/File.hpp ./include/core/Frustum.hpp ./include/core/Generic.hpp ./include/core/HashMap.hpp ./include/core/List.hpp ./include/core/Logger.hpp ./include/core/Matrix.hpp ./include/core/Plane.hpp ./include/core/Quaternion.hpp ./include/core/Queue.hpp ./include/core/Random.hpp ./include/core/ReadLine.hpp ./include/core/SpinLock.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/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}) #add_executable(performance ${SRC_PERFORMANCE}) #target_link_libraries(performance PRIVATE core) #target_include_directories(performance PRIVATE include) #target_compile_definitions(performance PRIVATE ${DEFINITIONS})