2020-04-11 07:12:20 +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)
|
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)
|
2019-06-30 15:45:56 +00:00
|
|
|
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(
|
2020-04-13 16:44:42 +00:00
|
|
|
clang-analyze-check-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
2020-04-18 15:45:46 +00:00
|
|
|
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()
|