2019-12-03 16:23:14 +00:00
|
|
|
find_program(CLANG_CHECK_EXE NAMES clang-check-10 clang-check-9 clang-check-8
|
|
|
|
clang-check-7 clang-check-6.0 clang-check)
|
2019-10-09 06:12:42 +00:00
|
|
|
if(CLANG_CHECK_EXE)
|
|
|
|
option(CLANG_ANALYZE_FIX "Perform fixes for Clang-Check" OFF)
|
|
|
|
endif()
|
|
|
|
|
2019-06-30 15:45:56 +00:00
|
|
|
function(add_clang_analyze_check)
|
|
|
|
list(GET ARGN 0 _target)
|
|
|
|
set(_sources ${ARGN})
|
|
|
|
list(REMOVE_AT _sources 0)
|
|
|
|
|
|
|
|
if(CLANG_CHECK_EXE)
|
|
|
|
if(CLANG_CHECK_FIX)
|
|
|
|
list(APPEND _args "-fix")
|
|
|
|
endif()
|
|
|
|
if(NOT TARGET clang-analyze-check)
|
|
|
|
add_custom_target(clang-analyze-check)
|
|
|
|
endif()
|
2019-12-03 16:23:14 +00:00
|
|
|
add_custom_target(
|
|
|
|
clang-analyze-check-${_target}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
COMMAND ${CLANG_CHECK_EXE} -analyze -extra-arg="-Wno-unknown-warning-option" -p
|
|
|
|
${CMAKE_BINARY_DIR} ${_sources})
|
2019-06-30 15:45:56 +00:00
|
|
|
add_dependencies(clang-analyze-check-${_target} ${_target})
|
|
|
|
add_dependencies(clang-analyze-check clang-analyze-check-${_target})
|
|
|
|
else()
|
2019-08-10 07:30:01 +00:00
|
|
|
message(STATUS "CMLIB warning:")
|
|
|
|
message(STATUS " Clang-Check analyzer is not found")
|
2019-06-30 15:45:56 +00:00
|
|
|
endif()
|
|
|
|
endfunction()
|