I'm trying to write a CLion plugin that invokes a custom libtooling-based tool, which needs a compilation database. Since CLion uses clangd internally I initially assumed that it always adds the -DCMAKE_EXPORT_COMPILE_COMMANDS=ON CMake command-line argument when configuring a CMake project, but to my surprise I found that it does not, so the compile_commands.json file is not in the build directory unless the user explicitly requested the compilation database generation themselves.
Since I'd like my plugin to work regardless of the configuration options set by the user for their CMake project I tried to locate the compile_commands.json file used by clangd but have been unable to find it. Is there any way to access it? Or is there another way to access the compiler flags for a single source file so that I can at least generate a compilation database manually in my plugin?