CLion IDE - how to configure?

How do you configure CLion IDE so that “Go to Definition” and similar actions work?

It can’t detect the location of included header symbols (which I can’t figure out myself either).

For example applications/subghz/subghz_setting.c contains:

#include "furi_hal_subghz_configs.h"

But that file lives in firmware/targets/f7/furi_hal/furi_hal_subghz_configs.h. How come these header files are found by the Scons build tool? IDE & I myself can’t make the connection.

It seemed a lot easier to manage in CLion with the Makefile. I’ve been trying to implement some suggestions I read in CPP-1102, the CLion ticket about scons support. Namely, adding scons-compiledb support… and the steps needed to get there were a bit funky:

  1. First, run ./fbt once to download/unpack the tool chain
  2. Run . ./scripts/toolchain/ to set all env vars needed to address the toolchain’s python binary
  3. Install scons-compiledb with python3 -m pip install scons-compiledb (I had trouble using the pip binary, but better luck invoking it by module. NOTE: if you get a warning about it installing to user directory, something’s gone wrong — it should install to the toolchain’s site-packages)
  4. Modify the root SConstruct, adding an import scons_compiledb to the top, and altering the DefaultEnvironment(tools=[]) call to:
    env = DefaultEnvironment(tools=[])
  5. Now, when you run ./fbt, it should generate a build/latest/compile_commands.json file
  6. Copy or symlink this file to the root flipperzero-firmware directory, or CLion may have some issues with the paths.
  7. Finally, hit File > Open, navigate to the compile_commands.json file, hit Open, and when the dialog appears, click “Open as Project”

Buuuuut even with all that, I still found it unable to resolve furi.h =/