build: fail if clang-tidy is not found when -DRUN_CLANG_TIDY=ON (#7210)

This commit is contained in:
Yat Ho
2024-10-31 02:29:38 +08:00
committed by GitHub
parent f0e7c3ed74
commit 1f36458e10

View File

@@ -761,19 +761,20 @@ else()
endif()
endif()
if(RUN_CLANG_TIDY STREQUAL "AUTO")
if(DEFINED ENV{LGTM_SRC} OR DEFINED ENV{APPVEYOR}) # skip clang-tidy on LGTM/appveyor
set(RUN_CLANG_TIDY OFF)
else()
set(RUN_CLANG_TIDY ON)
endif()
if(RUN_CLANG_TIDY STREQUAL "AUTO" AND (DEFINED ENV{LGTM_SRC} OR DEFINED ENV{APPVEYOR})) # skip clang-tidy on LGTM/appveyor
set(RUN_CLANG_TIDY OFF)
endif()
if(RUN_CLANG_TIDY)
tr_get_required_flag(RUN_CLANG_TIDY CLANG_TIDY_IS_REQUIRED)
message(STATUS "Looking for clang-tidy")
find_program(CLANG_TIDY clang-tidy)
if(CLANG_TIDY STREQUAL "CLANG_TIDY-NOTFOUND")
message(STATUS "Looking for clang-tidy - not found")
if(CLANG_TIDY_IS_REQUIRED)
message(FATAL_ERROR "clang-tidy is required but wasn't found")
endif()
else()
message(STATUS "Looking for clang-tidy - found")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY}")