Skip to content

Conversation

@scpeters
Copy link
Contributor

@scpeters scpeters commented Dec 5, 2025

Alternative to #232 for addressing the duplicate package versions specified in cmake and package.xml. Whereas #232 adds a github workflow to verify that the versions are identical, this copies a python script and cmake helper from gazebosim/gz-cmake#456 to get the version from a package.xml file and use it in cmake. This makes python a hard requirement for configuring the urdfdom package.

Signed-off-by: Steve Peters <[email protected]>
Copies the python script and cmake helper from gz-cmake
to get the package.xml version.

Signed-off-by: Steve Peters <[email protected]>
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

I'm not opposed to this, but something occurred to me. The data in the package.xml is highly structured XML. Could we not do something as simple as doing a regex? Something like the following:

file(READ package.xml PACKAGE_XML_DATA)
string(REGEX MATCH "<version>([0-9]+)\.([0-9]+)\.([0-9]+)</version>" _ ${PACKAGE_XML_DATA})
set(URDF_MAJOR_VERSION ${CMAKE_MATCH_1})
set(URDF_MINOR_VERSION ${CMAKE_MATCH_2})
set(URDF_PATCH_VERSION ${CMAKE_MATCH_3})

@traversaro
Copy link
Contributor

I'm not opposed to this, but something occurred to me. The data in the package.xml is highly structured XML. Could we not do something as simple as doing a regex? Something like the following:

file(READ package.xml PACKAGE_XML_DATA)
string(REGEX MATCH "<version>([0-9]+)\.([0-9]+)\.([0-9]+)</version>" _ ${PACKAGE_XML_DATA})
set(URDF_MAJOR_VERSION ${CMAKE_MATCH_1})
set(URDF_MINOR_VERSION ${CMAKE_MATCH_2})
set(URDF_PATCH_VERSION ${CMAKE_MATCH_3})

dartsim does something similar: https://github.com/dartsim/dart/blob/59f39923015604b2984b82fc8c964dad9cd598f4/CMakeLists.txt#L72 .

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.

4 participants