-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Environment
- OS and Version: Arch Linux (rolling @ 2025-02-28)
- VS Code Version: 1.98.0
- C/C++ Extension Version: 1.24.1
Bug Summary and Steps to Reproduce
I have a C++ project (KiCad) which I'm trying to setup with Code.
My workspace directory is /home/user/build/kicad/, where build is a symlink to /storage/data/build.
I'm generating a compile_commands.json file using cmake in ./build.
The issue is that Code incorrectly thinks any source file cannot be found in compile_commands.json.
This is a snippet from the file:
[ // ...
{
"directory": "/home/user/build/kicad/build",
"command": "/usr/bin/c++ <SNIP>",
"file": "/home/user/build/kicad/build/api/cpp/api/common/envelope.pb.cc",
"output": "api/CMakeFiles/kiapi.dir/cpp/api/common/envelope.pb.cc.o"
},
//...
]When hand-editing the file to replace the absolute paths with symlink-resolved absolute paths things start working:
[ // ...
{
"directory": "/storage/data/build/kicad/build",
"command": "/usr/bin/c++ <SNIP>",
"file": "/storage/data/build/kicad/build/api/cpp/api/common/envelope.pb.cc",
"output": "api/CMakeFiles/kiapi.dir/cpp/api/common/envelope.pb.cc.o"
},
//...
]From what I understand, cmake is actually correct here, as -afaik- paths need to be relative to the source dir or absolute, but don't have to resolve symlinks.
Would it be possible to fix this?
Probably the most elegant / secure way would be to resolve the paths read from compile_commands.json, but it may not be the most performant option.
Configuration and Logs
{
"configurations": [
{
"name": "Linux",
"intelliSenseMode": "linux-gcc-x64",
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"includePath": [
"${workspaceFolder}",
"${workspaceFolder}/include"
],
"compilerPath": "/usr/bin/g++",
"cStandard": "c17",
"cppStandard": "c++20",
"defines": [
],
"browse": {
"path": [
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true
}
}
],
"version": 4
}Other Extensions
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status