66 lines
1.4 KiB
CMake
66 lines
1.4 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
project(
|
|
irc-toolkit
|
|
VERSION 2021.01.07
|
|
DESCRIPTION "IRC Protocol helpers"
|
|
LANGUAGES C
|
|
)
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
OPTION(CODE_ANALYZER "Analyze the code statically" OFF)
|
|
OPTION(CODE_COVERAGE "Build with coverage tools" OFF)
|
|
|
|
find_library(UIRC_PATH NAMES uirc REQUIRED)
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Werror")
|
|
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
|
|
-pedantic
|
|
)
|
|
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()
|
|
if (CODE_ANALYZER)
|
|
add_compile_options(--analyze)
|
|
endif()
|
|
endif()
|
|
|
|
macro(buildtool source)
|
|
add_executable(${source} ${source}.c common.c)
|
|
target_link_libraries(${source} ${UIRC_PATH})
|
|
set_property(TARGET ${source} PROPERTY C_STANDARD 99)
|
|
install(TARGETS ${source} RUNTIME)
|
|
endmacro()
|
|
|
|
buildtool(irc-list)
|
|
buildtool(irc-events)
|
|
buildtool(irc-messages)
|
|
|