Mat*_*szL 5 c++ cmake clang-tidy
我有使用 CMake 的大型项目。我想clang_tidy-8
使用以下代码添加支持:
set(BORG_CLANG_TIDY OFF CACHE STRING "If enabled, clang-tidy will be used. If set to 'fix', fixes will be done on source")
set_property(CACHE BORG_CLANG_TIDY PROPERTY STRINGS ON OFF fix)
if(BORG_CLANG_TIDY)
if (BORG_CLANG_TIDY STREQUAL "fix")
set(maybe_fix -fix)
endif()
set(CMAKE_CXX_CLANG_TIDY clang-tidy-8 -extra-arg=-Wno-unknown-warning-option -format-style=file ${maybe_fix} )
endif()
Run Code Online (Sandbox Code Playgroud)
我将适当的.clang-tidy
放在项目的根目录中(正确 = 带有所需的检查)。但是,有些目录我不希望 clang tidy 检查/修复(3rdparty 和遗留代码,因为它很脆弱而无法修改)。所以我尝试将空.clang-tidy
文件放在这些目录中(empty = with -checks=-*
)。这不起作用,因为Error: no checks enabled.
我希望找到一些假货,-checks=-*,hello-world-do-nothing-check
但没有任何表现。
还有其他方法可以禁用选定子目录 (/subtrees) 中的检查吗?这些目录是静态的,如果需要,可以在 CMake 中进行硬编码。
如果你想要一个什么都不做的虚拟检查,那么至少有一个很容易通过其选项禁用:misc-definitions-in-headers
该HeaderFileExtensions
选项可用于使检查仅适用于某些头文件后缀。如果您将其设置为不存在的行“x”,那么您还有其他hello-world-do-nothing-check
选择。您的 clang-tidy 文件将如下所示:
Checks: '-*,misc-definitions-in-headers'
CheckOptions:
- { key: HeaderFileExtensions, value: "x" }
Run Code Online (Sandbox Code Playgroud)
您还可以检查/sf/answers/3942382671/并尝试调整line-filter
以过滤掉某些目录中的文件。
归档时间: |
|
查看次数: |
2723 次 |
最近记录: |