Рефакторинг

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)
set(_args --analyze --extra-arg="-Wno-unknown-warning-option")
get_target_property(__sources ${target} SOURCES)
list(FILTER __sources EXCLUDE REGEX "qrc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "moc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "ui_.*\\.h$")
if(CLANG_CHECK_EXE) if(CLANG_CHECK_EXE)
set(_args --analyze --extra-arg="-Wno-unknown-warning-option")
get_target_property(__sources ${target} SOURCES)
list(FILTER __sources EXCLUDE REGEX "qrc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "moc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "ui_.*\\.h$")
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)
set(_args -extra-arg="-Wno-unknown-warning-option")
get_target_property(__sources ${target} SOURCES)
list(FILTER __sources EXCLUDE REGEX "qrc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "moc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "ui_.*\\.h$")
if(CLANG_TIDY_EXE) if(CLANG_TIDY_EXE)
set(_args -extra-arg="-Wno-unknown-warning-option")
get_target_property(__sources ${target} SOURCES)
list(FILTER __sources EXCLUDE REGEX "qrc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "moc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "ui_.*\\.h$")
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,25 +17,23 @@ if(CLAZY_EXE AND CLANG_APPLY_REPLACEMENTS_EXE)
endif() endif()
function(myx_cmake_clazy_analyze target) function(myx_cmake_clazy_analyze target)
set(options)
set(oneValueArgs CHECKS)
set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
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"
)
endif()
get_target_property(__sources ${target} SOURCES)
list(FILTER __sources EXCLUDE REGEX "qrc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "moc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "ui_.*\\.h$")
set(_args -checks=${ARG_CHECKS} -extra-arg="-Wno-unknown-warning-option"
-export-fixes=clazy-fixes-file.yaml)
if(CLAZY_EXE) if(CLAZY_EXE)
set(options)
set(oneValueArgs CHECKS)
set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
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")
endif()
get_target_property(__sources ${target} SOURCES)
list(FILTER __sources EXCLUDE REGEX "qrc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "moc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "ui_.*\\.h$")
set(_args -checks=${ARG_CHECKS} -extra-arg="-Wno-unknown-warning-option"
-export-fixes=clazy-fixes-file.yaml)
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,22 +1,22 @@
function(myx_cmake_format_sources target) function(myx_cmake_format_sources target)
get_target_property(__sources ${target} SOURCES)
list(FILTER __sources EXCLUDE REGEX "qrc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "moc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "ui_.*\\.h$")
if(NOT TARGET myx-cmake-format-sources)
add_custom_target(myx-cmake-format-sources)
endif()
if(NOT TARGET myx-cmake-check-format-sources)
add_custom_target(myx-cmake-check-format-sources)
endif()
if(NOT TARGET myx-cmake-add-doxygen-comments)
add_custom_target(myx-cmake-add-doxygen-comments)
endif()
find_program(UNCRUSTIFY_EXE NAMES uncrustify) find_program(UNCRUSTIFY_EXE NAMES uncrustify)
if(UNCRUSTIFY_EXE) if(UNCRUSTIFY_EXE)
get_target_property(__sources ${target} SOURCES)
list(FILTER __sources EXCLUDE REGEX "qrc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "moc_.*\\.cpp$")
list(FILTER __sources EXCLUDE REGEX "ui_.*\\.h$")
if(NOT TARGET myx-cmake-format-sources)
add_custom_target(myx-cmake-format-sources)
endif()
if(NOT TARGET myx-cmake-check-format-sources)
add_custom_target(myx-cmake-check-format-sources)
endif()
if(NOT TARGET myx-cmake-add-doxygen-comments)
add_custom_target(myx-cmake-add-doxygen-comments)
endif()
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()