|
@@ -52,101 +52,38 @@ 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()
|
|
|
+ set(DEFINITIONS "")
|
|
|
else()
|
|
|
+ set(DEFINITIONS ERROR_SIMULATOR CORE_CHECK_MEMORY)
|
|
|
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()
|
|
|
+ elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
|
|
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
|
|
|
+ include("cmake/gcc_warnings.cmake")
|
|
|
+ set(DEFINITIONS ${DEFINITIONS}
|
|
|
+ bool=_Bool
|
|
|
+ true=1
|
|
|
+ false=0
|
|
|
+ nullptr=0
|
|
|
+ static_assert=_Static_assert
|
|
|
)
|
|
|
+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}
|
|
|
- -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
|
|
|
+ ${WARNINGS}
|
|
|
-fdiagnostics-color=always
|
|
|
- -pedantic
|
|
|
- -pedantic-errors
|
|
|
- ${MORE_WARNINGS}
|
|
|
)
|
|
|
target_compile_definitions(core
|
|
|
PUBLIC CORE_LOG_LEVEL=${LOG_LEVEL}
|