How to integrate clang-tidy with CMake (<LANG> _CLANG_TIDY) and MSVC?
How to pass a flag clang
, for example, -fms-compatibility-version
with CMake ? On the CLI, this is easy: <LANG>_CLANG_TIDY
<LANG>_CLANG_TIDY
clang-tidy main.cpp -- -fms-compatibility-version=19.10
But with CMake, this does not work as expected:
-DCMAKE_CXX_CLANG_TIDY="clang-tidy;-checks=-*,readability-*;--;-fms-compatibility-version=19.10"
The flag is required to work clang
with modern versions of MSVC.
If this is not possible; Is there any other way to integrate CMake + MSVC + clang-tidy (besides creating a custom build target)?
+6
2 answers
In Visual Studio 2017 15.6.3 (be sure to update) here.
I had to put
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-format-style='file'")
# CMake is buggy. It gives the -std:c++14 instead of /std:c++14
# set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++14")
In mine CMakeLists.txt
. I do not know whether to do it correctly, but I can compile AND detect errors. It seems to me a victory.
0