Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate compile_commands.json #76

Closed
bergercookie opened this issue Apr 5, 2020 · 3 comments
Closed

Generate compile_commands.json #76

bergercookie opened this issue Apr 5, 2020 · 3 comments
Labels
duplicate This issue or pull request already exists

Comments

@bergercookie
Copy link

Hi there,

Is there a way to generate a compile_commands.json file for the ROS workspace that colcon is used for? I've tried passing --cmake-args=-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON but that seems to only generate compile_commands for very few of the packages in my workspace as well as lots of warnings like the following:

Starting >>> gtest_vendor
--- stderr: gtest_vendor
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_EXPORT_COMPILE_COMMANDS


---

I've also tried generating the compile_commands.json using Bear but that resulted in an empty compile_commands file.

Any pointers?

@dirk-thomas dirk-thomas added the duplicate This issue or pull request already exists label Apr 5, 2020
@dirk-thomas
Copy link
Member

dirk-thomas commented Apr 5, 2020

Is there a way to generate a compile_commands.json file for the ROS workspace

Yes, the feature was implemented in #69 and that change is available as of colcon-cmake version 0.2.20 as referenced in that ticket. So you likely have an older version.

lots of warnings like the following:

You might want to try the CMake option --no-warn-unused-cli (see https://cmake.org/cmake/help/latest/manual/cmake.1.html).

Assuming that using the latest released version will resolve your question I am going to close this ticket.

@bergercookie
Copy link
Author

I see. I would expect the --cmake-args=-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON to create a single compile_commands.json file at the root of the build directory. This way I would be able to feed tools like Sourcetrail with that one file instead of all the individual JSON files generated.

I mean, it's not too hard on my end to just aggregate them into a single file, it would just be nice for colcon to do it for me in the first place.

Do you think this is a feature worth having in colcon?
I could take a look in implementing it.

@bergercookie
Copy link
Author

I mean, it's not too hard on my end to just aggregate them into a single file, it would just be nice for colcon to do it for me in the first place.

Aplologies, I misunderstood your answer. The PR you linked is doing exactly that.
I think I have an outdated version of colcon then!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Development

No branches or pull requests

2 participants