Skip to content
Snippets Groups Projects
Commit 4b671555 authored by Lars Bilke's avatar Lars Bilke Committed by Dmitri Naumov
Browse files

[cmake] Introduce run-clang-tidy target.

As suggested in Prof. CMake, Craig Scott.
parent 195ad2bd
No related branches found
No related tags found
No related merge requests found
---
Checks: '-*,clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-pro-type-member-init, *explicit-conversions*, google-explicit-constructor, google-readability-braces-around-statements, modernize-loop-convert, modernize-use-default-member-init, modernize-use-emplace, modernize-use-using, readability-braces-around-statements, readability-else-after-return, readability-named-parameter, *readability-namespace-comments, *readability-inconsistent-*, readability-redundant-member-init, readability-simplify-boolean-expr, readability-string-compare'
Checks: >
-*
,clang-diagnostic-*,
clang-analyzer-*,
cppcoreguidelines-pro-type-member-init,
*explicit-conversions*,
google-explicit-constructor,
google-readability-braces-around-statements,
modernize-loop-convert,
modernize-use-default-member-init,
modernize-use-emplace,
modernize-use-using,
readability-braces-around-statements,
readability-else-after-return,
readability-named-parameter,
*readability-namespace-comments,
*readability-inconsistent-*,
readability-redundant-member-init,
readability-simplify-boolean-expr,
readability-string-compare
WarningsAsErrors: ''
HeaderFilterRegex: '.*'
WarningsAsErrors: ""
HeaderFilterRegex: ".*"
AnalyzeTemporaryDtors: false
FormatStyle: file
FormatStyle: file
CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: hicpp-braces-around-statements.ShortStatementLines
value: '1'
- key: readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-braces-around-statements.ShortStatementLines
value: "1"
- key: hicpp-braces-around-statements.ShortStatementLines
value: "1"
- key: readability-braces-around-statements.ShortStatementLines
value: "1"
......@@ -85,6 +85,7 @@ include(DocumentationSetup)
include(test/Test)
include(Coverage)
include(CppCheck)
include(ClangTidy)
# ---- More Options ----
......
......@@ -6,18 +6,12 @@ clang tidy:
needs: []
variables:
BUILD_DIR: "./build-tidy"
CMAKE_ARGS: "-DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DCMAKE_CXX_CLANG_TIDY=clang-tidy;--extra-arg=-Wno-error=unknown-warning-option"
script:
- rm -rf $BUILD_DIR
- mkdir -p $BUILD_DIR
- cd $BUILD_DIR
- >
cmake .. -G Ninja
$CMAKE_ARGS
-DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
- cmake --build . > >(tee make.txt)
artifacts:
# No report yet: https://gitlab.com/gitlab-org/gitlab/-/issues/3985
paths:
- $BUILD_DIR/make.txt
expire_in: 1 week
- cmake --build . --target run-clang-tidy
if(NOT PROJECT_IS_TOP_LEVEL)
return()
endif()
find_program(CLANG_TIDY_EXECUTABLE clang-tidy)
find_program(RUN_CLANG_TIDY_EXECUTABLE run-clang-tidy)
if(CLANG_TIDY_EXECUTABLE AND RUN_CLANG_TIDY_EXECUTABLE)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
add_custom_target(
run-clang-tidy
COMMAND ${RUN_CLANG_TIDY_EXECUTABLE} -clang-tidy-binary
${CLANG_TIDY_EXECUTABLE} -p ${CMAKE_BINARY_DIR}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
USES_TERMINAL
)
# Disable clang-tidy in cpm build dirs, hack: Disable all checks, but one
# check has to be enabled.
file(WRITE ${PROJECT_BINARY_DIR}/_deps/.clang-tidy
"Checks: '-*,boost-use-to-string'"
)
endif()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment