Getting compile_commands.json from CMake#
CMake provides the CMAKE_EXPORT_COMPILE_COMMANDS flag to export the compile commands. The flag can be added to your CMakeLists.txt script:
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
or added to your build command:
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .
Either of these approaches will create the file compile_commands.json in your build directory.