From dcafdee7464e8dc3b38954037f01ed5798c818f4 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Sun, 12 Dec 2021 19:44:29 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyxCMakeCodeAnalyzeClangCheck.cmake | 12 +++---- .../MyxCMakeCodeAnalyzeClangTidy.cmake | 12 +++---- .../modules/MyxCMakeCodeAnalyzeClazy.cmake | 34 +++++++++---------- MyxCMake/modules/MyxCMakeFormatSources.cmake | 30 ++++++++-------- 4 files changed, 43 insertions(+), 45 deletions(-) diff --git a/MyxCMake/modules/MyxCMakeCodeAnalyzeClangCheck.cmake b/MyxCMake/modules/MyxCMakeCodeAnalyzeClangCheck.cmake index aee4360..5c6a567 100644 --- a/MyxCMake/modules/MyxCMakeCodeAnalyzeClangCheck.cmake +++ b/MyxCMake/modules/MyxCMakeCodeAnalyzeClangCheck.cmake @@ -11,13 +11,13 @@ unset(V) unset(CLANG_CHECK_NAMES) 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) + 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) list(APPEND _args "--fixit") endif() diff --git a/MyxCMake/modules/MyxCMakeCodeAnalyzeClangTidy.cmake b/MyxCMake/modules/MyxCMakeCodeAnalyzeClangTidy.cmake index b3504a6..94d3d01 100644 --- a/MyxCMake/modules/MyxCMakeCodeAnalyzeClangTidy.cmake +++ b/MyxCMake/modules/MyxCMakeCodeAnalyzeClangTidy.cmake @@ -11,13 +11,13 @@ unset(V) unset(CLANG_TIDY_NAMES) 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) + 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) list(APPEND _args "--fix") endif() diff --git a/MyxCMake/modules/MyxCMakeCodeAnalyzeClazy.cmake b/MyxCMake/modules/MyxCMakeCodeAnalyzeClazy.cmake index 0e7b4d9..7527617 100644 --- a/MyxCMake/modules/MyxCMakeCodeAnalyzeClazy.cmake +++ b/MyxCMake/modules/MyxCMakeCodeAnalyzeClazy.cmake @@ -17,25 +17,23 @@ if(CLAZY_EXE AND CLANG_APPLY_REPLACEMENTS_EXE) endif() 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) + 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) add_custom_target(myx-cmake-clazy-analyze) endif() diff --git a/MyxCMake/modules/MyxCMakeFormatSources.cmake b/MyxCMake/modules/MyxCMakeFormatSources.cmake index 63d0111..782e02a 100644 --- a/MyxCMake/modules/MyxCMakeFormatSources.cmake +++ b/MyxCMake/modules/MyxCMakeFormatSources.cmake @@ -1,22 +1,22 @@ 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) 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) list(APPEND UNCRUSTIFY_OPTS -c ${CMAKE_SOURCE_DIR}/.uncrustify.cfg) endif()