cmake_minimum_required(VERSION 3.25) project(core C) set(CMAKE_C_STANDARD 23) set(SRC "src/BitArray.c" "src/Box.c" "src/Buffer.c" "src/Frustum.c" "src/HashMap.c" "src/Logger.c" "src/Matrix.c" "src/Plane.c" "src/Quaternion.c" "src/Random.c" "src/ReadLine.c" "src/SpinLock.c" "src/Test.c" "src/ToString.c" "src/Utility.c" "src/Vector.c" "src/View.c" ) set(SRC_TESTS "test/Main.c" "test/modules/BitArrayTests.c" "test/modules/BoxTests.c" "test/modules/BufferTests.c" "test/modules/ComponentsTests.c" "test/modules/FrustumTests.c" "test/modules/HashMapTests.c" "test/modules/ListTests.c" "test/modules/MatrixTests.c" "test/modules/PlaneTests.c" "test/modules/QuaternionTests.c" "test/modules/QueueTests.c" "test/modules/RandomTests.c" "test/modules/ReadLineTests.c" "test/modules/SpinLockTests.c" "test/modules/TestTests.c" "test/modules/UtilityTests.c" "test/modules/VectorTests.c" "test/modules/ViewTests.c" ) set(SRC_PERFORMANCE "performance/Main.c" ) 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_C_COMPILER_ID STREQUAL "GNU") set(COMPILE_OPTIONS --coverage) set(LINK_OPTIONS gcov) elseif(CMAKE_C_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.c") endif() if(CMAKE_C_COMPILER_ID STREQUAL "GNU") include("cmake/gcc_warnings.cmake") elseif(CMAKE_C_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.h ./include/core/Box.h ./include/core/Buffer.h ./include/core/Check.h ./include/core/Components.h ./include/core/Frustum.h ./include/core/Generic.h ./include/core/HashMap.h ./include/core/List.h ./include/core/Logger.h ./include/core/Matrix.h ./include/core/Plane.h ./include/core/Quaternion.h ./include/core/Queue.h ./include/core/Random.h ./include/core/ReadLine.h ./include/core/SpinLock.h ./include/core/Test.h ./include/core/ToString.h ./include/core/Types.h ./include/core/Utility.h ./include/core/Vector.h ./include/core/View.h ) 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})