Integrate clang-tidy-8 with cmake build
authorBen Davis <ben.davis@arm.com>
Tue, 12 Oct 2021 14:06:40 +0000 (15:06 +0100)
committerMatteo Franchin <matteo.franchin@arm.com>
Thu, 11 Nov 2021 10:15:22 +0000 (10:15 +0000)
We will now run clang-tidy if available as part of the standard build
with the bugprone-* and modernize-* checks

Change-Id: I4c9d3cf8712f802b912d32a443bca1584169a8b3
Signed-off-by: Ben Davis <ben.davis@arm.com>
CMakeLists.txt

index 1dc13b4..608a92c 100644 (file)
@@ -26,6 +26,13 @@ project(VkLayer_window_system_integration)
 find_package(PkgConfig REQUIRED)
 pkg_check_modules(VULKAN_PKG_CONFIG vulkan)
 
+find_program(CLANG_TIDY clang-tidy-8)
+
+if (NOT CLANG_TIDY STREQUAL "CLANG_TIDY-NOTFOUND")
+   message(STATUS "Using clang-tidy: ${CLANG_TIDY}")
+   set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY} -checks=bugprone-*,modernize-*)
+endif()
+
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pthread -fPIC")
 if (DEFINED DEBUG)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0")