On 10/17/24 1:27 PM, Hugo Melder via Qt-creator wrote:
I cannot get QTC to pick up the compile_commands.json file generated by CMake.
Here some things I’ve tried out:
1. Create a .clangd configuration file to hard-code the compilation database
location
2. Move compile_commands.json into the top-level of the project
3. Verify that clangd is configured with the correct workspace folder (Language
Client Inspector
OS Info:
WindowsBuildLabEx :
22621.1.arm64fre.ni_release.220506-1250
OsName : Microsoft Windows 11
Pro
OsVersion : 10.0.22631
CsSystemType : ARM64-based PC
QtCreatorVersion : 14.0.1 (Enterprise)
Steps to reproduce:
1. Create a new Qt Quick Application.
2. Click on "Projects" on Sidebar
3. Add "CMAKE_EXPORT_COMPILE_COMMANDS" to initial configuration
4. Reconfigure the project
The build directory now contains a compile_commands.json file.
We can now edit compile_commands.json to test, if it is really picked up. Find
the entry for main.cpp and add '-DFOOBAR' to the command.
QTC greys out an "#ifdef FOOBAR" block, despite FOOBAR being defined in the
build command for main.cpp.
Does QTC support compilation databases?
Note that this question is out of scope for Qt Creator. We generate our
own compilation database file with the necessary tweaks for clang. If
you want to trick clangd in using a different one, you are on your own.
However, from your description it sounds like you expect clangd to pick
up live updates to the json file, which will not work; you have to
restart it. Otherwise I don't know what might be going wrong.
Christian
--
Qt-creator mailing list
Qt-creator@qt-project.org
https://lists.qt-project.org/listinfo/qt-creator