From f6339b495e544ecea48e3563ea2ab5997b98d813 Mon Sep 17 00:00:00 2001 From: Thomas Arp <357770+welcor@users.noreply.github.com> Date: Wed, 2 Jul 2025 22:34:57 +0200 Subject: [PATCH] Feature/clang tidy (#154) * First cmake list file, simple docs. TODO: utils folder. * Support for building utils * All fields except HAVE_DOPRNT in place * Now builds and runs :) * Added support for clang-tidy, if available. --- .clang-tidy | 8 ++++++++ CMakeLists.txt | 11 +++++++++++ 2 files changed, 19 insertions(+) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..1bae24a --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,8 @@ +Checks: > + -*, + clang-analyzer-*, + bugprone-*, + performance-*, + portability-* +#WarningsAsErrors: '*' +HeaderFilterRegex: 'src/.*' \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fa9a76..78cd2af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,17 @@ if (CMAKE_COMPILER_IS_GNUCC) endif() endif() +# clang-tidy if available +find_program(CLANG_TIDY_EXE NAMES clang-tidy) + +if(CLANG_TIDY_EXE AND STATIC_ANALYSIS) + message(STATUS "clang-tidy enabled: ${CLANG_TIDY_EXE}") + set(CMAKE_C_CLANG_TIDY "${CLANG_TIDY_EXE}") + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +else() + message(WARNING "clang-tidy not found. Static analysis disabled.") +endif() + # ========== Header checks ========== check_include_file("fcntl.h" HAVE_FCNTL_H) check_include_file("errno.h" HAVE_ERRNO_H)