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

CMakeLists.txt: Some fixes for Relocatable package #179

Merged
merged 1 commit into from Dec 20, 2023
Merged

CMakeLists.txt: Some fixes for Relocatable package #179

merged 1 commit into from Dec 20, 2023

Conversation

DasRoteSkelett
Copy link
Contributor

The overall rationale is, that the current behavior is not well suited for cross-compiling or relocation of the package. This
commit shall address some of the issues found.

There are some absolute path in the generation of the .cmake files which ruin the creation of relocatable packages.
Fixing:

  • CMAKE_MODULE_PATH append instead of replacement
  • Do not expose TinyXML Path (private instead of public)
  • INTERFACE use relative path instead of ${CMAKE_INSTALL_INCLUDEDIR}

See also

https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html#creating-relocatable-packages

for reference.

Signed-off-by: Matthias Schoepfer m.schoepfer@rethinkrobotics.com

@traversaro
Copy link
Contributor

The problem is that tinyxml.h is actually included in public header, see https://github.com/ros/urdfdom/blob/3.1.0/urdf_parser/include/urdf_parser/urdf_parser.h#L44 . This change would break compilation if tinyxml is not installed in a system prefix. Possible fixes are:

  • Either install a FindTinyXML.cmake or depend on a package that installs it to switch to use imported targets
  • Or switch to forward declare the used tinyxml classes

@DasRoteSkelett
Copy link
Contributor Author

So, one could REQUIRE tinyxml_vendor, as it installs a FindTinyXML.cmake?
Generally, I find it a bit awkward that tinyxml types are exposed in the public api (especially, because exchanging the xml parser is now difficult). But replacing this would be a breaking change :-(

@traversaro
Copy link
Contributor

So, one could REQUIRE tinyxml_vendor, as it installs a FindTinyXML.cmake?

In theory, yes. In practice, it is a bit awkward as urdfdom is a library that is tipically packaged outside of the usual ros packaging (see for example https://repology.org/project/urdfdom/versions), while tinyxml_vendor is a ROS2-only package, that has a "strange" name that has a specific meaning as part of ROS2, but it would be a bit strange to package for general distributions.

Generally, I find it a bit awkward that tinyxml types are exposed in the public api (especially, because exchanging the xml parser is now difficult). But replacing this would be a breaking change :-(

Yes, I totally agree. See #178 for a related change.

@clalancette
Copy link
Contributor

@DasRoteSkelett With #186 done, some of this is no longer necessary, but some of it is. If you are willing to rebase this to remove the bits that are conflicting, we can consider getting this in.

There are some absolute path in the generation of the .cmake files
which ruin the creation of relocatable packages.
Fixing:
 * CMAKE_MODULE_PATH append instead of replacement
 * INTERFACE use relative path instead of ${CMAKE_INSTALL_INCLUDEDIR}

See also

https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html#creating-relocatable-packages

for reference.

Signed-off-by: Matthias Schoepfer <m.schoepfer@rethinkrobotics.com>
@ghost
Copy link

ghost commented Dec 11, 2023

Done

@clalancette
Copy link
Contributor

Done

Thank you! Here is CI on this change:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@clalancette clalancette merged commit e120287 into ros:master Dec 20, 2023
7 checks passed
harleylara pushed a commit to traversaro/urdfdom that referenced this pull request Feb 15, 2024
There are some absolute path in the generation of the .cmake files
which ruin the creation of relocatable packages.
Fixing:
 * CMAKE_MODULE_PATH append instead of replacement
 * INTERFACE use relative path instead of ${CMAKE_INSTALL_INCLUDEDIR}

See also

https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html#creating-relocatable-packages

for reference.

Signed-off-by: Matthias Schoepfer <m.schoepfer@rethinkrobotics.com>
Co-authored-by: Matthias Schoepfer <m.schoepfer@rethinkrobotics.com>
Signed-off-by: harleylara <harley.lara@outlook.com>
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