I'm trying to integrate clang-tidy with cmake, but there are some files that belong to a particular target which I would like to ignore.
Is there any way to make clang-tidy to ignore files under certain directory or whose name matches a certain pattern?
3.27 introduces the SKIP_LINTING file property to handle this nicely.
add_executable(MyApp main.cpp things.cpp generatedBindings.cpp)
set_source_files_properties(generatedBindings.cpp PROPERTIES
SKIP_LINTING ON
)
Link to official CMake documentation: https://cmake.org/cmake/help/latest/prop_sf/SKIP_LINTING.html
You could also just add comments to your code.
https://clang.llvm.org/extra/clang-tidy/#suppressing-undesired-diagnostics
// NOLINTBEGIN
...
// NOLINTEND
In the directory you want to ignore, create a .clang-tidy config file, that disables all checks with:
Checks: '-*'
If there is no way of keeping such a file in a repository, the file can be easily generated before running clang-tidy with echo "Checks: '-*'" > $folder2ignore/.clang-tidy. (This will even overwrite existing .clang-tidy, effectively disabling clang-tidy for the folder)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With