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) if(MYXX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE) set(PACKAGE_VERSION_COMPATIBLE FALSE)
else() else()

View File

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

View File

@ -13,14 +13,16 @@ endif()
find_program(CLANG_TIDY_EXE NAMES ${CLANG_TIDY_NAMES}) find_program(CLANG_TIDY_EXE NAMES ${CLANG_TIDY_NAMES})
unset(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) if(NOT CLANG_TIDY_EXE)
message(STATUS "MyxxCMake: Clang Tidy analyzer is not found") message(STATUS "MyxxCMake: Clang Tidy analyzer is not found")
return() return()
endif() endif()
if(TARGET ${target}-analyze-clang-tidy) if(TARGET ${TARGET_NAME}-analyze-clang-tidy)
message(STATUS "MyxxCMake: target ${target}-analyze-clang-tidy already exists") message(STATUS "MyxxCMake: target ${TARGET_NAME}-analyze-clang-tidy already exists")
return() return()
endif() endif()
@ -29,24 +31,24 @@ function(myxx_analyze_clang_tidy target)
set(multiValueArgs EXTRA_ARGS) set(multiValueArgs EXTRA_ARGS)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(args -extra-arg="-Wno-unknown-warning-option ${ARG_EXTRA_ARGS}") set(__cmd_args -extra-arg="-Wno-unknown-warning-option ${ARG_EXTRA_ARGS}")
get_target_property(sources ${target} SOURCES) get_target_property(__sources ${TARGET_NAME} SOURCES)
foreach(iter ${sources}) foreach(iter ${__sources})
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos) string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
if(pos EQUAL -1) if(pos EQUAL -1)
list(APPEND srcs ${iter}) list(APPEND __filtered_sources ${iter})
endif() endif()
endforeach() endforeach()
if(ARG_FIX) if(ARG_FIX)
list(APPEND args "-fix-errors") list(APPEND __cmd_args "-fix-errors")
endif() endif()
if(NOT TARGET myxx-analyze-clang-tidy) if(NOT TARGET myxx-analyze-clang-tidy)
add_custom_target(myxx-analyze-clang-tidy) add_custom_target(myxx-analyze-clang-tidy)
endif() endif()
add_custom_target(${target}-analyze-clang-tidy add_custom_target(${TARGET_NAME}-analyze-clang-tidy
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${CLANG_TIDY_EXE} ${args} -p ${CMAKE_BINARY_DIR} ${srcs}) COMMAND ${CLANG_TIDY_EXE} ${__cmd_args} -p ${CMAKE_BINARY_DIR} ${__filtered_sources})
add_dependencies(${target}-analyze-clang-tidy ${target}) add_dependencies(${TARGET_NAME}-analyze-clang-tidy ${TARGET_NAME})
add_dependencies(myxx-analyze-clang-tidy ${target}-analyze-clang-tidy) add_dependencies(myxx-analyze-clang-tidy ${TARGET_NAME}-analyze-clang-tidy)
endfunction() 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) option(MYXX_CMAKE_CLAZY_FIX "MyxCMake: perform fixes for Clazy" OFF)
endif() endif()
function(myxx_analyze_clazy target) function(myxx_analyze_clazy TARGET_NAME)
myx_skip_external_target(${TARGET_NAME})
if(NOT CLAZY_EXE) if(NOT CLAZY_EXE)
message(STATUS "MyxCMake: Clazy standalone analyzer is not found") message(STATUS "MyxCMake: Clazy standalone analyzer is not found")
return() return()
endif() endif()
if(TARGET ${target}-analyze-clazy) if(TARGET ${TARGET_NAME}-analyze-clazy)
message(STATUS "MyxxCMake: target ${target}-analyze-clazy already exists") message(STATUS "MyxxCMake: target ${TARGET_NAME}-analyze-clazy already exists")
return() return()
endif() endif()
@ -30,14 +32,14 @@ function(myxx_analyze_clazy target)
thread-with-slots,tr-non-literal,unneeded-cast,use-chrono-in-qtimer") thread-with-slots,tr-non-literal,unneeded-cast,use-chrono-in-qtimer")
endif() endif()
set(args -checks=${ARG_CHECKS} set(__cmd_args -checks=${ARG_CHECKS}
-extra-arg=-Wno-unknown-warning-option -extra-arg=-Wno-unknown-warning-option
-export-fixes=clazy-fixes-file.yaml) -export-fixes=clazy-fixes-file.yaml)
get_target_property(sources ${target} SOURCES) get_target_property(__sources ${TARGET_NAME} SOURCES)
foreach(iter ${sources}) foreach(iter ${__sources})
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos) string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
if(pos EQUAL -1) if(pos EQUAL -1)
list(APPEND srcs ${iter}) list(APPEND __filtered_sources ${iter})
endif() endif()
endforeach() endforeach()
@ -46,15 +48,15 @@ function(myxx_analyze_clazy target)
endif() endif()
if(ARG_FIX) if(ARG_FIX)
add_custom_target(${target}-analyze-clazy add_custom_target(${TARGET_NAME}-analyze-clazy
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 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}) COMMAND ${CLANG_APPLY_REPLACEMENTS_EXE} ${CMAKE_BINARY_DIR})
else() else()
add_custom_target(${target}-analyze-clazy add_custom_target(${TARGET_NAME}-analyze-clazy
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 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() endif()
add_dependencies(${target}-analyze-clazy ${target}) add_dependencies(${TARGET_NAME}-analyze-clazy ${TARGET_NAME})
add_dependencies(myxx-analyze-clazy ${target}-analyze-clazy) add_dependencies(myxx-analyze-clazy ${TARGET_NAME}-analyze-clazy)
endfunction() 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}) set(MYXX_CMAKE_LIB_PVS_DIR_BACKPORT ${CMAKE_CURRENT_LIST_DIR})
endif() endif()
function(myxx_analyze_pvs_studio target) function(myxx_analyze_pvs_studio TARGET_NAME)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0") if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYXX_CMAKE_LIB_PVS_DIR_BACKPORT}) set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYXX_CMAKE_LIB_PVS_DIR_BACKPORT})
endif() endif()
myx_skip_external_target(${TARGET_NAME})
if(NOT PVS_STUDIO_ANALYZER_EXE) if(NOT PVS_STUDIO_ANALYZER_EXE)
message(STATUS "MyxxCMake: pvs-studio-analyzer not found.") message(STATUS "MyxxCMake: pvs-studio-analyzer not found.")
return() 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") set(ARG_MODE "GA:1,2,3;64:1,2;OP:1,2,3;CS:1,2;OWASP:1,2")
endif() endif()
get_target_property(sources ${target} SOURCES) get_target_property(sources ${TARGET_NAME} SOURCES)
foreach(iter ${sources}) foreach(iter ${sources})
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos) string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
if(pos EQUAL -1) if(pos EQUAL -1)
@ -42,8 +45,8 @@ function(myxx_analyze_pvs_studio target)
endif() endif()
endforeach() endforeach()
pvs_studio_add_target(TARGET ${target}-analyze-pvs-studio pvs_studio_add_target(TARGET ${TARGET_NAME}-analyze-pvs-studio
ANALYZE ${target} ANALYZE ${TARGET_NAME}
COMPILE_COMMANDS COMPILE_COMMANDS
HIDE_HELP HIDE_HELP
OUTPUT OUTPUT
@ -51,18 +54,18 @@ function(myxx_analyze_pvs_studio target)
ARGS --exclude-path ${CMAKE_CURRENT_BINARY_DIR} ${ARG_ARGS} ARGS --exclude-path ${CMAKE_CURRENT_BINARY_DIR} ${ARG_ARGS}
MODE ${ARG_MODE}) MODE ${ARG_MODE})
get_target_property(target_type ${target} TYPE) get_target_property(__target_type ${TARGET_NAME} TYPE)
if(${target_type} STREQUAL INTERFACE_LIBRARY) if(${__target_type} STREQUAL INTERFACE_LIBRARY)
set(target_type INTERFACE) set(__target_type INTERFACE)
else() else()
set(target_type PRIVATE) set(__target_type PRIVATE)
endif() endif()
if(MSVC) 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 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() endif()
add_dependencies(${target}-analyze-pvs-studio ${target}) add_dependencies(${TARGET_NAME}-analyze-pvs-studio ${TARGET_NAME})
add_dependencies(myxx-analyze-pvs-studio ${target}-analyze-pvs-studio) add_dependencies(myxx-analyze-pvs-studio ${TARGET_NAME}-analyze-pvs-studio)
endfunction() endfunction()

View File

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

View File

@ -2,9 +2,9 @@
## Установка ## Установка
Скачать [пакет](../../../releases/download/2.0.8/myxx-cmake_2.0.8_all.deb) Скачать [пакет](../../../releases/download/2.0.9/myxx-cmake_2.0.9_all.deb)
для Debian и установить его, выполнив команду `sudo dpkg -i myxx-cmake_2.0.8_all.deb`, для Debian и установить его, выполнив команду `sudo dpkg -i myxx-cmake_2.0.9_all.deb`,
или [архив](../../../releases/download/2.0.8/myxx-cmake-local-2.0.8.tar.xz) или [архив](../../../releases/download/2.0.9/myxx-cmake-local-2.0.9.tar.xz)
и распаковать его в каталог `$HOME/.local/share/cmake`. и распаковать его в каталог `$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) 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) include(GNUInstallDirs)
file(WRITE ${CMAKE_SOURCE_DIR}/MyxxCMake/MyxxCMakeConfigVersion.cmake 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. * New version.