2024-01-21 10:33 PM
I work in a workspace but I use vim with clangd for editing my code. I am wondering if it is possible to create a compile_commands.json file and if so how.
If the IDE uses cmake under the hood then it should be rather straightforward but I cannot understand how to proceed.
see e.g. this:
https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html
Solved! Go to Solution.
2024-01-23 10:22 AM
I found an answer by myself, and it is YES.
For those who may need it.
Install a tool that can create a compile_commands.json from a makefile like compiledb or bear (in the following I will use compiledb)
1) Go on Project-> Properties and change add the folder where compiledb is installed in PATH as shown below.
2) Go to Project -> Build Targets -> Create... Uncheck all the options and add the custom command you need for creating the compile_commands.json file in the Build commands.
3) Select the newly created target on the left hand side of CubeIDE, right click and select Build Target.
4) Once your compile_commands.json is created, you have to move it in the upper folder (root of your project).
You may have some error related to cyclomatic-complexity, but to solve this is enough to open the compile_commands.json file and remove all the -fcyclomatic-complexity entries.
OBS! I have just discovered this method, so take it with a grain of salt.
2024-01-23 10:22 AM
I found an answer by myself, and it is YES.
For those who may need it.
Install a tool that can create a compile_commands.json from a makefile like compiledb or bear (in the following I will use compiledb)
1) Go on Project-> Properties and change add the folder where compiledb is installed in PATH as shown below.
2) Go to Project -> Build Targets -> Create... Uncheck all the options and add the custom command you need for creating the compile_commands.json file in the Build commands.
3) Select the newly created target on the left hand side of CubeIDE, right click and select Build Target.
4) Once your compile_commands.json is created, you have to move it in the upper folder (root of your project).
You may have some error related to cyclomatic-complexity, but to solve this is enough to open the compile_commands.json file and remove all the -fcyclomatic-complexity entries.
OBS! I have just discovered this method, so take it with a grain of salt.
2024-08-14 03:14 AM
Thanks for this solution.
I'm trying to set it up but I got an error: make: *** No rule to make target 'compile_command'. Stop.
Is there anything to configure with the makefile?
2024-08-15 12:58 AM
It was long ago, but looking at the screenshots I don't think you need to change the Makefile manually.
Have you done the step 2) correctly?
2024-09-02 01:20 AM
Yes I did step 2 as you described.