2020-04-22 16:14:51 +00:00
|
|
|
find_program(CLANG_CHECK_EXE NAMES clang-check-10 clang-check-9 clang-check)
|
2019-10-09 06:12:42 +00:00
|
|
|
if(CLANG_CHECK_EXE)
|
2020-04-18 15:45:46 +00:00
|
|
|
option(CMLIB_CLANG_ANALYZE_FIX "Perform fixes for Clang-Check" OFF)
|
2019-10-09 06:12:42 +00:00
|
|
|
endif()
|
|
|
|
|
2020-04-13 16:44:42 +00:00
|
|
|
function(add_clang_analyze_check target)
|
2019-06-30 15:45:56 +00:00
|
|
|
set(_sources ${ARGN})
|
2020-04-18 15:45:46 +00:00
|
|
|
set(_args -analyze -extra-arg="-Wno-unknown-warning-option")
|
2019-06-30 15:45:56 +00:00
|
|
|
|
|
|
|
if(CLANG_CHECK_EXE)
|
2020-04-18 15:45:46 +00:00
|
|
|
if(CMLIB_CLANG_ANALYZE_FIX)
|
2020-04-18 19:01:23 +00:00
|
|
|
list(APPEND _args "--fixit")
|
2019-06-30 15:45:56 +00:00
|
|
|
endif()
|
|
|
|
if(NOT TARGET clang-analyze-check)
|
|
|
|
add_custom_target(clang-analyze-check)
|
|
|
|
endif()
|
2020-04-18 16:40:13 +00:00
|
|
|
add_custom_target(clang-analyze-check-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
COMMAND ${CLANG_CHECK_EXE} ${_args} -p ${CMAKE_BINARY_DIR} ${_sources})
|
2020-04-13 16:44:42 +00:00
|
|
|
add_dependencies(clang-analyze-check-${target} ${target})
|
|
|
|
add_dependencies(clang-analyze-check clang-analyze-check-${target})
|
2019-06-30 15:45:56 +00:00
|
|
|
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()
|