From 25387c5b6c4990769f95e1d77a0d609a53d03369 Mon Sep 17 00:00:00 2001 From: Seth Flynn Date: Tue, 17 Feb 2026 16:57:18 -0500 Subject: [PATCH] build(cmake): add support for clang-tidy Signed-off-by: Seth Flynn --- CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c6202581..01c50aa56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,19 @@ if(CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR MATCHES "^Ninja" set(CMAKE_EXPORT_COMPILE_COMMANDS ON) endif() +option(USE_CLANG_TIDY "Enable the use of clang-tidy during compilation" OFF) + +if(USE_CLANG_TIDY) + find_program(CLANG_TIDY clang-tidy OPTIONAL) + if(CLANG_TIDY) + message(STATUS "Using clang-tidy during compilation") + set(CLANG_TIDY_COMMAND "${CLANG_TIDY}" "--config-file=${CMAKE_SOURCE_DIR}/.clang-tidy") + set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_COMMAND}) + else() + message(WARNING "Unable to find `clang-tidy`. Not using during compilation") + endif() +endif() + option(DEBUG_ADDRESS_SANITIZER "Enable Address Sanitizer in Debug builds" OFF) # If this is a Debug build turn on address sanitiser