clangd icon indicating copy to clipboard operation
clangd copied to clipboard

support different names for compiled_commands.json

Open LoreMoretti opened this issue 1 year ago • 2 comments

For ExternalProject-based CMake superbuild, one might have a lot of compile_commands.json files placed in different directories, which might not respect the project set up of clangd.

In VScode one could use CMakeTools extension to merge all these compile_commands.json files into a unique one by setting the following option:

"cmake.mergedCompileCommands": "${workspaceFolder}/build/merged_compile_commands.json"

In this case for example, the merged file is called merged_compile_commands.json to distinguish it from the other compile_commands.json files.

Though, this new file is not found by clangd when setting the following option:

"clangd.arguments": [
        "--compile-commands-dir=${workspaceFolder}/build/"
    ],

It would be helpful to have an option like --compile-commands-file that one could set as follows:

"clangd.arguments": [
        "--compile-commands-file=${workspaceFolder}/build/merged_compile_commands.json"
    ],

LoreMoretti avatar Feb 14 '24 11:02 LoreMoretti

I noticed your use of ${workspaceFolder} in the clangd.arguments. Does that currently work for you (minus the "merged" part)? I ask because using named workspaces in there does not. (eg. replace yours with ${workspaceFolder:<name>}/<...>

vindicatorr avatar Mar 10 '24 03:03 vindicatorr

I noticed your use of ${workspaceFolder} in the clangd.arguments. Does that currently work for you (minus the "merged" part)? I ask because using named workspaces in there does not. (eg. replace yours with ${workspaceFolder:<name>}/<...>

${workspaceFolder} works because its substitution has been manually implemented in vscode-clangd.

There is no comparable implementation of ${workspaceFolder:<name>}, though I imagine a patch to add that would be welcome. (Even better would be to call into some sort of VSCode API to automatically handle all the variable substitutions that VSCode itself handles, if such a thing exists.)

HighCommander4 avatar Mar 10 '24 06:03 HighCommander4