Skip to content

Add generated version header urdf_parser/version.hpp - #268

Open
saikishor wants to merge 5 commits into
ros:rollingfrom
saikishor:add/version_header
Open

saikishor wants to merge 5 commits into
ros:rollingfrom
saikishor:add/version_header

Conversation

@saikishor

Copy link
Copy Markdown
Collaborator

Description

Adds a CMake-generated urdf_parser/version.hpp header (plus a urdf_parser/version.h alias, matching the existing .h/.hpp convention), similar to the version.h headers generated for rclcpp and other ROS 2 libraries. Downstream code can now check the urdfdom version at compile time.

The values come from the version already parsed from package.xml in the top-level CMakeLists.txt, so there is no new source of truth.

Provided macros:

  • URDFDOM_VERSION_MAJOR, URDFDOM_VERSION_MINOR, URDFDOM_VERSION_PATCH
  • URDFDOM_VERSION_STR (e.g. "6.0.2")
  • URDFDOM_VERSION_GTE(major, minor, patch), usable in #if
#include <urdf_parser/version.hpp>

#if URDFDOM_VERSION_GTE(6, 0, 0)
  // use APIs available since urdfdom 6.0.0
#endif

Changes

  • cmake/version.hpp.in: header template, configured into the build tree and installed next to the other urdf_parser headers
  • The generated include dir is added to the BUILD_INTERFACE of all urdfdom targets
  • New urdf_version_header_test checks the macros against the build version and the GTE logic
  • README section describing the header

Signed-off-by: Sai Kishor Kothakota <sai.kishor@pal-robotics.com>
Signed-off-by: Sai Kishor Kothakota <sai.kishor@pal-robotics.com>
Signed-off-by: Sai Kishor Kothakota <sai.kishor@pal-robotics.com>
@saikishor
saikishor requested a review from ahcorde November 5, 2026 06:31

@ahcorde ahcorde left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Stale header: I bumped package.xml from 6.0.2 to 6.1.0 and rebuilt with Makefiles. CMake didn't re-run, the header still said 6.0.2, and the version test still passed. With the CMAKE_CONFIGURE_DEPENDS line, the header updated to 6.1.0 and the test passed. Clean builds aren't affected.
  • Test gap: I broke each of the six macro branches in turn, at both 6.0.2 and 6.1.1. Only the minor < MINOR mutations went undetected. Adding EXPECT_TRUE(URDFDOM_VERSION_GTE(M, m - 1, p + 1)); catches them.

Minor
README: tag 6.0.2 doesn't have the header, and the example fails there with a fatal missing-file error. A __has_include guard handled both cases correctly in my test.

Signed-off-by: Sai Kishor Kothakota <sai.kishor@pal-robotics.com>
Signed-off-by: Sai Kishor Kothakota <sai.kishor@pal-robotics.com>
@saikishor

Copy link
Copy Markdown
Collaborator Author

@ahcorde regarding the __has_include tag, for what it's worth, i think it is wiser to backport this till humble sl everyone can condition things properly. What do you think?. If you want me to add that conditioning I can add

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants