66 lines
2.2 KiB
CMake
66 lines
2.2 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
project(microirc LANGUAGES C)
|
|
|
|
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)
|
|
|
|
# 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.
|
|
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)
|
|
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()
|
|
|
|
if ( BUILD_IRCV3 )
|
|
message(STATUS "IRCv3 capabilities are going to be built.")
|
|
add_compile_definitions(UIRC_IRCV3)
|
|
endif()
|
|
|
|
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()
|
|
|
|
set(build_FILES
|
|
src/assemblers.c
|
|
src/misc.c
|
|
src/tokenizers.c
|
|
)
|
|
|
|
if ( BUILD_HELPERS )
|
|
message(STATUS "Helper functions are going to be built.")
|
|
set(build_FILES ${build_FILES} src/helpers.c)
|
|
add_compile_definitions(UIRC_HELPERS)
|
|
if ( BUILD_IRCV3 )
|
|
set(build_FILES ${build_FILES} src/taghelpers.c)
|
|
endif()
|
|
endif()
|
|
|
|
add_library(uirc SHARED ${build_FILES})
|
|
set_property(TARGET uirc PROPERTY C_STANDARD 99)
|
|
|
|
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/"
|
|
DESTINATION "include/uirc"
|
|
FILES_MATCHING PATTERN "*.h"
|
|
)
|
|
|
|
install(TARGETS uirc DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
|
|
if ( BUILD_TESTS )
|
|
message(STATUS "Tests are going to be built.")
|
|
enable_testing()
|
|
add_subdirectory(tests)
|
|
endif()
|