Improve CMakeLists
This commit is contained in:
parent
24480c7cb7
commit
f77bee950f
|
@ -1,22 +1,13 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
project(microircd LANGUAGES C)
|
||||
|
||||
add_compile_definitions(UIRCD_VERSION="2020.12.30")
|
||||
include(GNUInstallDirs)
|
||||
|
||||
OPTION(CODE_ANALYZER "Analyze the code statically" ON)
|
||||
OPTION(CODE_COVERAGE "Build with coverage tools" OFF)
|
||||
set(UIRCD_VERSION "2021.01.02")
|
||||
add_compile_definitions(UIRCD_VERSION="${UIRC_VERSION}")
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
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 -Wno-unused-parameter)
|
||||
if ( CODE_ANALYZER )
|
||||
add_compile_options(-fanalyzer)
|
||||
endif()
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
add_compile_options(-Weverything -Wno-padded -Wno-disabled-macro-expansion -pedantic)
|
||||
if ( CODE_COVERAGE )
|
||||
add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
|
||||
endif()
|
||||
endif()
|
||||
OPTION(CODE_ANALYZER "Analyze the code statically" OFF)
|
||||
OPTION(CODE_COVERAGE "Build with coverage tools" OFF)
|
||||
|
||||
add_executable(uircd
|
||||
src/buffer.c
|
||||
|
@ -31,6 +22,8 @@ add_executable(uircd
|
|||
)
|
||||
|
||||
find_library(UIRC_PATH NAMES uirc REQUIRED)
|
||||
target_link_libraries(uircd ${UIRC_PATH})
|
||||
|
||||
find_library(LIBCONFIG_PATH NAMES config)
|
||||
if(NOT LIBCONFIG_PATH)
|
||||
message(WARNING "libconfig not found. uIRCd will not support configuration files")
|
||||
|
@ -39,7 +32,48 @@ else()
|
|||
add_compile_definitions(UIRCD_FEATURE_LIBCONFIG)
|
||||
target_link_libraries(uircd ${LIBCONFIG_PATH})
|
||||
endif()
|
||||
target_link_libraries(uircd ${UIRC_PATH})
|
||||
set_property(TARGET uircd PROPERTY C_STANDARD 99)
|
||||
|
||||
install(TARGETS uircd RUNTIME)
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Werror")
|
||||
add_compile_options(-pedantic)
|
||||
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
|
||||
-fstack-check
|
||||
)
|
||||
if (CODE_ANALYZER)
|
||||
add_compile_options(-fanalyzer)
|
||||
endif()
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
add_compile_options(
|
||||
-Weverything
|
||||
-Wno-padded
|
||||
-Wno-disabled-macro-expansion
|
||||
)
|
||||
if (CODE_COVERAGE)
|
||||
add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set_target_properties(uircd PROPERTIES
|
||||
C_STANDARD 99
|
||||
VERSION "${UIRCD_VERSION}"
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS uircd
|
||||
RUNTIME
|
||||
)
|
||||
|
|
Reference in New Issue