I'm trying to write a tool using libTooling. I got it set up so that it compiles with the example from the LLVM Documentation. However C/C++ Intellisense seems to not work with CMake projects.
My tool is located in:
<project>/clang-tools-extra/mytool
Now the C/C++ extension tries to read the compile_config.json and tells me <project>/build/compile_config.json
could not be found, using includePath
from c_cpp_properties.json
instead.
I tried adding the include paths manually in my workspace settings:
{
"C_Cpp.default.includePath": [
"../../",
"../../clang/Frontend/",
"../../clang/Tooling/",
"../../llvm/Support/"
],
"C_Cpp.default.browse.path": [
"../.."
]
}
Or in a file c_cpp_properties.json
. But it still searches for the includes in the wrong place. E.g. the include:
#include "llvm/Support/CommandLine.h"
It tries to find in <project>/llvm/include/llvm/Support/CommandLine.h
. So apparently it reads something from command_config.json even though it says it can't find it (while it is there), but the wrong thing. It shouldn't add llvm/include
at all.
You need to install cmake-tool extension (ms-vscode.cmake-tools) and add following configuration to your c_cpp_properties.json
:
{
"configurations": [
{
"compileCommands": "${workspaceFolder}/_build/compile_commands.json",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
It is working for me
For VSCode 1.63+ (2022 or later):
1. Install the CMake Tools extension (ms-vscode.cmake-tools
).
2. Put this in .vscode/c_cpp_properties.json
:
{
"configurations": [
{
"name": "CMake",
"compileCommands": "${config:cmake.buildDirectory}/compile_commands.json",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With