This commit is contained in:
Andrei Astafev 2022-10-09 21:15:35 +03:00
parent fe4129114c
commit 54f8cfc1cc
10 changed files with 79 additions and 69 deletions

View File

@ -1,4 +1,4 @@
set(MYXX_CMAKE_PACKAGE_VERSION "2.0.8")
set(MYXX_CMAKE_PACKAGE_VERSION "2.0.9")
if(MYXX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()

View File

@ -13,14 +13,16 @@ endif()
find_program(CLANG_CHECK_EXE NAMES ${CLANG_CHECK_NAMES})
unset(CLANG_CHECK_NAMES)
function(myxx_analyze_clang_check target)
function(myxx_analyze_clang_check TARGET_NAME)
myx_skip_external_target(${TARGET_NAME})
if(NOT CLANG_CHECK_EXE)
message(STATUS "MyxCMake: Clang Check analyzer is not found")
return()
endif()
if(TARGET ${target}-analyze-clang-check)
message(STATUS "MyxxCMake: target ${target}-analyze-clang-check already exists")
if(TARGET ${TARGET_NAME}-analyze-clang-check)
message(STATUS "MyxxCMake: target ${TARGET_NAME}-analyze-clang-check already exists")
return()
endif()
@ -29,24 +31,24 @@ function(myxx_analyze_clang_check target)
set(multiValueArgs EXTRA_ARGS)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(args --analyze --extra-arg=-Wno-unknown-warning-option ${EXTRA_ARGS})
get_target_property(sources ${target} SOURCES)
foreach(iter ${sources})
set(__cmd_args --analyze --extra-arg=-Wno-unknown-warning-option ${EXTRA_ARGS})
get_target_property(__sources ${TARGET_NAME} SOURCES)
foreach(iter ${__sources})
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
if(pos EQUAL -1)
list(APPEND srcs ${iter})
list(APPEND __filtered_sources ${iter})
endif()
endforeach()
if(ARG_FIX)
list(APPEND args "--fixit")
list(APPEND __cmd_args "--fixit")
endif()
if(NOT TARGET myxx-analyze-clang-check)
add_custom_target(myxx-analyze-clang-check)
endif()
add_custom_target(${target}-analyze-clang-check
add_custom_target(${TARGET_NAME}-analyze-clang-check
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${CLANG_CHECK_EXE} ${args} -p ${CMAKE_BINARY_DIR} ${srcs})
add_dependencies(${target}-analyze-clang-check ${target})
add_dependencies(myxx-analyze-clang-check ${target}-analyze-clang-check)
COMMAND ${CLANG_CHECK_EXE} ${__cmd_args} -p ${CMAKE_BINARY_DIR} ${__filtered_sources})
add_dependencies(${TARGET_NAME}-analyze-clang-check ${TARGET_NAME})
add_dependencies(myxx-analyze-clang-check ${TARGET_NAME}-analyze-clang-check)
endfunction()

View File

@ -13,14 +13,16 @@ endif()
find_program(CLANG_TIDY_EXE NAMES ${CLANG_TIDY_NAMES})
unset(CLANG_TIDY_NAMES)
function(myxx_analyze_clang_tidy target)
function(myxx_analyze_clang_tidy TARGET_NAME)
myx_skip_external_target(${TARGET_NAME})
if(NOT CLANG_TIDY_EXE)
message(STATUS "MyxxCMake: Clang Tidy analyzer is not found")
return()
endif()
if(TARGET ${target}-analyze-clang-tidy)
message(STATUS "MyxxCMake: target ${target}-analyze-clang-tidy already exists")
if(TARGET ${TARGET_NAME}-analyze-clang-tidy)
message(STATUS "MyxxCMake: target ${TARGET_NAME}-analyze-clang-tidy already exists")
return()
endif()
@ -29,24 +31,24 @@ function(myxx_analyze_clang_tidy target)
set(multiValueArgs EXTRA_ARGS)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(args -extra-arg="-Wno-unknown-warning-option ${ARG_EXTRA_ARGS}")
get_target_property(sources ${target} SOURCES)
foreach(iter ${sources})
set(__cmd_args -extra-arg="-Wno-unknown-warning-option ${ARG_EXTRA_ARGS}")
get_target_property(__sources ${TARGET_NAME} SOURCES)
foreach(iter ${__sources})
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
if(pos EQUAL -1)
list(APPEND srcs ${iter})
list(APPEND __filtered_sources ${iter})
endif()
endforeach()
if(ARG_FIX)
list(APPEND args "-fix-errors")
list(APPEND __cmd_args "-fix-errors")
endif()
if(NOT TARGET myxx-analyze-clang-tidy)
add_custom_target(myxx-analyze-clang-tidy)
endif()
add_custom_target(${target}-analyze-clang-tidy
add_custom_target(${TARGET_NAME}-analyze-clang-tidy
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${CLANG_TIDY_EXE} ${args} -p ${CMAKE_BINARY_DIR} ${srcs})
add_dependencies(${target}-analyze-clang-tidy ${target})
add_dependencies(myxx-analyze-clang-tidy ${target}-analyze-clang-tidy)
COMMAND ${CLANG_TIDY_EXE} ${__cmd_args} -p ${CMAKE_BINARY_DIR} ${__filtered_sources})
add_dependencies(${TARGET_NAME}-analyze-clang-tidy ${TARGET_NAME})
add_dependencies(myxx-analyze-clang-tidy ${TARGET_NAME}-analyze-clang-tidy)
endfunction()

View File

@ -6,14 +6,16 @@ if(CLAZY_EXE AND CLANG_APPLY_REPLACEMENTS_EXE)
option(MYXX_CMAKE_CLAZY_FIX "MyxCMake: perform fixes for Clazy" OFF)
endif()
function(myxx_analyze_clazy target)
function(myxx_analyze_clazy TARGET_NAME)
myx_skip_external_target(${TARGET_NAME})
if(NOT CLAZY_EXE)
message(STATUS "MyxCMake: Clazy standalone analyzer is not found")
return()
endif()
if(TARGET ${target}-analyze-clazy)
message(STATUS "MyxxCMake: target ${target}-analyze-clazy already exists")
if(TARGET ${TARGET_NAME}-analyze-clazy)
message(STATUS "MyxxCMake: target ${TARGET_NAME}-analyze-clazy already exists")
return()
endif()
@ -30,14 +32,14 @@ function(myxx_analyze_clazy target)
thread-with-slots,tr-non-literal,unneeded-cast,use-chrono-in-qtimer")
endif()
set(args -checks=${ARG_CHECKS}
set(__cmd_args -checks=${ARG_CHECKS}
-extra-arg=-Wno-unknown-warning-option
-export-fixes=clazy-fixes-file.yaml)
get_target_property(sources ${target} SOURCES)
foreach(iter ${sources})
get_target_property(__sources ${TARGET_NAME} SOURCES)
foreach(iter ${__sources})
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
if(pos EQUAL -1)
list(APPEND srcs ${iter})
list(APPEND __filtered_sources ${iter})
endif()
endforeach()
@ -46,15 +48,15 @@ function(myxx_analyze_clazy target)
endif()
if(ARG_FIX)
add_custom_target(${target}-analyze-clazy
add_custom_target(${TARGET_NAME}-analyze-clazy
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${CLAZY_EXE} ${args} -p ${CMAKE_BINARY_DIR} ${srcs}
COMMAND ${CLAZY_EXE} ${__cmd_args} -p ${CMAKE_BINARY_DIR} ${__filtered_sources}
COMMAND ${CLANG_APPLY_REPLACEMENTS_EXE} ${CMAKE_BINARY_DIR})
else()
add_custom_target(${target}-analyze-clazy
add_custom_target(${TARGET_NAME}-analyze-clazy
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${CLAZY_EXE} ${args} -p ${CMAKE_BINARY_DIR} ${srcs})
COMMAND ${CLAZY_EXE} ${__cmd_args} -p ${CMAKE_BINARY_DIR} ${__filtered_sources})
endif()
add_dependencies(${target}-analyze-clazy ${target})
add_dependencies(myxx-analyze-clazy ${target}-analyze-clazy)
add_dependencies(${TARGET_NAME}-analyze-clazy ${TARGET_NAME})
add_dependencies(myxx-analyze-clazy ${TARGET_NAME}-analyze-clazy)
endfunction()

View File

@ -5,10 +5,13 @@ if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(MYXX_CMAKE_LIB_PVS_DIR_BACKPORT ${CMAKE_CURRENT_LIST_DIR})
endif()
function(myxx_analyze_pvs_studio target)
function(myxx_analyze_pvs_studio TARGET_NAME)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYXX_CMAKE_LIB_PVS_DIR_BACKPORT})
endif()
myx_skip_external_target(${TARGET_NAME})
if(NOT PVS_STUDIO_ANALYZER_EXE)
message(STATUS "MyxxCMake: pvs-studio-analyzer not found.")
return()
@ -34,7 +37,7 @@ function(myxx_analyze_pvs_studio target)
set(ARG_MODE "GA:1,2,3;64:1,2;OP:1,2,3;CS:1,2;OWASP:1,2")
endif()
get_target_property(sources ${target} SOURCES)
get_target_property(sources ${TARGET_NAME} SOURCES)
foreach(iter ${sources})
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
if(pos EQUAL -1)
@ -42,8 +45,8 @@ function(myxx_analyze_pvs_studio target)
endif()
endforeach()
pvs_studio_add_target(TARGET ${target}-analyze-pvs-studio
ANALYZE ${target}
pvs_studio_add_target(TARGET ${TARGET_NAME}-analyze-pvs-studio
ANALYZE ${TARGET_NAME}
COMPILE_COMMANDS
HIDE_HELP
OUTPUT
@ -51,18 +54,18 @@ function(myxx_analyze_pvs_studio target)
ARGS --exclude-path ${CMAKE_CURRENT_BINARY_DIR} ${ARG_ARGS}
MODE ${ARG_MODE})
get_target_property(target_type ${target} TYPE)
if(${target_type} STREQUAL INTERFACE_LIBRARY)
set(target_type INTERFACE)
get_target_property(__target_type ${TARGET_NAME} TYPE)
if(${__target_type} STREQUAL INTERFACE_LIBRARY)
set(__target_type INTERFACE)
else()
set(target_type PRIVATE)
set(__target_type PRIVATE)
endif()
if(MSVC)
target_compile_options(${target} BEFORE ${target_type} /FI ${ARG_HEADER})
target_compile_options(${TARGET_NAME} BEFORE ${__target_type} /FI ${ARG_HEADER})
else() # GCC/Clang
target_compile_options(${target} BEFORE ${target_type} -include ${ARG_HEADER})
target_compile_options(${TARGET_NAME} BEFORE ${__target_type} -include ${ARG_HEADER})
endif()
add_dependencies(${target}-analyze-pvs-studio ${target})
add_dependencies(myxx-analyze-pvs-studio ${target}-analyze-pvs-studio)
add_dependencies(${TARGET_NAME}-analyze-pvs-studio ${TARGET_NAME})
add_dependencies(myxx-analyze-pvs-studio ${TARGET_NAME}-analyze-pvs-studio)
endfunction()

View File

@ -5,10 +5,11 @@ if(MYXX_CODE_COVERAGE)
find_program(GENHTML_EXE NAMES genhtml)
endif()
function(myxx_code_coverage target)
function(myxx_code_coverage TARGET_NAME)
if(NOT MYXX_CODE_COVERAGE)
return()
endif()
myx_skip_external_target(${TARGET_NAME})
set(options)
set(oneValueArgs)
@ -16,33 +17,33 @@ function(myxx_code_coverage target)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set_property(TARGET ${target} APPEND PROPERTY
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY
COMPILE_OPTIONS --coverage)
set_property(TARGET ${target} APPEND PROPERTY LINK_FLAGS --coverage)
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY LINK_FLAGS --coverage)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set_property(TARGET ${target} APPEND PROPERTY
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY
COMPILE_OPTIONS -fprofile-instr-generate -fcoverage-mapping)
set_property(TARGET ${target} APPEND PROPERTY LINK_FLAGS --coverage)
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY LINK_FLAGS --coverage)
endif()
if(LCOV_EXE)
add_custom_target(${target}-coverage
add_custom_target(${TARGET_NAME}-coverage
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${LCOV_EXE} --test-name ${target} --output "${target}.lcov"
COMMAND ${LCOV_EXE} --test-name ${TARGET_NAME} --output "${TARGET_NAME}.lcov"
--capture
--no-external
--base-directory ${CMAKE_SOURCE_DIR}
--directory ${CMAKE_BINARY_DIR}
--exclude "/usr/\\\*"
--exclude "${CMAKE_BINARY_DIR}/\\\*")
add_dependencies(${target}-coverage ${target})
add_dependencies(${TARGET_NAME}-coverage ${TARGET_NAME})
if(GENHTML_EXE)
add_custom_target(${target}-coverage-report
add_custom_target(${TARGET_NAME}-coverage-report
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${GENHTML_EXE} --output-directory "${target}-coverage-html" "${target}.lcov")
add_dependencies(${target}-coverage-report ${target}-coverage)
COMMAND ${GENHTML_EXE} --output-directory "${TARGET_NAME}-coverage-html" "${TARGET_NAME}.lcov")
add_dependencies(${TARGET_NAME}-coverage-report ${TARGET_NAME}-coverage)
endif()
endif()
endfunction()

View File

@ -2,9 +2,9 @@
## Установка
Скачать [пакет](../../../releases/download/2.0.8/myxx-cmake_2.0.8_all.deb)
для Debian и установить его, выполнив команду `sudo dpkg -i myxx-cmake_2.0.8_all.deb`,
или [архив](../../../releases/download/2.0.8/myxx-cmake-local-2.0.8.tar.xz)
Скачать [пакет](../../../releases/download/2.0.9/myxx-cmake_2.0.9_all.deb)
для Debian и установить его, выполнив команду `sudo dpkg -i myxx-cmake_2.0.9_all.deb`,
или [архив](../../../releases/download/2.0.9/myxx-cmake-local-2.0.9.tar.xz)
и распаковать его в каталог `$HOME/.local/share/cmake`.
## Использование

View File

@ -1 +1 @@
2.0.8
2.0.9

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
project(myxx-cmake VERSION 2.0.8 LANGUAGES)
project(myxx-cmake VERSION 2.0.9 LANGUAGES)
include(GNUInstallDirs)
file(WRITE ${CMAKE_SOURCE_DIR}/MyxxCMake/MyxxCMakeConfigVersion.cmake

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
myxx-cmake (2.0.8) unstable; urgency=medium
myxx-cmake (2.0.9) unstable; urgency=medium
* New version.