2020-04-22 16:14:51 +00:00
|
|
|
find_program(CLANG_APPLY_REPLACEMENTS_EXE NAMES clang-apply-replacements-10 clang-apply-replacements-9
|
|
|
|
clang-apply-replacements)
|
2020-04-19 07:37:01 +00:00
|
|
|
|
|
|
|
find_program(CLAZY_EXE NAMES clazy-standalone)
|
|
|
|
|
|
|
|
if(CLAZY_EXE AND CLANG_APPLY_REPLACEMENTS_EXE)
|
|
|
|
option(CMLIB_CLAZY_FIX "Perform fixes for Clazy" OFF)
|
|
|
|
endif()
|
|
|
|
|
2020-04-13 16:44:42 +00:00
|
|
|
function(add_clazy_check target)
|
2020-04-19 07:37:01 +00:00
|
|
|
set(options)
|
|
|
|
set(oneValueArgs CHECKS)
|
|
|
|
set(multiValueArgs)
|
|
|
|
|
|
|
|
cmake_parse_arguments(_CLAZY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
|
|
2020-04-19 08:01:53 +00:00
|
|
|
set(_sources ${_CLAZY_UNPARSED_ARGUMENTS})
|
2020-04-19 07:37:01 +00:00
|
|
|
if(NOT _CLAZY_CHECKS)
|
2020-04-22 16:14:51 +00:00
|
|
|
set(_CLAZY_CHECKS
|
|
|
|
"level2,container-inside-loop,heap-allocated-small-trivial-type,inefficient-qlist,isempty-vs-count,qt-keywords,unneeded-cast"
|
|
|
|
)
|
2020-04-19 07:37:01 +00:00
|
|
|
endif()
|
2020-04-22 16:14:51 +00:00
|
|
|
set(_args -checks=${_CLAZY_CHECKS} -extra-arg="-Wno-unknown-warning-option"
|
|
|
|
-export-fixes=clazy-fixes-file.yaml)
|
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-19 07:37:01 +00:00
|
|
|
if(CMLIB_CLAZY_FIX)
|
2020-04-22 16:14:51 +00:00
|
|
|
add_custom_target(
|
|
|
|
clazy-check-${target}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
COMMAND ${CLAZY_EXE} ${_args} -p ${CMAKE_BINARY_DIR} ${_sources}
|
|
|
|
COMMAND ${CLANG_APPLY_REPLACEMENTS_EXE} ${CMAKE_BINARY_DIR})
|
2020-04-19 07:37:01 +00:00
|
|
|
else()
|
|
|
|
add_custom_target(clazy-check-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
2020-04-22 16:14:51 +00:00
|
|
|
COMMAND ${CLAZY_EXE} ${_args} -p ${CMAKE_BINARY_DIR} ${_sources})
|
2020-04-19 07:37:01 +00:00
|
|
|
endif()
|
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()
|