cmake_minimum_required(VERSION 3.25) project(core) set(CMAKE_C_STANDARD 23) set(SRC "src/Logger.c" "src/Utility.c" "src/Buffer.c" #"src/Clock.cpp" #"src/Random.cpp" #"src/BitArray.cpp" #"src/Vector.cpp" #"src/Quaternion.cpp" #"src/Matrix.cpp" #"src/Box.cpp" #"src/Plane.cpp" #"src/Frustum.cpp" #"src/View.cpp" #"src/Thread.cpp" #"src/Mutex.cpp" #"src/SpinLock.cpp" #"src/FileReader.cpp" #"src/ArrayString.cpp" ) set(SRC_TESTS "test/Main.c" "test/Test.c" "test/modules/BufferTests.c" "test/modules/UtilityTests.c" #"test/modules/ArrayListTests.cpp" #"test/modules/ArrayStringTests.cpp" #"test/modules/ArrayTests.cpp" #"test/modules/BitArrayTests.cpp" #"test/modules/BoxTests.cpp" #"test/modules/BufferedValueTests.cpp" #"test/modules/ClockTests.cpp" #"test/modules/ColorTests.cpp" #"test/modules/ComponentsTests.cpp" #"test/modules/FileReaderTests.cpp" #"test/modules/FrustumTests.cpp" #"test/modules/HashMapTests.cpp" #"test/modules/HashedStringTests.cpp" #"test/modules/LinkedListTests.cpp" #"test/modules/ListTests.cpp" #"test/modules/MathTests.cpp" #"test/modules/MatrixStackTests.cpp" #"test/modules/MatrixTests.cpp" #"test/modules/PlaneTests.cpp" #"test/modules/QuaternionTests.cpp" #"test/modules/RandomTests.cpp" #"test/modules/RingBufferTests.cpp" #"test/modules/StackTests.cpp" #"test/modules/ThreadTests.cpp" #"test/modules/VectorTests.cpp" #"test/modules/ViewTests.cpp" ) set(SRC_PERFORMANCE #"performance/Main.cpp" #"test/Test.cpp" ) if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") set(COMPILE_OPTIONS -flto) set(LINK_OPTIONS -flto) set(LOG_LEVEL 2) set(DEFINITIONS "") else() if(CMAKE_C_COMPILER_ID STREQUAL "GNU") set(COMPILE_OPTIONS --coverage) set(LINK_OPTIONS gcov) else() set(COMPILE_OPTIONS -fprofile-instr-generate -fcoverage-mapping) set(LINK_OPTIONS ${COMPILE_OPTIONS}) endif() set(LOG_LEVEL 4) set(DEFINITIONS ERROR_SIMULATOR CORE_CHECK_MEMORY) list(APPEND SRC "src/ErrorSimulator.c") endif() if(CMAKE_C_COMPILER_ID STREQUAL "GNU") set(MORE_WARNINGS -Walloc-zero -Wanalyzer-too-complex -Warith-conversion -Warray-bounds=2 -Wattribute-alias=2 -Wbidi-chars=any -Wcast-align=strict -Wduplicated-branches -Wduplicated-cond -Wformat-overflow=2 -Wformat-signedness -Wformat-truncation=2 -Wimplicit-fallthrough=5 -Wjump-misses-init -Wlogical-op -Wnormalized=nfkc -Wshift-overflow=2 -Wstack-usage=8388608 -Wstringop-overflow=4 -Wtrampolines -Wtrivial-auto-var-init -Wunused-const-variable=2 -Wuse-after-free=3 ) endif() add_library(core STATIC ${SRC}) target_compile_options(core PUBLIC ${COMPILE_OPTIONS} -Wall -Walloca -Warray-parameter -Wbad-function-cast -Wcast-qual -Wconversion -Wdate-time -Wdisabled-optimization -Wdouble-promotion -Wenum-compare -Wenum-conversion -Werror -Wextra -Wfloat-equal -Wformat=2 -Wframe-larger-than=8388608 -Winfinite-recursion -Winit-self -Winvalid-pch -Wlarger-than=1073741824 -Wmissing-braces -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes -Wmultichar -Wnarrowing -Wnested-externs -Wnull-dereference -Wold-style-definition -Woverlength-strings -Wredundant-decls -Wshadow -Wsign-conversion -Wstack-protector -Wstrict-overflow=2 -Wstrict-prototypes -Wswitch-enum -Wundef -Wunreachable-code -Wvla -Wwrite-strings -fdiagnostics-color=always -pedantic -pedantic-errors ${MORE_WARNINGS} ) target_compile_definitions(core PUBLIC CORE_LOG_LEVEL=${LOG_LEVEL} PRIVATE ${DEFINITIONS} ) target_link_libraries(core PRIVATE ${LINK_OPTIONS} ) target_sources(core PUBLIC FILE_SET HEADERS BASE_DIRS include FILES ./include/core/utils/Buffer.h ./include/core/utils/Check.h ./include/core/utils/Error.h ./include/core/utils/Logger.h ./include/core/utils/Types.h ./include/core/utils/Utility.h # ./include/core/data/Array.hpp # ./include/core/data/ArrayList.hpp # ./include/core/data/BitArray.hpp # ./include/core/data/Components.hpp # ./include/core/data/HashMap.hpp # ./include/core/data/LinkedList.hpp # ./include/core/data/List.hpp # ./include/core/data/ProbingHashMap.hpp # ./include/core/data/RingBuffer.hpp # ./include/core/data/Stack.hpp # ./include/core/io/File.hpp # ./include/core/io/FileReader.hpp # ./include/core/math/Box.hpp # ./include/core/math/BufferedValue.hpp # ./include/core/math/Frustum.hpp # ./include/core/math/Math.hpp # ./include/core/math/Matrix.hpp # ./include/core/math/MatrixStack.hpp # ./include/core/math/Plane.hpp # ./include/core/math/Quaternion.hpp # ./include/core/math/Vector.hpp # ./include/core/math/View.hpp # ./include/core/thread/Thread.hpp # ./include/core/utils/ArrayString.hpp # ./include/core/utils/Clock.hpp # ./include/core/utils/Color.hpp # ./include/core/utils/HashCode.hpp # ./include/core/utils/Random.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)