cmlib/CMLibCodeAnalysisClazy.cmake

26 lines
875 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)
list(GET ARGN 0 _target)
set(_sources ${ARGN})
list(REMOVE_AT _sources 0)
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()