cmlib/CMLibCodeAnalysisClazy.cmake

24 lines
822 B
CMake
Raw Normal View History

2019-12-03 16:23:14 +00:00
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()
2019-12-03 16:23:14 +00:00
add_custom_target(
clazy-check-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
2020-04-01 18:42:59 +00:00
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()