Tooling: generate compile_commands.json for clangd
The Visual Studio CMake generator does not emit compile_commands.json, so clangd had no include paths or flags and reported hundreds of false errors. Add a parallel Ninja config (build-clangd/) that produces the database: - CMAKE_EXPORT_COMPILE_COMMANDS ON (honored by Ninja, ignored by VS) - gen-compile-commands.bat configures build-clangd/ under vcvars64 - .clangd points clangd's CompilationDatabase at build-clangd/ - ignore /build-clangd clangd's clang-cl driver auto-resolves the MSVC/Windows SDK system includes, so the cl.exe-based database is sufficient. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
8
gen-compile-commands.bat
Normal file
8
gen-compile-commands.bat
Normal file
@@ -0,0 +1,8 @@
|
||||
@echo off
|
||||
REM Generates compile_commands.json for clangd via a Ninja build (the Visual
|
||||
REM Studio generator can't emit one). Run from the repo root.
|
||||
setlocal
|
||||
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" || exit /b 1
|
||||
set "NINJA=C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja\ninja.exe"
|
||||
cmake -S . -B build-clangd -G Ninja -DCMAKE_MAKE_PROGRAM="%NINJA%" -DCMAKE_BUILD_TYPE=Debug -DCOOP_BUILD_HOOK=ON || exit /b 1
|
||||
echo COMPILE_COMMANDS_DONE
|
||||
Reference in New Issue
Block a user