Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>CMake Tools → clangd SyncNew to Visual Studio Code? Get it now.
CMake Tools → clangd Sync

CMake Tools → clangd Sync

PolyCam

|
1 install
| (0) | Free
Automatically syncs clangd's compilation database with the active CMake Tools configure preset
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

CMake Tools → clangd Sync

Bridges CMake Tools and clangd in VS Code by keeping clangd's compilation database in sync with the active CMake configure preset.

The problem

CMake Tools and clangd don't talk to each other. When you switch CMake configure presets (e.g. from desktop-debug to desktop-release), clangd keeps using the old compile_commands.json — leading to stale diagnostics, wrong include paths, and missing symbols.

The usual workarounds (manually editing .clangd, symlinking compile_commands.json, restarting clangd) are tedious and error-prone.

What this extension does

When you switch configure presets in CMake Tools, this extension automatically:

  1. Updates the CompilationDatabase path in your .clangd config file to point at the new build directory
  2. Restarts clangd so it picks up the new compilation database

That's it. No UI, no commands, no settings. It activates when your workspace contains a CMakePresets.json or CMakeLists.txt and runs silently in the background.

How it works

  • Listens to CMake Tools' onSelectedConfigurationChanged and onActiveProjectChanged events via the CMake Tools API
  • Calls getBuildDirectory() to resolve the current build directory
  • Makes a targeted edit to the .clangd file in your workspace root — only the CompilationDatabase line is changed, all other clangd configuration is preserved
  • Skips the write and clangd restart entirely if the path hasn't changed
  • Uses a relative path when the build directory is inside the workspace

Example

After switching to the desktop-release preset, your .clangd file will contain:

CompileFlags:
  CompilationDatabase: out/cmake-desktop-release

If you already have other directives in .clangd (e.g. Add, Remove, Compiler), they are left untouched.

Requirements

  • CMake Tools
  • clangd

Both are declared as extension dependencies and will be installed automatically if missing.

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft