|
@@ -1,248 +1,138 @@
|
|
cmake_minimum_required(VERSION 3.25)
|
|
cmake_minimum_required(VERSION 3.25)
|
|
-project(core)
|
|
+project(core C)
|
|
|
|
|
|
-set(CMAKE_CXX_STANDARD 20)
|
|
+set(CMAKE_C_STANDARD 23)
|
|
|
|
|
|
set(SRC
|
|
set(SRC
|
|
- "src/Logger.cpp"
|
|
+ "src/BitArray.c"
|
|
- "src/Utility.cpp"
|
|
+ "src/Box.c"
|
|
- "src/Error.cpp"
|
|
+ "src/Buffer.c"
|
|
- "src/New.cpp"
|
|
+ "src/Components.c"
|
|
- "src/Buffer.cpp"
|
|
+ "src/File.c"
|
|
- "src/Clock.cpp"
|
|
+ "src/Frustum.c"
|
|
- "src/Random.cpp"
|
|
+ "src/HashMap.c"
|
|
- "src/BitArray.cpp"
|
|
+ "src/Logger.c"
|
|
- "src/Vector.cpp"
|
|
+ "src/Matrix.c"
|
|
- "src/Quaternion.cpp"
|
|
+ "src/Plane.c"
|
|
- "src/Matrix.cpp"
|
|
+ "src/Quaternion.c"
|
|
- "src/Box.cpp"
|
|
+ "src/Random.c"
|
|
- "src/Plane.cpp"
|
|
+ "src/ReadLine.c"
|
|
- "src/Frustum.cpp"
|
|
+ "src/SpinLock.c"
|
|
- "src/View.cpp"
|
|
+ "src/Terminal.c"
|
|
- "src/Thread.cpp"
|
|
+ "src/Test.c"
|
|
- "src/Mutex.cpp"
|
|
+ "src/Thread.c"
|
|
- "src/SpinLock.cpp"
|
|
+ "src/ToString.c"
|
|
- "src/FileReader.cpp"
|
|
+ "src/Unicode.c"
|
|
- "src/ErrorSimulator.cpp"
|
|
+ "src/Utility.c"
|
|
- "src/ArrayString.cpp"
|
|
+ "src/Vector.c"
|
|
|
|
+ "src/View.c"
|
|
)
|
|
)
|
|
|
|
|
|
set(SRC_TESTS
|
|
set(SRC_TESTS
|
|
- "test/Main.cpp"
|
|
+ "test/Main.c"
|
|
- "test/Test.cpp"
|
|
+ "test/modules/BitArrayTests.c"
|
|
- "test/modules/ArrayTests.cpp"
|
|
+ "test/modules/BoxTests.c"
|
|
- "test/modules/ArrayStringTests.cpp"
|
|
+ "test/modules/BufferTests.c"
|
|
- "test/modules/UtilityTests.cpp"
|
|
+ "test/modules/ComponentsTests.c"
|
|
- "test/modules/ArrayListTests.cpp"
|
|
+ "test/modules/FileTests.c"
|
|
- "test/modules/BitArrayTests.cpp"
|
|
+ "test/modules/FrustumTests.c"
|
|
- "test/modules/MathTests.cpp"
|
|
+ "test/modules/HashMapTests.c"
|
|
- "test/modules/ListTests.cpp"
|
|
+ "test/modules/ListTests.c"
|
|
- "test/modules/LinkedListTests.cpp"
|
|
+ "test/modules/MatrixTests.c"
|
|
- "test/modules/UniquePointerTests.cpp"
|
|
+ "test/modules/PlaneTests.c"
|
|
- "test/modules/HashMapTests.cpp"
|
|
+ "test/modules/QuaternionTests.c"
|
|
- "test/modules/StackTests.cpp"
|
|
+ "test/modules/QueueTests.c"
|
|
- "test/modules/RingBufferTests.cpp"
|
|
+ "test/modules/RandomTests.c"
|
|
- "test/modules/ComponentsTests.cpp"
|
|
+ "test/modules/ReadLineTests.c"
|
|
- "test/modules/VectorTests.cpp"
|
|
+ "test/modules/SpinLockTests.c"
|
|
- "test/modules/QuaternionTests.cpp"
|
|
+ "test/modules/TerminalTests.c"
|
|
- "test/modules/MatrixTests.cpp"
|
|
+ "test/modules/TestTests.c"
|
|
- "test/modules/BoxTests.cpp"
|
|
+ "test/modules/UnicodeTests.c"
|
|
- "test/modules/BufferedValueTests.cpp"
|
|
+ "test/modules/UtilityTests.c"
|
|
- "test/modules/PlaneTests.cpp"
|
|
+ "test/modules/VectorTests.c"
|
|
- "test/modules/FrustumTests.cpp"
|
|
+ "test/modules/ViewTests.c"
|
|
- "test/modules/ViewTests.cpp"
|
|
|
|
- "test/modules/MatrixStackTests.cpp"
|
|
|
|
- "test/modules/ColorTests.cpp"
|
|
|
|
- "test/modules/BufferTests.cpp"
|
|
|
|
- "test/modules/ClockTests.cpp"
|
|
|
|
- "test/modules/RandomTests.cpp"
|
|
|
|
- "test/modules/ThreadTests.cpp"
|
|
|
|
- "test/modules/FileReaderTests.cpp"
|
|
|
|
- "test/modules/ErrorTests.cpp"
|
|
|
|
- "test/modules/NewTests.cpp"
|
|
|
|
- "test/modules/HashedStringTests.cpp"
|
|
|
|
)
|
|
)
|
|
|
|
|
|
set(SRC_PERFORMANCE
|
|
set(SRC_PERFORMANCE
|
|
- "performance/Main.cpp"
|
|
+ "performance/Main.c"
|
|
- "test/Test.cpp"
|
|
|
|
)
|
|
)
|
|
|
|
|
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
|
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
|
|
- set(COMPILE_OPTIONS -flto)
|
|
+ set(COMPILE_OPTIONS "")
|
|
- set(LINK_OPTIONS -flto)
|
|
+ set(LINK_OPTIONS "")
|
|
set(LOG_LEVEL 2)
|
|
set(LOG_LEVEL 2)
|
|
- set(ERROR_SIMULATOR "")
|
|
+ set(DEFINITIONS CHECK_MEMORY)
|
|
else()
|
|
else()
|
|
- if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
+ set(DEFINITIONS ERROR_SIMULATOR CHECK_MEMORY)
|
|
|
|
+ if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
|
set(COMPILE_OPTIONS --coverage)
|
|
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()
|
|
endif()
|
|
- set(LINK_OPTIONS gcov)
|
|
|
|
set(LOG_LEVEL 4)
|
|
set(LOG_LEVEL 4)
|
|
- set(ERROR_SIMULATOR "ERROR_SIMULATOR")
|
|
+ list(APPEND SRC "src/ErrorSimulator.c")
|
|
endif()
|
|
endif()
|
|
|
|
|
|
-if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
+if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
|
- set(MORE_WARNINGS
|
|
+ include("cmake/gcc_warnings.cmake")
|
|
- -Waligned-new=all
|
|
+elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
|
- -Walloc-zero
|
|
+ include("cmake/clang_warnings.cmake")
|
|
- -Wanalyzer-too-complex
|
|
|
|
- -Warith-conversion
|
|
|
|
- -Warray-bounds=2
|
|
|
|
- -Wattribute-alias=2
|
|
|
|
- -Wbidi-chars=any
|
|
|
|
- -Wcast-align=strict
|
|
|
|
- -Wcatch-value=3
|
|
|
|
- -Wcomma-subscript
|
|
|
|
- -Wconditionally-supported
|
|
|
|
- -Wduplicated-branches
|
|
|
|
- -Wduplicated-cond
|
|
|
|
- -Wformat-overflow=2
|
|
|
|
- -Wformat-signedness
|
|
|
|
- -Wformat-truncation=2
|
|
|
|
- -Wimplicit-fallthrough=5
|
|
|
|
- -Winvalid-imported-macros
|
|
|
|
- -Wlogical-op
|
|
|
|
- -Wmultiple-inheritance
|
|
|
|
- -Wnoexcept
|
|
|
|
- -Wnormalized=nfkc
|
|
|
|
- -Wplacement-new=2
|
|
|
|
- -Wredundant-tags
|
|
|
|
- -Wshift-overflow=2
|
|
|
|
- -Wstack-usage=8388608
|
|
|
|
- -Wstrict-null-sentinel
|
|
|
|
- -Wstringop-overflow=4
|
|
|
|
- -Wsuggest-final-methods
|
|
|
|
- -Wsuggest-final-types
|
|
|
|
- -Wtrampolines
|
|
|
|
- -Wtrivial-auto-var-init
|
|
|
|
- -Wunused-const-variable=2
|
|
|
|
- -Wuse-after-free=3
|
|
|
|
- -Wvirtual-inheritance
|
|
|
|
- -Wvolatile
|
|
|
|
- )
|
|
|
|
endif()
|
|
endif()
|
|
|
|
|
|
add_library(core STATIC ${SRC})
|
|
add_library(core STATIC ${SRC})
|
|
target_compile_options(core PUBLIC
|
|
target_compile_options(core PUBLIC
|
|
${COMPILE_OPTIONS}
|
|
${COMPILE_OPTIONS}
|
|
|
|
+ ${WARNINGS}
|
|
-fdiagnostics-color=always
|
|
-fdiagnostics-color=always
|
|
- -fno-exceptions
|
|
|
|
- -fno-rtti
|
|
|
|
- -fno-threadsafe-statics
|
|
|
|
- # deactivated due to the need for <atomic>
|
|
|
|
- #-nostdinc++
|
|
|
|
- -pedantic
|
|
|
|
- -pedantic-errors
|
|
|
|
- -Wall
|
|
|
|
- -Walloca
|
|
|
|
- -Warray-parameter
|
|
|
|
- -Wcast-qual
|
|
|
|
- -Wconversion
|
|
|
|
- -Wctad-maybe-unsupported
|
|
|
|
- -Wctor-dtor-privacy
|
|
|
|
- -Wdate-time
|
|
|
|
- -Wdeprecated-copy-dtor
|
|
|
|
- -Wdeprecated-enum-enum-conversion
|
|
|
|
- -Wdeprecated-enum-float-conversion
|
|
|
|
- -Wdisabled-optimization
|
|
|
|
- -Wdouble-promotion
|
|
|
|
- -Weffc++
|
|
|
|
- -Wenum-compare
|
|
|
|
- -Wenum-conversion
|
|
|
|
- -Werror
|
|
|
|
- -Wextra
|
|
|
|
- -Wextra-semi
|
|
|
|
- -Wfloat-equal
|
|
|
|
- -Wformat=2
|
|
|
|
- -Wframe-larger-than=8388608
|
|
|
|
- -Winfinite-recursion
|
|
|
|
- -Winit-self
|
|
|
|
- -Winvalid-pch
|
|
|
|
- -Wlarger-than=1073741824
|
|
|
|
- -Wmismatched-tags
|
|
|
|
- -Wmissing-braces
|
|
|
|
- -Wmissing-declarations
|
|
|
|
- -Wmissing-include-dirs
|
|
|
|
- -Wmultichar
|
|
|
|
- -Wnon-virtual-dtor
|
|
|
|
- -Wnull-dereference
|
|
|
|
- -Wold-style-cast
|
|
|
|
- -Woverlength-strings
|
|
|
|
- -Woverloaded-virtual
|
|
|
|
- -Wredundant-decls
|
|
|
|
- -Wregister
|
|
|
|
- -Wshadow
|
|
|
|
- -Wsign-conversion
|
|
|
|
- -Wsign-promo
|
|
|
|
- -Wstack-protector
|
|
|
|
- -Wstrict-overflow=2
|
|
|
|
- -Wsuggest-override
|
|
|
|
- -Wswitch-enum
|
|
|
|
- -Wsynth
|
|
|
|
- -Wundef
|
|
|
|
- -Wunreachable-code
|
|
|
|
- -Wvla
|
|
|
|
- -Wwrite-strings
|
|
|
|
- -Wzero-as-null-pointer-constant
|
|
|
|
- ${MORE_WARNINGS}
|
|
|
|
)
|
|
)
|
|
-target_compile_definitions(core
|
|
+target_compile_definitions(core
|
|
- PUBLIC CORE_LOG_LEVEL=${LOG_LEVEL}
|
|
+ PUBLIC LOG_LEVEL=${LOG_LEVEL}
|
|
- PRIVATE ${ERROR_SIMULATOR}
|
|
+ PRIVATE ${DEFINITIONS}
|
|
)
|
|
)
|
|
-target_link_libraries(core
|
|
+target_link_libraries(core
|
|
- PUBLIC -nodefaultlibs c m
|
|
+ PRIVATE m ${LINK_OPTIONS}
|
|
- PRIVATE ${LINK_OPTIONS}
|
|
|
|
)
|
|
)
|
|
-target_sources(core PUBLIC
|
|
+target_sources(core PUBLIC
|
|
FILE_SET HEADERS
|
|
FILE_SET HEADERS
|
|
BASE_DIRS include
|
|
BASE_DIRS include
|
|
- FILES
|
|
+ FILES
|
|
- ./include/core/data/Stack.hpp
|
|
+ ./include/core/BitArray.h
|
|
- ./include/core/data/HashMap.hpp
|
|
+ ./include/core/Box.h
|
|
- ./include/core/data/Components.hpp
|
|
+ ./include/core/Buffer.h
|
|
- ./include/core/data/ArrayList.hpp
|
|
+ ./include/core/Check.h
|
|
- ./include/core/data/ProbingHashMap.hpp
|
|
+ ./include/core/Components.h
|
|
- ./include/core/data/List.hpp
|
|
+ ./include/core/File.h
|
|
- ./include/core/data/LinkedList.hpp
|
|
+ ./include/core/Frustum.h
|
|
- ./include/core/data/BitArray.hpp
|
|
+ ./include/core/Generic.h
|
|
- ./include/core/data/Array.hpp
|
|
+ ./include/core/HashMap.h
|
|
- ./include/core/data/RingBuffer.hpp
|
|
+ ./include/core/List.h
|
|
- ./include/core/thread/Thread.hpp
|
|
+ ./include/core/Logger.h
|
|
- ./include/core/utils/HashCode.hpp
|
|
+ ./include/core/Matrix.h
|
|
- ./include/core/utils/New.hpp
|
|
+ ./include/core/Plane.h
|
|
- ./include/core/utils/Check.hpp
|
|
+ ./include/core/Quaternion.h
|
|
- ./include/core/utils/Buffer.hpp
|
|
+ ./include/core/Queue.h
|
|
- ./include/core/utils/Random.hpp
|
|
+ ./include/core/Random.h
|
|
- ./include/core/utils/UniquePointer.hpp
|
|
+ ./include/core/ReadLine.h
|
|
- ./include/core/utils/Types.hpp
|
|
+ ./include/core/SpinLock.h
|
|
- ./include/core/utils/Color.hpp
|
|
+ ./include/core/Terminal.h
|
|
- ./include/core/utils/Logger.hpp
|
|
+ ./include/core/Test.h
|
|
- ./include/core/utils/ArrayString.hpp
|
|
+ ./include/core/Thread.h
|
|
- ./include/core/utils/Utility.hpp
|
|
+ ./include/core/ToString.h
|
|
- ./include/core/utils/Meta.hpp
|
|
+ ./include/core/Types.h
|
|
- ./include/core/utils/AlignedData.hpp
|
|
+ ./include/core/Unicode.h
|
|
- ./include/core/utils/Clock.hpp
|
|
+ ./include/core/Utility.h
|
|
- ./include/core/utils/Error.hpp
|
|
+ ./include/core/Vector.h
|
|
- ./include/core/math/Quaternion.hpp
|
|
+ ./include/core/View.h
|
|
- ./include/core/math/Box.hpp
|
|
|
|
- ./include/core/math/Frustum.hpp
|
|
|
|
- ./include/core/math/Vector.hpp
|
|
|
|
- ./include/core/math/Matrix.hpp
|
|
|
|
- ./include/core/math/View.hpp
|
|
|
|
- ./include/core/math/BufferedValue.hpp
|
|
|
|
- ./include/core/math/Plane.hpp
|
|
|
|
- ./include/core/math/MatrixStack.hpp
|
|
|
|
- ./include/core/math/Math.hpp
|
|
|
|
- ./include/core/io/File.hpp
|
|
|
|
- ./include/core/io/FileReader.hpp
|
|
|
|
)
|
|
)
|
|
install(TARGETS core FILE_SET HEADERS)
|
|
install(TARGETS core FILE_SET HEADERS)
|
|
|
|
|
|
add_executable(test ${SRC_TESTS})
|
|
add_executable(test ${SRC_TESTS})
|
|
target_link_libraries(test PRIVATE core)
|
|
target_link_libraries(test PRIVATE core)
|
|
-target_compile_definitions(test PRIVATE ${ERROR_SIMULATOR})
|
|
+target_compile_definitions(test PRIVATE ${DEFINITIONS})
|
|
|
|
|
|
add_executable(performance ${SRC_PERFORMANCE})
|
|
add_executable(performance ${SRC_PERFORMANCE})
|
|
target_link_libraries(performance PRIVATE core)
|
|
target_link_libraries(performance PRIVATE core)
|
|
|
|
+target_include_directories(performance PRIVATE include)
|
|
|
|
+target_compile_definitions(performance PRIVATE ${DEFINITIONS})
|