2020-07-04 15:43:30 +00:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
|
|
|
project(microirc LANGUAGES C)
|
|
|
|
|
2020-12-30 18:48:48 +00:00
|
|
|
set(library_VERSION "2020.12.20")
|
|
|
|
|
2020-12-16 14:22:25 +00:00
|
|
|
OPTION(BUILD_TESTS "Build tests for ctest" OFF)
|
|
|
|
OPTION(BUILD_IRCV3 "Build IRCv3 components" ON)
|
|
|
|
OPTION(BUILD_HELPERS "Build message helpers" ON)
|
|
|
|
OPTION(BUILD_VALIDATORS "Build message validators" ON)
|
|
|
|
OPTION(CODE_ANALYZER "Analyze the code statically" ON)
|
|
|
|
OPTION(CODE_COVERAGE "Build with coverage tools" OFF)
|
|
|
|
|
2020-09-22 20:58:53 +00:00
|
|
|
# NOTE: Do these seem too annoying? Try writing good code then.
|
|
|
|
# Code that triggers these warnings will not be accepted unless it has a good reason to trigger them.
|
2020-09-22 20:33:20 +00:00
|
|
|
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
2020-12-16 14:22:25 +00:00
|
|
|
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()
|
2020-09-22 20:33:20 +00:00
|
|
|
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
2020-09-26 21:22:05 +00:00
|
|
|
add_compile_options(-Weverything -Wno-padded -Wno-disabled-macro-expansion -pedantic)
|
2020-12-16 14:22:25 +00:00
|
|
|
if ( CODE_COVERAGE )
|
|
|
|
add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
|
|
|
|
endif()
|
2020-09-22 20:33:20 +00:00
|
|
|
endif()
|
|
|
|
|
2020-09-15 15:11:34 +00:00
|
|
|
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)
|
2020-07-09 20:54:11 +00:00
|
|
|
endif()
|
2020-09-22 20:33:20 +00:00
|
|
|
|
2020-10-29 20:33:37 +00:00
|
|
|
if ( BUILD_VALIDATORS )
|
|
|
|
message(STATUS "Message validators are going to be built.")
|
|
|
|
add_compile_definitions(UIRC_VALIDATORS)
|
|
|
|
set(build_FILES ${build_FILES} src/validators.c)
|
|
|
|
endif()
|
|
|
|
|
2020-07-22 16:57:59 +00:00
|
|
|
set(build_FILES
|
|
|
|
src/assemblers.c
|
|
|
|
src/misc.c
|
|
|
|
src/tokenizers.c
|
|
|
|
)
|
2020-09-22 20:33:20 +00:00
|
|
|
|
2020-07-23 13:59:41 +00:00
|
|
|
if ( BUILD_HELPERS )
|
2020-10-10 10:15:02 +00:00
|
|
|
message(STATUS "Helper functions are going to be built.")
|
2020-10-29 20:33:37 +00:00
|
|
|
set(build_FILES ${build_FILES} src/helpers.c)
|
2020-10-31 10:56:48 +00:00
|
|
|
add_compile_definitions(UIRC_HELPERS)
|
2020-10-29 20:33:37 +00:00
|
|
|
if ( BUILD_IRCV3 )
|
|
|
|
set(build_FILES ${build_FILES} src/taghelpers.c)
|
|
|
|
endif()
|
2020-07-04 15:43:30 +00:00
|
|
|
endif()
|
2020-09-22 20:33:20 +00:00
|
|
|
|
2020-12-30 18:48:48 +00:00
|
|
|
add_library(uirc ${build_FILES})
|
2020-07-04 15:43:30 +00:00
|
|
|
|
2020-12-16 15:11:53 +00:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
|
|
|
set_target_properties(uirc PROPERTIES
|
|
|
|
C_STANDARD 99
|
2020-12-30 18:48:48 +00:00
|
|
|
VERSION ${library_VERSION}
|
|
|
|
SOVERSION ${library_VERSION}
|
2020-12-16 15:11:53 +00:00
|
|
|
PUBLIC_HEADER "include/functions.h;include/helpers.h;include/mappings.h;include/types.h;include/uirc.h"
|
2020-09-15 15:11:34 +00:00
|
|
|
)
|
|
|
|
|
2020-12-16 15:11:53 +00:00
|
|
|
install(
|
|
|
|
TARGETS uirc
|
|
|
|
LIBRARY
|
|
|
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/uirc
|
|
|
|
)
|
2020-09-22 20:33:20 +00:00
|
|
|
|
|
|
|
if ( BUILD_TESTS )
|
2020-10-10 10:15:02 +00:00
|
|
|
message(STATUS "Tests are going to be built.")
|
2020-09-22 20:33:20 +00:00
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(tests)
|
|
|
|
endif()
|