Add optional binary relocatability #218
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎉 New feature
Closes part of gazebosim/gz-sim#626
Summary
This PR uses the changes introduced in gz-cmake3 in gazebosim/gz-cmake#334 to support the cmake installation directory to be moved after the
make install
prefix, and continue to work without the need to set any special environment variable, as long as the library is compiled as shared. To avoid regressions and problems in Ubuntu Focal due to the use of std::filesystem, this new behaviour is only activated if theGZ_ENABLE_RELOCATABLE_INSTALL
option is enabled, and its default value isOFF
.In particular, this PR defines the functions
gz::launch::getPluginInstallPath()
andgz::launch::getInitialConfigPath()
that should be used in place of theGZ_LAUNCH_PLUGIN_INSTALL_PATH
andGZ_LAUNCH_INITIAL_CONFIG_PATH
macros to ensure that the library is relocatable.Furthermore, this PR also deprecates the
GZ_LAUNCH_PLUGIN_INSTALL_PATH
andGZ_LAUNCH_INITIAL_CONFIG_PATH
macros, using the strategy described in https://stackoverflow.com/a/29297970 . That strategy works fine on GCC and Clang, while on MSVC it raise a warning:However, I think that it does anyhow the job of raising some kind of warning, and then at soon as the developer checks the macro definition the kind of warning is clear.
Test it
The test should work as usual. The used CMake machinery is tested in gazebosim/gz-cmake#334 .
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.