From 88926375a0e4e45f72c87b9e487c060ddd3c9216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 6 Nov 2020 14:34:04 +0100 Subject: [PATCH] Clang-Tidy: error out when executable not found Stop with an error when the Clang-Tidy executable cannot be found. Without this check, CMake will happily report "Found Clang-Tidy" but with the fallback version (0, 0, 0), when `CLANG_TIDY_EXECUTABLE` points to a non-existing executable. --- build_files/cmake/Modules/FindClangTidy.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build_files/cmake/Modules/FindClangTidy.cmake b/build_files/cmake/Modules/FindClangTidy.cmake index d576ad8f100..04c5dfda448 100644 --- a/build_files/cmake/Modules/FindClangTidy.cmake +++ b/build_files/cmake/Modules/FindClangTidy.cmake @@ -43,7 +43,10 @@ find_program(CLANG_TIDY_EXECUTABLE ${_clang_tidy_SEARCH_DIRS} ) -if(CLANG_TIDY_EXECUTABLE) +if(CLANG_TIDY_EXECUTABLE AND NOT EXISTS ${CLANG_TIDY_EXECUTABLE}) + message(WARNING "Cached or directly specified Clang-Tidy executable does not exist.") + set(CLANG_TIDY_FOUND FALSE) +elseif(CLANG_TIDY_EXECUTABLE) # Mark clang-tidy as found. set(CLANG_TIDY_FOUND TRUE)