From b14ff3790515bda4f807bdff022ec45bf45e396c Mon Sep 17 00:00:00 2001
From: detiam <dehe_tian@outlook.com>
Date: Wed, 6 Mar 2024 10:43:04 +0800
Subject: [PATCH 1/2] Fix wrong path in desktop file

---
 cmake/packaging/unix.cmake                     | 2 --
 cmake/prep/special_package_configuration.cmake | 2 ++
 packaging/linux/flatpak/sunshine.desktop       | 4 ++--
 packaging/linux/sunshine.desktop               | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/cmake/packaging/unix.cmake b/cmake/packaging/unix.cmake
index d6a4ae93575..bacbfc910de 100644
--- a/cmake/packaging/unix.cmake
+++ b/cmake/packaging/unix.cmake
@@ -1,8 +1,6 @@
 # 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/cmake/prep/special_package_configuration.cmake b/cmake/prep/special_package_configuration.cmake
index 3094c2399a5..645624fe86e 100644
--- a/cmake/prep/special_package_configuration.cmake
+++ b/cmake/prep/special_package_configuration.cmake
@@ -3,6 +3,8 @@ if (APPLE)
         configure_file(packaging/macos/Portfile Portfile @ONLY)
     endif()
 elseif (UNIX)
+    include(GNUInstallDirs)
+
     # configure the .desktop file
     if(${SUNSHINE_BUILD_APPIMAGE})
         configure_file(packaging/linux/AppImage/sunshine.desktop sunshine.desktop @ONLY)
diff --git a/packaging/linux/flatpak/sunshine.desktop b/packaging/linux/flatpak/sunshine.desktop
index be702701e08..1c5fe13a409 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_DATAROOTDIR@/applications/sunshine_terminal.desktop
+Exec=gio launch @CMAKE_INSTALL_FULL_DATAROOTDIR@/applications/sunshine_terminal.desktop
 
 [Desktop Action KMS]
 Name=Run in Terminal (KMS)
 Icon=application-x-executable
-Exec=gio launch @CMAKE_INSTALL_DATAROOTDIR@/applications/sunshine_kms.desktop
+Exec=gio launch @CMAKE_INSTALL_FULL_DATAROOTDIR@/applications/sunshine_kms.desktop
diff --git a/packaging/linux/sunshine.desktop b/packaging/linux/sunshine.desktop
index b0f2ce327ec..719555301d5 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_DATAROOTDIR@/applications/sunshine_terminal.desktop
+Exec=gio launch @CMAKE_INSTALL_FULL_DATAROOTDIR@/applications/sunshine_terminal.desktop

From 5c5287c9c071e0c18ae665d4a9a5655d70ea303c Mon Sep 17 00:00:00 2001
From: detiam <dehe_tian@outlook.com>
Date: Wed, 6 Mar 2024 12:13:52 +0800
Subject: [PATCH 2/2] cmake: Add comment

Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com>
---
 cmake/prep/special_package_configuration.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmake/prep/special_package_configuration.cmake b/cmake/prep/special_package_configuration.cmake
index 645624fe86e..a5a780f5563 100644
--- a/cmake/prep/special_package_configuration.cmake
+++ b/cmake/prep/special_package_configuration.cmake
@@ -3,7 +3,7 @@ if (APPLE)
         configure_file(packaging/macos/Portfile Portfile @ONLY)
     endif()
 elseif (UNIX)
-    include(GNUInstallDirs)
+    include(GNUInstallDirs)  # this needs to be included prior to configuring the desktop files
 
     # configure the .desktop file
     if(${SUNSHINE_BUILD_APPIMAGE})