2020-07-04 15:43:30 +00:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
|
|
|
project(microirc LANGUAGES C)
|
|
|
|
|
2021-01-02 18:12:59 +00:00
|
|
|
include(GNUInstallDirs)
|
2020-12-30 18:48:48 +00:00
|
|
|
|
2021-01-02 18:12:59 +00:00
|
|
|
set(UIRC_VERSION "2021.01.02")
|
|
|
|
add_compile_definitions(UIRC_VERSION="${UIRC_VERSION}")
|
2020-12-16 14:22:25 +00:00
|
|
|
|
2021-01-02 18:12:59 +00:00
|
|
|
OPTION(BUILD_HELPERS "Build message helpers" ON )
|
|
|
|
OPTION(BUILD_VALIDATORS "Build message validators" ON )
|
|
|
|
OPTION(BUILD_IRCV3 "Build IRCv3 components" ON )
|
|
|
|
OPTION(BUILD_TESTS "Build tests for ctest" OFF)
|
|
|
|
OPTION(CODE_ANALYZER "Analyze the code statically" OFF)
|
|
|
|
OPTION(CODE_COVERAGE "Build with coverage tools" OFF)
|
|
|
|
|
|
|
|
set(UIRC_SOURCE
|
|
|
|
src/assemblers.c
|
2021-01-02 22:20:06 +00:00
|
|
|
src/commands.c
|
|
|
|
src/converters.c
|
|
|
|
src/memory.c
|
|
|
|
src/string.c
|
2021-01-02 18:12:59 +00:00
|
|
|
src/tokenizers.c
|
|
|
|
)
|
|
|
|
|
|
|
|
set(UIRC_HEADERS
|
2021-01-02 22:20:06 +00:00
|
|
|
src/assemblers.h
|
|
|
|
src/commands.h
|
|
|
|
src/converters.h
|
|
|
|
src/errors.h
|
|
|
|
src/modes.h
|
|
|
|
src/replies.h
|
|
|
|
src/tokenizers.h
|
|
|
|
src/types.h
|
|
|
|
src/uirc.h
|
2021-01-02 18:12:59 +00:00
|
|
|
)
|
2020-09-22 20:33:20 +00:00
|
|
|
|
2021-01-02 18:12:59 +00:00
|
|
|
#
|
|
|
|
# Features
|
|
|
|
#
|
|
|
|
if (BUILD_IRCV3)
|
2020-10-10 10:15:02 +00:00
|
|
|
message(STATUS "IRCv3 capabilities are going to be built.")
|
2020-09-22 20:33:20 +00:00
|
|
|
add_compile_definitions(UIRC_IRCV3)
|
2021-01-02 22:20:06 +00:00
|
|
|
set(UIRC_SOURCE ${UIRC_SOURCE}
|
|
|
|
src/tags.c
|
|
|
|
src/capabilities.c
|
|
|
|
)
|
|
|
|
set(UIRC_HEADERS ${UIRC_HEADERS}
|
|
|
|
src/tags.h
|
|
|
|
src/capabilities.h
|
|
|
|
)
|
2020-07-09 20:54:11 +00:00
|
|
|
endif()
|
2021-01-02 18:12:59 +00:00
|
|
|
if (BUILD_VALIDATORS)
|
2020-10-29 20:33:37 +00:00
|
|
|
message(STATUS "Message validators are going to be built.")
|
|
|
|
add_compile_definitions(UIRC_VALIDATORS)
|
2021-01-02 22:20:06 +00:00
|
|
|
set(UIRC_SOURCE ${UIRC_SOURCE}
|
|
|
|
src/validators.c
|
|
|
|
)
|
|
|
|
set(UIRC_HEADERS ${UIRC_HEADERS}
|
|
|
|
src/validators.h
|
|
|
|
)
|
2020-10-29 20:33:37 +00:00
|
|
|
endif()
|
2021-01-02 18:12:59 +00:00
|
|
|
if (BUILD_HELPERS)
|
2020-10-10 10:15:02 +00:00
|
|
|
message(STATUS "Helper functions are going to be built.")
|
2020-10-31 10:56:48 +00:00
|
|
|
add_compile_definitions(UIRC_HELPERS)
|
2020-07-04 15:43:30 +00:00
|
|
|
endif()
|
2021-01-02 18:12:59 +00:00
|
|
|
if (BUILD_TESTS)
|
|
|
|
message(STATUS "Tests are going to be built.")
|
|
|
|
enable_testing()
|
2021-01-02 22:20:06 +00:00
|
|
|
|
|
|
|
macro(buildtest name source)
|
|
|
|
add_executable(${source} tests/${source}.c)
|
|
|
|
target_link_libraries(${source} uirc)
|
|
|
|
add_test(NAME ${name} COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${source})
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
buildtest(Tokenizer tokenizer)
|
|
|
|
buildtest(Overflow overflow)
|
|
|
|
buildtest(PrefixAssembler prefixassm)
|
|
|
|
buildtest(MessageAssembler msgassm)
|
|
|
|
buildtest(NumericCmds numericmds)
|
|
|
|
buildtest(IncorrectTrailing notrail)
|
|
|
|
buildtest(SpacedArguments spacedargs)
|
|
|
|
buildtest(StrTokMoveSave strtokmr)
|
|
|
|
buildtest(Junk junk)
|
|
|
|
|
|
|
|
if (BUILD_IRCV3)
|
|
|
|
buildtest(TagParser tagtok)
|
|
|
|
buildtest(TagAssembler tagassm)
|
|
|
|
if (BUILD_HELPERS)
|
|
|
|
buildtest(TimestampAssembly timestamp)
|
|
|
|
buildtest(TagBitMaskTknzr capbitmask)
|
|
|
|
endif()
|
|
|
|
endif()
|
2021-01-02 18:12:59 +00:00
|
|
|
endif()
|
2020-09-22 20:33:20 +00:00
|
|
|
|
2021-01-02 18:12:59 +00:00
|
|
|
add_library(uirc ${UIRC_SOURCE})
|
2020-07-04 15:43:30 +00:00
|
|
|
|
2021-01-02 18:12:59 +00:00
|
|
|
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()
|
2020-12-16 15:11:53 +00:00
|
|
|
|
2021-01-02 18:12:59 +00:00
|
|
|
separate_arguments(UIRC_HEADERS)
|
2020-12-16 15:11:53 +00:00
|
|
|
set_target_properties(uirc PROPERTIES
|
|
|
|
C_STANDARD 99
|
2021-01-02 18:12:59 +00:00
|
|
|
VERSION ${UIRC_VERSION}
|
|
|
|
SOVERSION ${UIRC_VERSION}
|
|
|
|
PUBLIC_HEADER "${UIRC_HEADERS}"
|
2020-09-15 15:11:34 +00:00
|
|
|
)
|
|
|
|
|
2020-12-16 15:11:53 +00:00
|
|
|
install(
|
|
|
|
TARGETS uirc
|
|
|
|
LIBRARY
|
2021-01-02 22:20:06 +00:00
|
|
|
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/uirc"
|
2020-12-16 15:11:53 +00:00
|
|
|
)
|