Рефакторинг

This commit is contained in:
Andrei Astafev 2021-12-12 19:44:29 +03:00
parent 475afb8070
commit dcafdee746
4 changed files with 43 additions and 45 deletions

View File

@ -11,13 +11,13 @@ unset(V)
unset(CLANG_CHECK_NAMES) unset(CLANG_CHECK_NAMES)
function(myx_cmake_clang_check_analyze target) function(myx_cmake_clang_check_analyze target)
if(CLANG_CHECK_EXE)
set(_args --analyze --extra-arg="-Wno-unknown-warning-option") set(_args --analyze --extra-arg="-Wno-unknown-warning-option")
get_target_property(__sources ${target} SOURCES) get_target_property(__sources ${target} SOURCES)
list(FILTER __sources EXCLUDE REGEX "qrc_.*\\.cpp$") list(FILTER __sources EXCLUDE REGEX "qrc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "moc_.*\\.cpp$") list(FILTER __sources EXCLUDE REGEX "moc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "ui_.*\\.h$") list(FILTER __sources EXCLUDE REGEX "ui_.*\\.h$")
if(CLANG_CHECK_EXE)
if(MYX_CMAKE_CLANG_ANALYZE_FIX) if(MYX_CMAKE_CLANG_ANALYZE_FIX)
list(APPEND _args "--fixit") list(APPEND _args "--fixit")
endif() endif()

View File

@ -11,13 +11,13 @@ unset(V)
unset(CLANG_TIDY_NAMES) unset(CLANG_TIDY_NAMES)
function(myx_cmake_clang_tidy_analyze target) function(myx_cmake_clang_tidy_analyze target)
if(CLANG_TIDY_EXE)
set(_args -extra-arg="-Wno-unknown-warning-option") set(_args -extra-arg="-Wno-unknown-warning-option")
get_target_property(__sources ${target} SOURCES) get_target_property(__sources ${target} SOURCES)
list(FILTER __sources EXCLUDE REGEX "qrc_.*\\.cpp$") list(FILTER __sources EXCLUDE REGEX "qrc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "moc_.*\\.cpp$") list(FILTER __sources EXCLUDE REGEX "moc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "ui_.*\\.h$") list(FILTER __sources EXCLUDE REGEX "ui_.*\\.h$")
if(CLANG_TIDY_EXE)
if(MYX_CMAKE_CLANG_TIDY_FIX) if(MYX_CMAKE_CLANG_TIDY_FIX)
list(APPEND _args "--fix") list(APPEND _args "--fix")
endif() endif()

View File

@ -17,15 +17,14 @@ if(CLAZY_EXE AND CLANG_APPLY_REPLACEMENTS_EXE)
endif() endif()
function(myx_cmake_clazy_analyze target) function(myx_cmake_clazy_analyze target)
if(CLAZY_EXE)
set(options) set(options)
set(oneValueArgs CHECKS) set(oneValueArgs CHECKS)
set(multiValueArgs) set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT ARG_CHECKS) if(NOT ARG_CHECKS)
set(ARG_CHECKS "level2,container-inside-loop,heap-allocated-small-trivial-type,inefficient-qlist,isempty-vs-count,qt-keywords,unneeded-cast" set(ARG_CHECKS "level2,container-inside-loop,heap-allocated-small-trivial-type,inefficient-qlist,isempty-vs-count,qt-keywords,unneeded-cast")
)
endif() endif()
get_target_property(__sources ${target} SOURCES) get_target_property(__sources ${target} SOURCES)
@ -35,7 +34,6 @@ function(myx_cmake_clazy_analyze target)
set(_args -checks=${ARG_CHECKS} -extra-arg="-Wno-unknown-warning-option" set(_args -checks=${ARG_CHECKS} -extra-arg="-Wno-unknown-warning-option"
-export-fixes=clazy-fixes-file.yaml) -export-fixes=clazy-fixes-file.yaml)
if(CLAZY_EXE)
if(NOT TARGET myx-cmake-clazy-analyze) if(NOT TARGET myx-cmake-clazy-analyze)
add_custom_target(myx-cmake-clazy-analyze) add_custom_target(myx-cmake-clazy-analyze)
endif() endif()

View File

@ -1,5 +1,7 @@
function(myx_cmake_format_sources target) function(myx_cmake_format_sources target)
find_program(UNCRUSTIFY_EXE NAMES uncrustify)
if(UNCRUSTIFY_EXE)
get_target_property(__sources ${target} SOURCES) get_target_property(__sources ${target} SOURCES)
list(FILTER __sources EXCLUDE REGEX "qrc_.*\\.cpp$") list(FILTER __sources EXCLUDE REGEX "qrc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "moc_.*\\.cpp$") list(FILTER __sources EXCLUDE REGEX "moc_.*\\.cpp$")
@ -15,8 +17,6 @@ function(myx_cmake_format_sources target)
add_custom_target(myx-cmake-add-doxygen-comments) add_custom_target(myx-cmake-add-doxygen-comments)
endif() endif()
find_program(UNCRUSTIFY_EXE NAMES uncrustify)
if(UNCRUSTIFY_EXE)
if(EXISTS ${CMAKE_SOURCE_DIR}/.uncrustify.cfg) if(EXISTS ${CMAKE_SOURCE_DIR}/.uncrustify.cfg)
list(APPEND UNCRUSTIFY_OPTS -c ${CMAKE_SOURCE_DIR}/.uncrustify.cfg) list(APPEND UNCRUSTIFY_OPTS -c ${CMAKE_SOURCE_DIR}/.uncrustify.cfg)
endif() endif()