cmlib/CMLibCodeAnalysisClazy.cmake

24 lines
822 B
CMake

set(clazy_checks
container-inside-loop,heap-allocated-small-trivial-type,inefficient-qlist,isempty-vs-count,qt-keywords,unneeded-cast
)
function(add_clazy_check target)
set(_sources ${ARGN})
find_program(CLAZY_EXE NAMES clazy-standalone)
if(CLAZY_EXE)
if(NOT TARGET clazy-check)
add_custom_target(clazy-check)
endif()
add_custom_target(
clazy-check-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CLAZY_EXE} -checks=level2,${clazy_checks} -extra-arg="-Wno-unknown-warning-option" -p
${CMAKE_BINARY_DIR} ${_sources})
add_dependencies(clazy-check-${target} ${target})
add_dependencies(clazy-check clazy-check-${target})
else()
message(STATUS "CMLIB warning:")
message(STATUS " Clazy analyzer is not found")
endif()
endfunction()