Add options for compiler flags
This commit is contained in:
parent
0ff0a8742b
commit
45bccfcaa7
|
@ -1,14 +1,21 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
project(microircd LANGUAGES C)
|
||||
|
||||
add_compile_definitions(
|
||||
UIRCD_VERSION="2020.12.30.0"
|
||||
)
|
||||
add_compile_definitions(UIRCD_VERSION="2020.12.30")
|
||||
|
||||
OPTION(CODE_ANALYZER "Analyze the code statically" ON)
|
||||
OPTION(CODE_COVERAGE "Build with coverage tools" OFF)
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
add_compile_options(-Wall -Wextra -Wformat-overflow=2 -Wformat-security -Winit-self -Wstrict-overflow=2 -Wstringop-overflow=2 -Walloc-zero -Wduplicated-branches -Wduplicated-cond -Wtrampolines -Wfloat-equal -Wshadow -Wunsafe-loop-optimizations -Wparentheses -pedantic -fanalyzer -fstack-check)
|
||||
add_compile_options(-Wall -Wextra -Werror -Wformat-overflow=2 -Wformat-security -Winit-self -Wstrict-overflow=2 -Wstringop-overflow=2 -Walloc-zero -Wduplicated-branches -Wduplicated-cond -Wtrampolines -Wfloat-equal -Wshadow -Wunsafe-loop-optimizations -Wparentheses -pedantic -fstack-check)
|
||||
if ( CODE_ANALYZER )
|
||||
add_compile_options(-fanalyzer)
|
||||
endif()
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
add_compile_options(-Weverything -pedantic -Wno-padded -Wno-disabled-macro-expansion)
|
||||
add_compile_options(-Weverything -Wno-padded -Wno-disabled-macro-expansion -pedantic)
|
||||
if ( CODE_COVERAGE )
|
||||
add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(uircd
|
||||
|
|
Reference in New Issue