Проверка с помощью clang tidy
This commit is contained in:
parent
10bb16a535
commit
e49aead06f
21
CMLibClangTidy.cmake
Normal file
21
CMLibClangTidy.cmake
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
function(add_clang_tidy_check)
|
||||||
|
list(GET ARGN 0 _target)
|
||||||
|
set(_sources ${ARGN})
|
||||||
|
list(REMOVE_AT _sources 0)
|
||||||
|
|
||||||
|
option(CLANG_TIDY_FIX "Perform fixes for Clang-Tidy" OFF)
|
||||||
|
find_program(CLANG_TIDY_EXE
|
||||||
|
NAMES clang-tidy-9 clang-tidy-8 clang-tidy-7 clang-tidy-6.0 clang-tidy)
|
||||||
|
if(CLANG_TIDY_EXE)
|
||||||
|
if(CLANG_TIDY_FIX)
|
||||||
|
list(APPEND _args "-fix")
|
||||||
|
endif()
|
||||||
|
add_custom_target(clang-tidy-check
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
COMMAND ${CLANG_TIDY_EXE} -extra-arg="-Wno-unknown-warning-option" -p ${CMAKE_BINARY_DIR} ${_sources})
|
||||||
|
add_dependencies(clang-tidy-check ${_target})
|
||||||
|
else()
|
||||||
|
message(WARNING "ClangTidy is not found")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
@ -31,6 +31,7 @@ include(CMLibCommonTargetProperties)
|
|||||||
include(CMLibCommonLibraryTarget)
|
include(CMLibCommonLibraryTarget)
|
||||||
include(CMLibBuildTypes)
|
include(CMLibBuildTypes)
|
||||||
include(CMLibCodeAnalysisPvsStudio)
|
include(CMLibCodeAnalysisPvsStudio)
|
||||||
|
include(CMLibClangTidy)
|
||||||
include(cotire)
|
include(cotire)
|
||||||
|
|
||||||
include(CMLibBreathe)
|
include(CMLibBreathe)
|
||||||
|
Loading…
Reference in New Issue
Block a user