This commit is contained in:
Andrei Astafev 2022-10-19 16:59:18 +03:00
parent b3d19b7336
commit f1b574cd50
8 changed files with 58 additions and 34 deletions

View File

@ -38,24 +38,31 @@ function(myxx)
return() return()
endif() endif()
get_property(targets DIRECTORY ${CMAKE_BINARY_DIR} PROPERTY BUILDSYSTEM_TARGETS) if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
foreach(iter ${targets}) return()
get_target_property(target_type ${iter} TYPE)
if((NOT ${target_type} STREQUAL "UTILITY") AND
(NOT ${iter} MATCHES ".*_shared$" ) AND
(NOT ${iter} MATCHES ".*_static$" )
)
myxx_code_coverage(${iter})
myxx_analyze_clang_tidy(${iter})
myxx_analyze_clang_tidy_naming(${iter})
myxx_analyze_clang_check(${iter})
if(MYXX_CMAKE_CLAZY_FIX)
myxx_analyze_clazy(${iter} FIX)
else()
myxx_analyze_clazy(${iter})
endif() endif()
myxx_analyze_pvs_studio(${iter})
myxx_add_sanitizers(${iter}) get_property(__targets DIRECTORY ${CMAKE_BINARY_DIR} PROPERTY BUILDSYSTEM_TARGETS)
foreach(__iter ${__targets})
get_target_property(__target_type ${__iter} TYPE)
if((NOT ${__target_type} STREQUAL "UTILITY") AND
(NOT ${__target_type} STREQUAL "INTERFACE_LIBRARY") AND
(NOT ${__iter} MATCHES ".*_shared$" ) AND
(NOT ${__iter} MATCHES ".*_static$" )
)
message(${__target_type} ${__iter})
myxx_code_coverage(${__iter})
myxx_analyze_clang_tidy(${__iter})
myxx_analyze_clang_tidy_naming(${__iter})
myxx_analyze_clang_check(${__iter})
if(MYXX_CMAKE_CLAZY_FIX)
myxx_analyze_clazy(${__iter} FIX)
else()
myxx_analyze_clazy(${__iter})
endif()
myxx_analyze_pvs_studio(${__iter})
myxx_add_sanitizers(${__iter})
endif() endif()
endforeach() endforeach()
endfunction(myxx) endfunction(myxx)

View File

@ -14,7 +14,9 @@ find_program(CLANG_CHECK_EXE NAMES ${CLANG_CHECK_NAMES})
unset(CLANG_CHECK_NAMES) unset(CLANG_CHECK_NAMES)
function(myxx_analyze_clang_check TARGET_NAME) function(myxx_analyze_clang_check TARGET_NAME)
myx_skip_external_target(${TARGET_NAME}) if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
return()
endif()
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")

View File

@ -14,7 +14,9 @@ find_program(CLANG_TIDY_EXE NAMES ${CLANG_TIDY_NAMES})
unset(CLANG_TIDY_NAMES) unset(CLANG_TIDY_NAMES)
function(myxx_analyze_clang_tidy TARGET_NAME) function(myxx_analyze_clang_tidy TARGET_NAME)
myx_skip_external_target(${TARGET_NAME}) if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
return()
endif()
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")
@ -55,7 +57,9 @@ endfunction()
function(myxx_analyze_clang_tidy_naming TARGET_NAME) function(myxx_analyze_clang_tidy_naming TARGET_NAME)
myx_skip_external_target(${TARGET_NAME}) if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
return()
endif()
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")
@ -82,10 +86,10 @@ function(myxx_analyze_clang_tidy_naming TARGET_NAME)
set(__cmd_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_NAME} 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 __filtered_sources ${iter}) list(APPEND __filtered_sources ${__iter})
endif() endif()
endforeach() endforeach()

View File

@ -7,7 +7,9 @@ if(CLAZY_EXE AND CLANG_APPLY_REPLACEMENTS_EXE)
endif() endif()
function(myxx_analyze_clazy TARGET_NAME) function(myxx_analyze_clazy TARGET_NAME)
myx_skip_external_target(${TARGET_NAME}) if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
return()
endif()
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")
@ -36,10 +38,10 @@ function(myxx_analyze_clazy TARGET_NAME)
-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_NAME} 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 __filtered_sources ${iter}) list(APPEND __filtered_sources ${__iter})
endif() endif()
endforeach() endforeach()

View File

@ -10,7 +10,9 @@ function(myxx_analyze_pvs_studio TARGET_NAME)
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 ${PROJECT_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
return()
endif()
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.")
@ -37,11 +39,11 @@ function(myxx_analyze_pvs_studio TARGET_NAME)
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_NAME} SOURCES) get_target_property(__target_sources ${TARGET_NAME} SOURCES)
foreach(iter ${sources}) foreach(__iter ${__target_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()

View File

@ -9,7 +9,10 @@ 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})
if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
return()
endif()
set(options) set(options)
set(oneValueArgs) set(oneValueArgs)

View File

@ -50,6 +50,10 @@ function(sanitizer_add_blacklist_file FILE)
endfunction() endfunction()
function(myxx_add_sanitizers ...) function(myxx_add_sanitizers ...)
if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
return()
endif()
# If no sanitizer is enabled, return immediately. # If no sanitizer is enabled, return immediately.
if(NOT if(NOT
(SANITIZE_ADDRESS (SANITIZE_ADDRESS

View File

@ -1 +1 @@
2.0.10 2.0.11