123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- cmake_minimum_required(VERSION 3.25)
- project(core)
- set(CMAKE_C_STANDARD 23)
- set(SRC
- "src/Buffer.c"
- "src/Logger.c"
- "src/Matrix.c"
- "src/Quaternion.c"
- "src/Random.c"
- "src/Utility.c"
- "src/Vector.c"
- #"src/BitArray.cpp"
- #"src/Box.cpp"
- #"src/Frustum.cpp"
- #"src/Plane.cpp"
- #"src/SpinLock.cpp"
- #"src/View.cpp"
- )
- set(SRC_TESTS
- "test/Main.c"
- "test/Test.c"
- "test/modules/BufferTests.c"
- "test/modules/MatrixTests.c"
- "test/modules/QuaternionTests.c"
- "test/modules/RandomTests.c"
- "test/modules/UtilityTests.c"
- "test/modules/VectorTests.c"
- #"test/modules/BitArrayTests.cpp"
- #"test/modules/BoxTests.cpp"
- #"test/modules/ComponentsTests.cpp"
- #"test/modules/FrustumTests.cpp"
- #"test/modules/HashMapTests.cpp"
- #"test/modules/LinkedListTests.cpp"
- #"test/modules/ListTests.cpp"
- #"test/modules/MatrixStackTests.cpp"
- #"test/modules/PlaneTests.cpp"
- #"test/modules/RingBufferTests.cpp"
- #"test/modules/StackTests.cpp"
- #"test/modules/ThreadTests.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)
- if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
- set(DEFINITIONS bool=_Bool true=1 false=0 nullptr=0 static_assert=_Static_assert)
- else()
- set(DEFINITIONS "")
- endif()
- else()
- if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
- set(COMPILE_OPTIONS --coverage)
- set(LINK_OPTIONS gcov)
- set(DEFINITIONS ERROR_SIMULATOR CORE_CHECK_MEMORY bool=_Bool true=1 false=0 nullptr=0 static_assert=_Static_assert)
- else()
- set(COMPILE_OPTIONS -fprofile-instr-generate -fcoverage-mapping)
- set(LINK_OPTIONS ${COMPILE_OPTIONS})
- set(DEFINITIONS ERROR_SIMULATOR CORE_CHECK_MEMORY)
- endif()
- set(LOG_LEVEL 4)
- 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 m ${LINK_OPTIONS}
- )
- target_sources(core PUBLIC
- FILE_SET HEADERS
- BASE_DIRS include
- FILES
- ./include/core/Buffer.h
- ./include/core/Check.h
- ./include/core/Logger.h
- ./include/core/Matrix.h
- ./include/core/Quaternion.h
- ./include/core/Random.h
- ./include/core/Types.h
- ./include/core/Utility.h
- # ./include/core/BitArray.hpp
- # ./include/core/Box.hpp
- # ./include/core/Components.hpp
- # ./include/core/Frustum.hpp
- # ./include/core/HashMap.hpp
- # ./include/core/LinkedList.hpp
- # ./include/core/List.hpp
- # ./include/core/MatrixStack.hpp
- # ./include/core/Plane.hpp
- # ./include/core/ProbingHashMap.hpp
- # ./include/core/RingBuffer.hpp
- # ./include/core/Stack.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)
|