sdformat install not relocatable: sdf::findFile searches original install location
Original report (archived issue) by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).
As reported here: https://github.com/osrf/homebrew-simulation/issues/479
The issue is that the install path searched by sdf::findFile is the install location at compile time:
- https://github.com/osrf/sdformat/blob/f3ab32d891e619861c513a86e9c10f72cac480bf/src/SDF.cc#L90:103
- https://github.com/osrf/sdformat/blob/f3ab32d891e619861c513a86e9c10f72cac480bf/cmake/sdf_config.h.in#L30:31
We would need to change the logic of sdf::findFile to make it fully relocatable.
Original comment by Jeongseok Lee (Bitbucket: jlee02, GitHub: jslee02).
DART also had the same issue and adopted the workaround of using the environment variable, which I believe sdformat already does. One possible solution I can think of now is searching typical install locations (like find_package does), which are platform dependent.
Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).
Yes, SDF already checks the SDF_PATH environment variable:
- https://github.com/osrf/sdformat/blob/f3ab32d891e619861c513a86e9c10f72cac480bf/src/SDF.cc#L105:120
but it does take an extra step to set that.
Original comment by Silvio Traversaro (Bitbucket: traversaro).
Relevant issue (I was not finding it anymore, so I think it is useful to link it here): https://osrf-migration.github.io/sdformat-gh-pages/#!/osrf/sdformat/issues/141/embed-sdf-xml-files-into-library (#141) .
xref: https://github.com/gazebosim/gz-sim/issues/626#issuecomment-1681348298
I guess this was fixed by https://github.com/gazebosim/sdformat/pull/1414 and explicitly enabling the GZ_ENABLE_RELOCATABLE_INSTALL option. The original issue mentioned homebrew, where I think relocatable install is not supported, but I am not sure if this is relevant or we can just close the issue.