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 <scpeters@openrobotics.org>
Copies the python script and cmake helper from gz-cmake
to get the package.xml version.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
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 .

@scpeters
Copy link
Contributor Author

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})

sure, this is reasonable enough and is more concise. I'll open a separate PR with this approach

@scpeters scpeters changed the title Use package.xml version in cmake Use package.xml version in cmake (using python) Dec 16, 2025
@scpeters
Copy link
Contributor Author

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})

sure, this is reasonable enough and is more concise. I'll open a separate PR with this approach

see #236

@scpeters
Copy link
Contributor Author

the approach from #236 was used instead

@scpeters scpeters closed this Dec 17, 2025
@scpeters scpeters deleted the scpeters/cmake_version_from_package_xml branch December 17, 2025 22:23
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