2020-04-01 18:42:59 +00:00
|
|
|
find_program(CLANG_TIDY_EXE NAMES clang-tidy-10 clang-tidy-9 clang-tidy-8 clang-tidy-7 clang-tidy-6.0
|
|
|
|
clang-tidy)
|
2019-10-09 06:12:42 +00:00
|
|
|
if(CLANG_TIDY_EXE)
|
|
|
|
option(CLANG_TIDY_FIX "Perform fixes for Clang-Tidy" OFF)
|
|
|
|
if(CLANG_TIDY_FIX)
|
|
|
|
list(APPEND _args "-fix")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-06-15 11:55:12 +00:00
|
|
|
function(add_clang_tidy_check)
|
|
|
|
list(GET ARGN 0 _target)
|
|
|
|
set(_sources ${ARGN})
|
|
|
|
list(REMOVE_AT _sources 0)
|
|
|
|
|
|
|
|
if(CLANG_TIDY_EXE)
|
2019-06-27 02:18:29 +00:00
|
|
|
if(NOT TARGET clang-tidy-check)
|
|
|
|
add_custom_target(clang-tidy-check)
|
|
|
|
endif()
|
2019-12-03 16:23:14 +00:00
|
|
|
add_custom_target(
|
|
|
|
clang-tidy-check-${_target}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
2020-04-01 18:42:59 +00:00
|
|
|
COMMAND ${CLANG_TIDY_EXE} -extra-arg="-Wno-unknown-warning-option" -p ${CMAKE_BINARY_DIR} ${_sources})
|
2019-06-25 12:01:57 +00:00
|
|
|
add_dependencies(clang-tidy-check-${_target} ${_target})
|
2019-06-27 02:18:29 +00:00
|
|
|
add_dependencies(clang-tidy-check clang-tidy-check-${_target})
|
2019-06-15 11:55:12 +00:00
|
|
|
else()
|
2019-08-10 07:30:01 +00:00
|
|
|
message(STATUS "CMLIB warning:")
|
|
|
|
message(STATUS " ClangTidy analyzer is not found")
|
2019-06-15 11:55:12 +00:00
|
|
|
endif()
|
|
|
|
endfunction()
|