mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 19:10:24 +00:00
Add compile_commands.json documentation for C/C++ (#22639)
Added documentation explaining that clangd requires `compile_commands.json` for proper functionality in both C and C++ projects. Includes instructions for generating the file using CMake. This is related to https://github.com/zed-industries/zed/discussions/6480 Release Notes: - N/A --------- Co-authored-by: Peter Tripp <peter@zed.dev>
This commit is contained in:
parent
2856d0a661
commit
bbce1c19d1
2 changed files with 28 additions and 0 deletions
|
@ -49,3 +49,17 @@ You can trigger formatting via {#kb editor::Format} or the `editor: format` acti
|
||||||
```
|
```
|
||||||
|
|
||||||
See [Clang-Format Style Options](https://clang.llvm.org/docs/ClangFormatStyleOptions.html) for a complete list of options.
|
See [Clang-Format Style Options](https://clang.llvm.org/docs/ClangFormatStyleOptions.html) for a complete list of options.
|
||||||
|
|
||||||
|
## Compile Commands
|
||||||
|
|
||||||
|
For some projects Clangd requires a `compile_commands.json` file to properly analyze your project. This file contains the compilation database that tells clangd how your project should be built.
|
||||||
|
|
||||||
|
### CMake Compile Commands
|
||||||
|
|
||||||
|
With CMake, you can generate `compile_commands.json` automatically by adding the following line to your `CMakeLists.txt`:
|
||||||
|
|
||||||
|
```cmake
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
```
|
||||||
|
|
||||||
|
After building your project, CMake will generate the `compile_commands.json` file in the build directory and clangd will automatically pick it up.
|
||||||
|
|
|
@ -98,3 +98,17 @@ Diagnostics:
|
||||||
```
|
```
|
||||||
|
|
||||||
For more advanced usage of clangd configuration file, take a look into their [official page](https://clangd.llvm.org/config.html).
|
For more advanced usage of clangd configuration file, take a look into their [official page](https://clangd.llvm.org/config.html).
|
||||||
|
|
||||||
|
## Compile Commands
|
||||||
|
|
||||||
|
For some projects Clangd requires a `compile_commands.json` file to properly analyze your project. This file contains the compilation database that tells clangd how your project should be built.
|
||||||
|
|
||||||
|
### CMake Compile Commands
|
||||||
|
|
||||||
|
With CMake, you can generate `compile_commands.json` automatically by adding the following line to your `CMakeLists.txt`:
|
||||||
|
|
||||||
|
```cmake
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
```
|
||||||
|
|
||||||
|
After building your project, CMake will generate the `compile_commands.json` file in the build directory and clangd will automatically pick it up.
|
||||||
|
|
Loading…
Reference in a new issue