notes/config/clangd/clangd.md

670 B
Raw Permalink Blame History

Clangd 配置

项目的根目录中存在 .clangd 文件,同时要生成 compile_commands.json 文件。

cmake

方案一

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

方案二

mkdir build
cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..

Makefile

Makefile 本身不能直接生成 compile_commands.json 文件。不过可以使用一些工具来生成这个文件例如Bear和CompileDB。

bear

运行Makefile并生成 compile_commands.json

bear make

CompileDB

安装:

pip install compiledb

运行Makefile并生成 compile_commands.json

compiledb make