Can I use .clang-tidy file with CMakeList.txt?

Viewed 2142

I have linked clang for my cpp project with CMakeLists.txt with

set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=google-*,cppcoreguidelines-*")

Since, I would like to move all the clang config to a file, I googled little bit and found that there is .clang-tidy file for this usage.

However, I wasn't able to configure CMakeList.txt to actually use this file.

Can anyone tell me how I should change that line in CMakeList.txt to link it with .clang-tidy file?

1 Answers

If you have .clang-tidy in project root, all you need to do is specify clang-tidy executable, e.g.

set(CMAKE_CXX_CLANG_TIDY "clang-tidy")

and clang-tidy will implicitly use .clang-tidy.

Related