From 17fe7c32ec390416d76024e3a0ac59850ef63a23 Mon Sep 17 00:00:00 2001 From: Timo Gurr Date: Sat, 4 Nov 2023 20:32:36 +0100 Subject: [PATCH] cmake: Use GNUInstallDirs to install data and lib directories 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. --- cmake/packaging/linux.cmake | 22 +++++++++++----------- cmake/packaging/unix.cmake | 2 ++ packaging/linux/flatpak/sunshine.desktop | 4 ++-- packaging/linux/sunshine.desktop | 2 +- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/cmake/packaging/linux.cmake b/cmake/packaging/linux.cmake index 8106345ffe8..b6ef24e5cbb 100644 --- a/cmake/packaging/linux.cmake +++ b/cmake/packaging/linux.cmake @@ -9,9 +9,9 @@ if(${SUNSHINE_BUILD_APPIMAGE} OR ${SUNSHINE_BUILD_FLATPAK}) DESTINATION "${SUNSHINE_ASSETS_DIR}/systemd/user") else() install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/85-sunshine.rules" - DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/udev/rules.d") + DESTINATION "${CMAKE_INSTALL_LIBDIR}/udev/rules.d") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.service" - DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/systemd/user") + DESTINATION "${CMAKE_INSTALL_LIBDIR}/systemd/user") endif() # Post install @@ -63,19 +63,19 @@ set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF) # application icon install(FILES "${CMAKE_SOURCE_DIR}/sunshine.svg" - DESTINATION "${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps") + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps") # tray icon if(${SUNSHINE_TRAY} STREQUAL 1) install(FILES "${CMAKE_SOURCE_DIR}/sunshine.svg" - DESTINATION "${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/status" + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/status" RENAME "sunshine-tray.svg") install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/common/assets/web/public/images/sunshine-playing.svg" - DESTINATION "${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/status") + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/status") install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/common/assets/web/public/images/sunshine-pausing.svg" - DESTINATION "${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/status") + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/status") install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/common/assets/web/public/images/sunshine-locked.svg" - DESTINATION "${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/status") + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/status") set(CPACK_DEBIAN_PACKAGE_DEPENDS "\ ${CPACK_DEBIAN_PACKAGE_DEPENDS}, \ @@ -89,17 +89,17 @@ endif() # desktop file # todo - validate desktop files with `desktop-file-validate` install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.desktop" - DESTINATION "${CMAKE_INSTALL_PREFIX}/share/applications") + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications") if(NOT ${SUNSHINE_BUILD_APPIMAGE}) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine_terminal.desktop" - DESTINATION "${CMAKE_INSTALL_PREFIX}/share/applications") + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications") endif() if(${SUNSHINE_BUILD_FLATPAK}) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine_kms.desktop" - DESTINATION "${CMAKE_INSTALL_PREFIX}/share/applications") + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications") endif() # metadata file # todo - validate file with `appstream-util validate-relax` install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.appdata.xml" - DESTINATION "${CMAKE_INSTALL_PREFIX}/share/metainfo") + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo") diff --git a/cmake/packaging/unix.cmake b/cmake/packaging/unix.cmake index bacbfc910de..d6a4ae93575 100644 --- a/cmake/packaging/unix.cmake +++ b/cmake/packaging/unix.cmake @@ -1,6 +1,8 @@ # unix specific packaging # put anything here that applies to both linux and macos +include(GNUInstallDirs) + # return here if building a macos package if(SUNSHINE_PACKAGE_MACOS) return() diff --git a/packaging/linux/flatpak/sunshine.desktop b/packaging/linux/flatpak/sunshine.desktop index 33124ab842f..be702701e08 100644 --- a/packaging/linux/flatpak/sunshine.desktop +++ b/packaging/linux/flatpak/sunshine.desktop @@ -12,9 +12,9 @@ Actions=RunInTerminal;KMS; [Desktop Action RunInTerminal] Name=Run in Terminal Icon=application-x-executable -Exec=gio launch @CMAKE_INSTALL_PREFIX@/share/applications/sunshine_terminal.desktop +Exec=gio launch @CMAKE_INSTALL_DATAROOTDIR@/applications/sunshine_terminal.desktop [Desktop Action KMS] Name=Run in Terminal (KMS) Icon=application-x-executable -Exec=gio launch @CMAKE_INSTALL_PREFIX@/share/applications/sunshine_kms.desktop +Exec=gio launch @CMAKE_INSTALL_DATAROOTDIR@/applications/sunshine_kms.desktop diff --git a/packaging/linux/sunshine.desktop b/packaging/linux/sunshine.desktop index 6bb8687fd1c..b0f2ce327ec 100644 --- a/packaging/linux/sunshine.desktop +++ b/packaging/linux/sunshine.desktop @@ -12,4 +12,4 @@ Actions=RunInTerminal; [Desktop Action RunInTerminal] Name=Run in Terminal Icon=application-x-executable -Exec=gio launch @CMAKE_INSTALL_PREFIX@/share/applications/sunshine_terminal.desktop +Exec=gio launch @CMAKE_INSTALL_DATAROOTDIR@/applications/sunshine_terminal.desktop