From 5569ee5f064467a083808aeff9e49b49900d4c1c Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sun, 13 Aug 2023 17:52:20 +0300 Subject: [PATCH] Set up the build system for the demo app. --- demo/CMakeLists.txt | 30 +++++++++++++++++++++++++++++- demo/README.md | 3 +++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 demo/README.md diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt index 6f1efcc..97d95b9 100644 --- a/demo/CMakeLists.txt +++ b/demo/CMakeLists.txt @@ -6,4 +6,32 @@ cmake_minimum_required(VERSION 3.20) -# TODO clang tidy etc +project(udpard_demo C) + +# Set up static analysis. +set(NO_STATIC_ANALYSIS OFF CACHE BOOL "disable udpard static analysis") +if (NOT NO_STATIC_ANALYSIS) + # clang-tidy (separate config files per directory) + find_program(clang_tidy NAMES clang-tidy) + if (NOT clang_tidy) + message(FATAL_ERROR "Could not locate clang-tidy") + endif () + message(STATUS "Using clang-tidy: ${clang_tidy}") +endif () + +# Define the LibUDPard static library build target. No special options are needed to use the library, it's very simple. +add_library(udpard_demo STATIC ${CMAKE_CURRENT_SOURCE_DIR}/../libudpard/udpard.c) +target_include_directories(udpard_demo INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/../libudpard) + +# Define the demo application build target and link it with the library. +add_executable(demo main.c) +target_link_libraries(demo PRIVATE udpard_demo) +set_target_properties( + demo + PROPERTIES + COMPILE_FLAGS "-Wall -Wextra -Werror -pedantic -Wdouble-promotion -Wswitch-enum -Wfloat-equal \ + -Wundef -Wconversion -Wtype-limits -Wsign-conversion -Wcast-align -Wmissing-declarations" + C_STANDARD 11 + C_EXTENSIONS OFF + C_CLANG_TIDY "${clang_tidy}" +) diff --git a/demo/README.md b/demo/README.md new file mode 100644 index 0000000..bfe33db --- /dev/null +++ b/demo/README.md @@ -0,0 +1,3 @@ +# LibUDPard demo application + +here be 🐉