2020-04-13 16:44:42 +00:00
|
|
|
function(add_clazy_check target)
|
2020-04-18 16:36:28 +00:00
|
|
|
find_program(CLAZY_EXE NAMES clazy-standalone)
|
2019-06-15 13:16:27 +00:00
|
|
|
set(_sources ${ARGN})
|
2020-04-18 16:36:28 +00:00
|
|
|
set(_clazy_checks
|
2020-04-18 16:40:13 +00:00
|
|
|
"container-inside-loop,heap-allocated-small-trivial-type,inefficient-qlist,isempty-vs-count,qt-keywords,unneeded-cast"
|
|
|
|
)
|
2020-04-18 16:36:28 +00:00
|
|
|
set(_args -checks=level2,${_clazy_checks} -extra-arg="-Wno-unknown-warning-option")
|
2019-06-15 13:16:27 +00:00
|
|
|
|
|
|
|
if(CLAZY_EXE)
|
2019-06-27 02:18:29 +00:00
|
|
|
if(NOT TARGET clazy-check)
|
|
|
|
add_custom_target(clazy-check)
|
|
|
|
endif()
|
2020-04-18 16:40:13 +00:00
|
|
|
add_custom_target(clazy-check-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
COMMAND ${CLAZY_EXE} ${_args} -p ${CMAKE_BINARY_DIR} ${_sources})
|
2020-04-13 16:44:42 +00:00
|
|
|
add_dependencies(clazy-check-${target} ${target})
|
|
|
|
add_dependencies(clazy-check clazy-check-${target})
|
2019-06-15 13:16:27 +00:00
|
|
|
else()
|
2019-08-10 07:30:01 +00:00
|
|
|
message(STATUS "CMLIB warning:")
|
2020-04-18 16:36:28 +00:00
|
|
|
message(STATUS " Clazy standalone analyzer is not found")
|
2019-06-15 13:16:27 +00:00
|
|
|
endif()
|
|
|
|
endfunction()
|