Добавлена проверка clang-check -analyze

This commit is contained in:
Andrei Astafev 2019-06-30 18:45:56 +03:00
parent 22afe7b94c
commit 8122c0f0a8
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,25 @@
function(add_clang_analyze_check)
list(GET ARGN 0 _target)
set(_sources ${ARGN})
list(REMOVE_AT _sources 0)
option(CLANG_ANALYZE_FIX "Perform fixes for Clang-Check" OFF)
find_program(CLANG_CHECK_EXE
NAMES clang-check-9 clang-check-8 clang-check-7 clang-check-6.0 clang-check)
if(CLANG_CHECK_EXE)
if(CLANG_CHECK_FIX)
list(APPEND _args "-fix")
endif()
if(NOT TARGET clang-analyze-check)
add_custom_target(clang-analyze-check)
endif()
add_custom_target(clang-analyze-check-${_target}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CLANG_CHECK_EXE} -analyze -extra-arg="-Wno-unknown-warning-option" -p ${CMAKE_BINARY_DIR} ${_sources})
add_dependencies(clang-analyze-check-${_target} ${_target})
add_dependencies(clang-analyze-check clang-analyze-check-${_target})
else()
message(WARNING "ClangCheck is not found")
endif()
endfunction()

View File

@ -31,6 +31,7 @@ include(CMLibCommonTargetProperties)
include(CMLibCommonLibraryTarget) include(CMLibCommonLibraryTarget)
include(CMLibBuildTypes) include(CMLibBuildTypes)
include(CMLibCodeAnalysisPvsStudio) include(CMLibCodeAnalysisPvsStudio)
include(CMLibCodeAnalysisClangAnalyze)
include(CMLibCodeAnalysisClangTidy) include(CMLibCodeAnalysisClangTidy)
include(CMLibCodeAnalysisClazy) include(CMLibCodeAnalysisClazy)
include(cotire) include(cotire)