cmake_minimum_required(VERSION 3.16) project(irc-toolkit LANGUAGES C) 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 -pedantic -fanalyzer -fstack-check) elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") add_compile_options(-Weverything -pedantic -Wno-padded -Wno-disabled-macro-expansion) endif() OPTION(CMAKE_BUILD_TYPE "Debug") if (CMAKE_BUILD_TYPE EQUAL "Debug") set(COMPILE_OPTIONS "${COMPILE_OPTIONS} -Og") elseif (CMAKE_BUILD_TYPE EQUAL "Release") set(COMPILE_OPTIONS "${COMPILE_OPTIONS} -O2 -Werror") endif() find_library(UIRC_PATH NAMES uirc libuirc REQUIRED) 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 DESTINATION ${CMAKE_INSTALL_BINDIR}) endmacro() buildtool(formatirc) buildtool(joinpart)