Clang-tidy passing incorrect arguments on windows?

I’m trying to use clang-tidy on windows using clang-cl.

But I’m getting this error while trying to run clang-tidy:

>------ Build All started: Project: PitoEngine, Configuration: Debug_x64 ------
  [1/14] Building CXX object CMakeFiles\engine.dir\CMakeFiles\engine.dir\cmake_pch.cxx.obj
  FAILED: CMakeFiles/engine.dir/CMakeFiles/engine.dir/cmake_pch.cxx.obj 
  "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E __run_co_compile --tidy="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/bin/clang-tidy.exe" --source=CMakeFiles\engine.dir\cmake_pch.cxx -- C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\Llvm\bin\clang-cl.exe  /nologo -TP -DNOMINMAX -DWIN32_LEAN_AND_MEAN -I..\..\src -Idep\graphics_system_dx12 -I..\..\dep\graphics_system_dx12\src\inc -I..\_deps\gsl-src\include -m64 -fdiagnostics-absolute-paths  /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0 /Od /RTC1 -MTd   -Werror -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -std:c++17 /YcD:/Github/PitoEngine/build/Debug_x64/CMakeFiles/engine.dir/cmake_pch.hxx /FpD:/Github/PitoEngine/build/Debug_x64/CMakeFiles/engine.dir/CMakeFiles/engine.dir/cmake_pch.cxx.pch /FID:/Github/PitoEngine/build/Debug_x64/CMakeFiles/engine.dir/cmake_pch.hxx /showIncludes /FoCMakeFiles\engine.dir\CMakeFiles\engine.dir\cmake_pch.cxx.obj /FdCMakeFiles\engine.dir\ -c CMakeFiles\engine.dir\cmake_pch.cxx
D:\Github\PitoEngine\build\Debug_x64\EXEC : error : unknown argument: '-std:c++17' [clang-diagnostic-error]

I believe the basic problem is that clang tidy doesn’t accept this command line syntax. Instead it uses -std=c++17.

This normally isn’t a problem until you use clang on windows.

1 Like

Please file an issue. Looks like another clang-cl kind of exclusion will be necessary, though I’m not too familiar with the codepaths involved here.

I’ve filed an issue:
https://gitlab.kitware.com/cmake/cmake/-/issues/20737

@brad.king pointed out correctly that this issue was fixed in cmake 3.17

I’ll mark this issue as solved.