-
-
Notifications
You must be signed in to change notification settings - Fork 954
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
build(cmake): Use GNUInstallDirs to install data and lib directories #1817
Conversation
Please note I couldn't test building/running the flatpak package as I only do distribution packaging, please be sure to test the change there as well. |
I don't see this as being better or worse than what we have right now. It's just different; therefore, I'm going to close this. |
@ReenigneArcher Please reopen as this actually fixes being able to install this on distributions like Exherbo which have such a said layout and we need to manually patch this wrong behaviour downstream right now: Also see this being fixed for many other projects in the same way (and not done by Exherbo devs so there is actually a need for this not only for Exherbo) just one quick recent example: paullouisageneau/libdatachannel@f1aa6c8 which mentiones Debian as well in regards to LIBDIR: paullouisageneau/libdatachannel#975 |
I fixed it in libdatachannel because otherwise it was broken on Fedora. That's also the case here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also fix conflicts.
@@ -317,6 +317,7 @@ modules: | |||
- cd ${FLATPAK_BUILDER_BUILDDIR} && npm install | |||
config-opts: | |||
- -DCMAKE_BUILD_TYPE=Release | |||
- -DCMAKE_INSTALL_DATAROOTDIR=/app/share |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be added to the following locations, unless the default is okay. Please confirm.
Sunshine/.github/workflows/CI.yml
Lines 402 to 412 in 11d4723
cmake -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DSUNSHINE_ASSETS_DIR=share/sunshine \ -DSUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine \ -DSUNSHINE_ENABLE_WAYLAND=ON \ -DSUNSHINE_ENABLE_X11=ON \ -DSUNSHINE_ENABLE_DRM=ON \ -DSUNSHINE_ENABLE_CUDA=ON \ ${{ matrix.EXTRA_ARGS }} \ .. make -j ${nproc} Sunshine/packaging/linux/Arch/PKGBUILD
Lines 80 to 86 in 11d4723
cmake \ -S "$pkgname" \ -B build \ -Wno-dev \ -D CMAKE_INSTALL_PREFIX=/usr \ -D SUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine \ -D SUNSHINE_ASSETS_DIR="share/sunshine" Sunshine/docker/debian-bookworm.dockerfile
Lines 105 to 115 in 11d4723
cmake \ -DCMAKE_CUDA_COMPILER:PATH=/build/cuda/bin/nvcc \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DSUNSHINE_ASSETS_DIR=share/sunshine \ -DSUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine \ -DSUNSHINE_ENABLE_WAYLAND=ON \ -DSUNSHINE_ENABLE_X11=ON \ -DSUNSHINE_ENABLE_DRM=ON \ -DSUNSHINE_ENABLE_CUDA=ON \ /build/sunshine Sunshine/docker/debian-bullseye.dockerfile
Lines 119 to 129 in 11d4723
cmake \ -DCMAKE_CUDA_COMPILER:PATH=/build/cuda/bin/nvcc \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DSUNSHINE_ASSETS_DIR=share/sunshine \ -DSUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine \ -DSUNSHINE_ENABLE_WAYLAND=ON \ -DSUNSHINE_ENABLE_X11=ON \ -DSUNSHINE_ENABLE_DRM=ON \ -DSUNSHINE_ENABLE_CUDA=ON \ /build/sunshine Sunshine/docker/fedora-38.dockerfile
Lines 106 to 115 in 11d4723
cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DSUNSHINE_ASSETS_DIR=share/sunshine \ -DSUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine \ -DSUNSHINE_ENABLE_WAYLAND=ON \ -DSUNSHINE_ENABLE_X11=ON \ -DSUNSHINE_ENABLE_DRM=ON \ -DSUNSHINE_ENABLE_CUDA=OFF \ /build/sunshine Sunshine/docker/fedora-39.dockerfile
Lines 106 to 115 in 11d4723
cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DSUNSHINE_ASSETS_DIR=share/sunshine \ -DSUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine \ -DSUNSHINE_ENABLE_WAYLAND=ON \ -DSUNSHINE_ENABLE_X11=ON \ -DSUNSHINE_ENABLE_DRM=ON \ -DSUNSHINE_ENABLE_CUDA=OFF \ /build/sunshine Sunshine/docker/ubuntu-20.04.dockerfile
Lines 155 to 165 in 11d4723
cmake \ -DCMAKE_CUDA_COMPILER:PATH=/build/cuda/bin/nvcc \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DSUNSHINE_ASSETS_DIR=share/sunshine \ -DSUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine \ -DSUNSHINE_ENABLE_WAYLAND=ON \ -DSUNSHINE_ENABLE_X11=ON \ -DSUNSHINE_ENABLE_DRM=ON \ -DSUNSHINE_ENABLE_CUDA=ON \ /build/sunshine Sunshine/docker/ubuntu-22.04.dockerfile
Lines 120 to 130 in 11d4723
cmake \ -DCMAKE_CUDA_COMPILER:PATH=/build/cuda/bin/nvcc \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DSUNSHINE_ASSETS_DIR=share/sunshine \ -DSUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine \ -DSUNSHINE_ENABLE_WAYLAND=ON \ -DSUNSHINE_ENABLE_X11=ON \ -DSUNSHINE_ENABLE_DRM=ON \ -DSUNSHINE_ENABLE_CUDA=ON \ /build/sunshine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For regular Linux distributions the defaults which CMake with the use of GNUInstallDirs figures out should be okay, as thats main purpose of it. (See also the comment from @Conan-Kudo above in regards to lib vs lib32/lib64 handling, which for example we don't have on Exherbo as we set different arch-specific prefixes instead.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it it's probably also not required for the flatpak as well as it sets -DCMAKE_INSTALL_PREFIX=/app
so stuff should properly end up being installed there. Pushed again to remove the line.
I probably concluded this wrong as on Exherbo we do indeed have to set DATAROOTDIR
specifically as we need the arch-independent stuff to not land under our (arch-dependent) prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably at the top of
./cmake/packaging/unix.cmake
@tgurr @ReenigneArcher special_package_configuration.cmake
is include before unix.cmake
been include in CMakeLists.txt, therefore GNUInstallDirs
is not enabled when configure desktop file, the @CMAKE_INSTALL_DATAROOTDIR@
in .desktop
files is invalid and empty string, this broken both regular and flatpak version of the desktop file in v0.22.0 release.
Sunshine/packaging/linux/sunshine.desktop
Line 15 in faeeb7e
Exec=gio launch @CMAKE_INSTALL_DATAROOTDIR@/applications/sunshine_terminal.desktop |
include(GNUInstallDirs)
to special_package_configuration.cmake
and generate the desktop file again,
Exec=gio launch share/applications/sunshine_terminal.desktop
the /usr/
in path is missing, a cmake bug? my distro is archlinux.
so how to fix this, revert the change for these desktop file, add -DCMAKE_INSTALL_DATAROOTDIR="/usr/share"
in PKGBUILD and anywhere needed, or wait cmake fix @CMAKE_INSTALL_DATAROOTDIR@
in configure_file()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding -DCMAKE_INSTALL_DATAROOTDIR:PATH=/usr/share
where needed appears to be the correct approach to me, e.g. on Exherbo we have to do that anyways because we need to install arch-independent stuff into /usr and arch-dependent stuff into prefix e.g. /usr/x86_64-pc-linux-gnu like bin, lib and so on which was the reason for this MR in the first place. Unfortunate this doesn't work automatically for configure_file()
but I can see no reason why @CMAKE_INSTALL_PREFIX@
would work but @CMAKE_INSTALL_DATAROOTDIR@
would not, according the the PKGBUILD @CMAKE_INSTALL_PREFIX@
was and is also manually set: https://github.com/LizardByte/Sunshine/blob/nightly/packaging/linux/Arch/PKGBUILD#L65 which might explain why things worked in the first place and brings me back to my suggestion of passing -DCMAKE_INSTALL_DATAROOTDIR:PATH=/usr/share
when/where needed. Hope you all agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tgurr wait according to cmake doc you post above, variable CMAKE_INSTALL_DATAROOT
's value should really just share
.
CMAKE_INSTALL_FULL_<dir>
The absolute path generated from the corresponding
CMAKE_INSTALL_<dir>
value. If the value is not already an absolute path, an absolute path is constructed typically by prepending the value of the CMAKE_INSTALL_PREFIX variable. However, there are some special cases as documented below.
you need CMAKE_INSTALL_FULL_DATAROOT
for value that auto prepend CMAKE_INSTALL_PREFIX
in to CMAKE_INSTALL_DATAROOT
, maybe you can make a new MR for update this and add include(GNUInstallDirs)
in special_package_configuration.cmake
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@detiam Do I get you right that you mean:
-Exec=gio launch @CMAKE_INSTALL_DATAROOTDIR@/applications/sunshine_terminal.desktop
+Exec=gio launch @CMAKE_INSTALL_FULL_DATAROOTDIR@/applications/sunshine_terminal.desktop
I lack the possibility to test your usecase and also don't want to steal the credits from you so if you'd prepare an MR instead I'd happiliy test my usecase to see if something breaks for me (which I don't expect, in the worst case we just set the different variable manually for our build). If you still want to me to prepare an MR instead please advise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please open a new PR (or issue) to help resolve this. Conversation on merged/closed PRs is going to get lost and forgotten about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@detiam Do I get you right that you mean:
-Exec=gio launch @CMAKE_INSTALL_DATAROOTDIR@/applications/sunshine_terminal.desktop +Exec=gio launch @CMAKE_INSTALL_FULL_DATAROOTDIR@/applications/sunshine_terminal.desktop
I lack the possibility to test your usecase and also don't want to steal the credits from you so if you'd prepare an MR instead I'd happiliy test my usecase to see if something breaks for me (which I don't expect, in the worst case we just set the different variable manually for our build). If you still want to me to prepare an MR instead please advise.
ok I opened a new PR here #2223 :)
Rebased on current nightly. |
GNUInstallDirs (https://cmake.org/cmake/help/v3.18/module/GNUInstallDirs.html) is a CMake module which provides similar params as autotools allowing to adjust where files are installed. On multiarch and/or cross layouts the prefix might be something like /usr/${arch} but arch independent files should still go into /usr/share.
Description
GNUInstallDirs (https://cmake.org/cmake/help/v3.18/module/GNUInstallDirs.html) is a CMake module which provides similar params as autotools allowing to adjust where files are installed.
On multiarch and/or cross layouts the prefix might be something like /usr/${arch} but arch independent files should still go into /usr/share.
Screenshot
Issues Fixed or Closed
Type of Change
.github/...
)Checklist
Branch Updates
LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.