Automatic CMake formatting and linting with ament_gersemi
ROS has CMake code style checking provided by the ament_lint_cmake package using cmakelint. This is great but cmake-lint doesn’t fix the issues it finds, and we like automation here in the ROS community.
I’m here to introduce a tool called ament_gersemi that can do CMake code style checking and automatically apply fixes. It is based on the gersemi tool and I think it could be useful to others out there! It has all of the configurability and limitations that gersemi has, but it will at least try to format your CMake files for you.
I have provided a default .gersemirc configuration file, but I would be open to feedback about what that default should be.
- Does it work with
ament_lint_cmake?- In my experience, yes. Feel free to point out any cases where the tools conflict.
- You shouldn’t need
ament_lint_cmakeifament_gersemiworks well because it also does checking w/o formatting.
- Why isn’t this released into the ROS distro?
- It’s probably not mature enough yet.
gersemiis a pip-only dependency, and packages that depend on pip-only packages cannot be released.
- Can it sort my find_package/add_library sources/<insert cmake command here> for me?
- Maybe.
gersemiallows extensions, so we might be able to add some extensions for this.
- Maybe.
| Original | Formatted |
|---|---|
|
|