I just want to have autocompletion for glib-2.0 in my IDE!

What host system are you using / which generator / compiler?

With make or ninja it is possible to generate a compile_commands.json, when generating with cmake pass -DCMAKE_EXPORT_COMPILE_COMMANDS=ON. Or to make your life easier, use CMakePresets.
This will generate a compile_commands.json file in your build folder containing the compiler command for each source file.

A lot of tools / plugins understand this file.

For instance with VS Code:

  • You might wanna use the extension “vs-vscode.cmake-tools”, which is able to copy the compile_commands.json to your root folder if you set the settings "cmake.copyCompileCommands": "${workspaceFolder}/compile_commands.json". This extension offers a lot more and I personally not super convienced of using it as I prefer the command line. But the automatic copy of the compile commands to the root folder (where most tools expect it by default) is quite handy
  • Install the extension “llvm-vs-code-extensions.vscode-clangd” instead of the C++ Microsoft extension. It will pick up the compile_commands.json in your root folder by default and everything should work without any issues. Maybe the Microsoft C++ extension works as well, but personally I really like clangd. If the compile_commmands.json is still in your build folder, you can also change the settings of the clangd extension to pick it up there. Although you need to lookup what exactly the command line argument is, I forgot.