From 7f05984946724703002ae34b00b5b8ceb210bb21 Mon Sep 17 00:00:00 2001 From: surtur Date: Sun, 5 Dec 2021 05:07:02 +0100 Subject: [PATCH] integrate clang-tidy into cmake * consolidate everything with the makefile, the "tidy" target now just sets the env var that is checked for in CMakeLists * rm clang-tidy from pre-commit as it's run as part of the "test" makefile target later in the file anyway --- .pre-commit-config.yaml | 3 --- CMakeLists.txt | 6 ++++++ Makefile | 4 +--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d7f2451..981064c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,9 +13,6 @@ repos: - repo: https://github.com/pocc/pre-commit-hooks rev: v1.3.4 hooks: - - id: clang-tidy - args: ["-p", "cmake-build-debug"] - exclude: ^lib/ - id: cppcheck args: ["--language=c++", "--std=c++20", "--enable=warning,performance,portability,information,unusedFunction,missingInclude", diff --git a/CMakeLists.txt b/CMakeLists.txt index a18a093..a5f7827 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,12 @@ add_subdirectory(lib/fmt EXCLUDE_FROM_ALL) endif(NOT CMAKE_CXX_FLAGS MATCHES "-Wall") if(CMAKE_BUILD_TYPE MATCHES "Debug") + + if($ENV{TIDY} MATCHES "1") + set(CMAKE_CXX_CLANG_TIDY clang-tidy -p ${CMAKE_CURRENT_BINARY_DIR} --checks=-*,clang-diagnostic-*,clang-analyzer-*,google-*,bugprone-* --header-filter= --use-color=true) + endif() + + # Produce debugging information in the operating system's native format. # Level 3 includes extra information, such as all the macro definitions # present in the program. Some debuggers support macro expansion when you diff --git a/Makefile b/Makefile index 4fbe8b0..9e10e36 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,6 @@ d_folder = cmake-build-debug r_folder = cmake-build-release s_folder = cmake-build-san s_tru = SANITIZE_PLS=true -t = clang-tidy -t_args = --config="" --format-style=google --checks="clang-diagnostic-*,clang-analyzer-*,google-*" --use-color=true -p $(d_folder) ./*.{cpp,h} v = valgrind v_env = VALGRIND= v_db = $(d_folder)_valgr @@ -41,7 +39,7 @@ san: tidy: - $(t) $(t_args) + env TIDY=1 make debug valgrind: valgrind-debug