From fdedf7078e77aa20c1ed1b8d7238dbed15dd69ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 6 Jun 2022 22:08:31 +0200 Subject: [PATCH] NOISSUE Add minimal thing for clang-tidy integration --- CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index add8dbcf..57d6755a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,20 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux") endif() endif() +option(Launcher_RUN_CLANG_TIDY "Run clang-tidy with the compiler." OFF) +if(Launcher_RUN_CLANG_TIDY) + find_program(CLANG_TIDY_COMMAND NAMES clang-tidy) + if(NOT CLANG_TIDY_COMMAND) + message(WARNING "CMake_RUN_CLANG_TIDY is ON but clang-tidy is not found!") + set(DO_CLANG_TIDY "" CACHE STRING "" FORCE) + else() + set(CLANG_TIDY_CHECKS "-modernize-use-trailing-return-type,-readability-magic-numbers,-modernize-avoid-c-arrays") + set(DO_CLANG_TIDY "${CLANG_TIDY_COMMAND};-checks=${CLANG_TIDY_CHECKS};-header-filter='${CMAKE_SOURCE_DIR}/src/*'") + endif() + # TODO: make this per-target, differentiate between libraries and main codebase + set(CMAKE_CXX_CLANG_TIDY ${DO_CLANG_TIDY}) +endif() + ##################################### Set CMake options ##################################### set(CMAKE_AUTOMOC ON)