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:
2026-06-19 10:21:10 +02:00
parent e38df6cf88
commit ba545ba64a
4 changed files with 19 additions and 0 deletions

5
.clangd Normal file
View File

@@ -0,0 +1,5 @@
# The Visual Studio CMake generator (build/) does not emit compile_commands.json,
# so the Ninja config in build-clangd/ provides it. Regenerate after changing
# sources or include dirs with: gen-compile-commands.bat
CompileFlags:
CompilationDatabase: build-clangd