[SOLVED] WSL Remote Development with CLion and Qt5 source code opened from compile_commands.json doesn't recognize headers

To build Qt from source configure program is started. It generates project configuration files - for Qt5 Makefile.

I would like to edit Qt Source code and add changes with help of CLion suggestions, code quality verification and so on.

with VS Code It's enough to add to .vscode/c_cpp_properties.json

    "configurations": [
        {
            "name": "Linux WSL",
            "includePath": [
                "${workspaceFolder}/**",
                "${workspaceFolder}/../builds/install_latest/include/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c17",
            "intelliSenseMode": "linux-gcc-x64"
        }

and I've got support of suggestion and jumping to class/functions/macros definitions/declarations.

How to achieve similar results with CLion?

0
2 comments

bear is a tool which monitor make execution and generate from it compile_commmand.json.

This can be used when opening project and helps with code completion. Yet, there're moments when I follow CTRL-LBM (of F10) and opened HEADERS are highlighted as unprocessed and/or signaling errors. No code completions, not further navigation.

So it's not solving all my needs.

0

Inspired by this StackOverflow post.
CLion uses clangd. Headers aren't present in compile_commands.json. And clangd doesn't know what to do with them.
Placing file .clangd in root Qt5 folder with content

If:
  PathMatch: .*\.(h)$

CompileFlags:
  Add:
    - "-xc++"
    #some other flags copied from compile_commands.json

After restart - headers are recognized, parsed and navigable.

0

Please sign in to leave a comment.