From 1e707d090eedd356c2edc1d007b1bb2f351b995a Mon Sep 17 00:00:00 2001 From: a4z Date: Sun, 5 May 2024 20:50:52 +0200 Subject: [PATCH] Add second way for running clang tidy --- CMakeLists.txt | 9 +++++++++ run_clang_tidy.sh | 7 +++++++ 2 files changed, 16 insertions(+) create mode 100755 run_clang_tidy.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 13b9655..da4c73e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,15 @@ if(PROJECT_IS_TOP_LEVEL) USES_TERMINAL ) + add_custom_target( + clang_tidy + COMMAND ${CMAKE_SOURCE_DIR}/run_clang_tidy.sh ${CMAKE_CXX_STANDARD} ${CMAKE_BINARY_DIR} + COMMENT "Running clang-tidy on each file individually" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + USES_TERMINAL + ) + + add_custom_target( clang-format COMMAND git ls-files | grep -E ".*\\.(c|h|cpp|hpp)$" | xargs clang-format -i diff --git a/run_clang_tidy.sh b/run_clang_tidy.sh new file mode 100755 index 0000000..2c498b3 --- /dev/null +++ b/run_clang_tidy.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +for file in $(git ls-files | grep -E '^(include|src)/.*\.(c|cpp|h|hpp)$') +do + echo 'Checking '$file + clang-tidy --extra-arg=-std=c++$1 -p $2 --header-filter='^$' $file || exit 255 +done