question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Instead of put a `compile_commands.json` at source root

See original GitHub issue

For cmake projects, compile_commands.json has to be copied/linked to the source root directory now. Instead of this, can a property of vscode workspace be set, so that vscode-clangd knows where is compile_commands.json?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
HighCommander4commented, Aug 14, 2021

Yes, this can be done today by adding the following to <project>/.vscode/settings.json:

{
  "clangd.arguments": [
    "--compile-commands-dir=<path_to_directory_containing_compile_commands.json>"
  ]
}

Another way is to use clangd’s own config file (see the CompilationDatabase key in the docs).

1reaction
HighCommander4commented, Aug 14, 2021

Another way is to use clangd’s own config file (see the CompilationDatabase key in the docs).

It doesn’t seem workspace specific, does it?

It can be. From the docs:

  • project configuration: a file named .clangd in the source tree. (clangd searches in all parent directories of the active file).
Read more comments on GitHub >

github_iconTop Results From Across the Web

Document that compile_commands.json is searched for in ...
json for my project and put it at the project root but the file was ignored because an underlying build folder "masked" the...
Read more >
cmake - Copy compile_commands.json to project root folder
json is built in the root of the binary directory, and I want to copy it to root of source directory after running...
Read more >
Compilation database | CLion Documentation - JetBrains
A compilation database lets CLion detect project files and extract ... The compile_commands.json file will be put into the build directory.
Read more >
C language server for Neovim without compile_commands ...
Generation of a compile_commands.json file is not so much effort if you are using cmake as a build system. Just append -DCMAKE_EXPORT_COMPILE_COMMANDS=1 and...
Read more >
C++ Editor/IDE Setup - fuchsia Git repositories
A Compilation Database file can be generated using fx compdb . This will create/update the file compile_commands.json in the fuchsia root directory. When...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found