cmake: Add support for running clang-tidy
Adds supports for running clang-tidy from within CMake, if the Clang toolset was found. This feature is experimental, but should work on many compilers, as it relies on generated compile_commands.json which are fully generated by the clang subproject. Using clang-tidy we can find hidden bugs that other static analyzers do not detect, or compilers don't even bother throwing an error for.
This commit is contained in:
parent
04ac0a640f
commit
92fc2b3ccb
|
@ -0,0 +1,35 @@
|
||||||
|
Checks: '-*,clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,portability-*,readability-*,performance-*'
|
||||||
|
WarningsAsErrors: ''
|
||||||
|
HeaderFilterRegex: ''
|
||||||
|
AnalyzeTemporaryDtors: false
|
||||||
|
FormatStyle: none
|
||||||
|
User: Xaymar
|
||||||
|
CheckOptions:
|
||||||
|
- key: cert-dcl16-c.NewSuffixes
|
||||||
|
value: 'L;LL;LU;LLU'
|
||||||
|
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
|
||||||
|
value: '0'
|
||||||
|
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
|
||||||
|
value: '1'
|
||||||
|
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
|
||||||
|
value: '1'
|
||||||
|
- key: google-readability-braces-around-statements.ShortStatementLines
|
||||||
|
value: '1'
|
||||||
|
- key: google-readability-function-size.StatementThreshold
|
||||||
|
value: '800'
|
||||||
|
- key: google-readability-namespace-comments.ShortNamespaceLines
|
||||||
|
value: '10'
|
||||||
|
- key: google-readability-namespace-comments.SpacesBeforeComments
|
||||||
|
value: '2'
|
||||||
|
- key: modernize-loop-convert.MaxCopySize
|
||||||
|
value: '16'
|
||||||
|
- key: modernize-loop-convert.MinConfidence
|
||||||
|
value: reasonable
|
||||||
|
- key: modernize-loop-convert.NamingStyle
|
||||||
|
value: CamelCase
|
||||||
|
- key: modernize-pass-by-value.IncludeStyle
|
||||||
|
value: llvm
|
||||||
|
- key: modernize-replace-auto-ptr.IncludeStyle
|
||||||
|
value: llvm
|
||||||
|
- key: modernize-use-nullptr.NullMacros
|
||||||
|
value: 'NULL'
|
|
@ -909,6 +909,7 @@ set_target_properties(
|
||||||
${PROJECT_NAME}
|
${PROJECT_NAME}
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
CXX_STANDARD ${_CXX_STANDARD}
|
CXX_STANDARD ${_CXX_STANDARD}
|
||||||
|
CXX_STANDARD_REQUIRED ON
|
||||||
CXX_EXTENSIONS ${_CXX_EXTENSIONS}
|
CXX_EXTENSIONS ${_CXX_EXTENSIONS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -947,8 +948,15 @@ if(HAVE_OBS_FRONTEND)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Clang-Format
|
# Clang Tools
|
||||||
if(HAVE_CLANG)
|
if(HAVE_CLANG)
|
||||||
|
generate_compile_commands_json(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
)
|
||||||
|
clang_tidy(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
VERSION 9.0.0
|
||||||
|
)
|
||||||
clang_format(
|
clang_format(
|
||||||
TARGETS ${PROJECT_NAME}
|
TARGETS ${PROJECT_NAME}
|
||||||
DEPENDENCY
|
DEPENDENCY
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 9166c8a575a2a6bf4c029cfefc84d4bbe62befc5
|
Subproject commit 58da85a255b468ad170603e9528d63cf0d73bd27
|
Loading…
Reference in New Issue