gazebosim / gz-gui

Builds on top of Qt to provide widgets which are useful when developing robotics applications, such as a 3D view, plots, dashboard, etc, and can be used together in a convenient unified interface.
https://gazebosim.org
Apache License 2.0
67 stars 39 forks source link

Add optional binary relocatability #552

Closed traversaro closed 4 months ago

traversaro commented 1 year ago

🎉 New feature

Closes part of https://github.com/gazebosim/gz-sim/issues/626

Summary

This PR uses the changes introduced in gz-cmake3 in https://github.com/gazebosim/gz-cmake/pull/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 the GZ_ENABLE_RELOCATABLE_INSTALL option is enabled, and its default value is OFF .

In particular, this PR defines a gz::rendering::getPluginInstallDir() that should be used in place of the GZ_GUI_PLUGIN_INSTALL_DIR macros to ensure that the library is relocatable.

Furthermore, this PR also deprecates the GZ_GUI_PLUGIN_INSTALL_DIR macro, 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:

warning C4068: unknown pragma

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 https://github.com/gazebosim/gz-cmake/pull/334 .

Checklist

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.

mjcarroll commented 1 year ago

Looks like CI is having issues on this one:

  -- Configuring done
  CMake Error at /usr/share/cmake/gz-cmake3/cmake3/GzUtils.cmake:214 (add_library):
    Cannot find source file:

      /github/workspace/build/include/gz/gui/gz-gui7_get_install_prefix_impl.cc

    Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
    .hpp .hxx .in .txx
  Call Stack (most recent call first):
    /usr/share/cmake/gz-cmake3/cmake3/GzCreateCoreLibrary.cmake:104 (_gz_add_library_or_component)
    include/gz/gui/CMakeLists.txt:48 (gz_create_core_library)
traversaro commented 1 year ago

Yes apparently there is some strange interaction between the old CMake version available in Focal and the strange location of the gz_create_core_library call in gz-gui as opposed to other gz-*, I will look into it.

mjcarroll commented 10 months ago

@traversaro are you going to be able to iterate on this one?

traversaro commented 10 months ago

@traversaro are you going to be able to iterate on this one?

I tried earlier today, but I was unable to find the solution. I think we can think of this some time after the code freeze/harmonic release.

mjcarroll commented 10 months ago

Sounds good, I'm going to remove the beta label for now.

traversaro commented 10 months ago

Sounds good, I'm going to remove the beta label for now.

Yes, probably post-Harmonic release the easiest solution is to target harmonic for this, so we do not need to worry about Focal compatibility.

jennuine commented 8 months ago

@traversaro does this need to be retargeted to gz-gui8?

traversaro commented 8 months ago

@traversaro does this need to be retargeted to gz-gui8?

Yes, I can do this in the next days.

caguero commented 6 months ago

@traversaro , friendly ping here. Do you plan to retarget your patch to gz-gui8?

traversaro commented 6 months ago

Yes, sorry, I just lost sight of the PR.

traversaro commented 4 months ago

Ops, sorry for the noise @jennuine @caguero , actually the PR was already merged in gz-gui8 in https://github.com/gazebosim/gz-gui/pull/580 before your pings, so we can safely close this one!