summarylogtreecommitdiffstats
path: root/0001-Fix-resources-Fix-CMake.patch
blob: a79c2bdeb8660aaaab55a09b230f81818a306a51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
From 00251d1894fcd819768a3a6fe276a98148cfa86b Mon Sep 17 00:00:00 2001
From: kenshen112 <finalfantasytimothy@gmail.com>
Date: Sat, 24 Dec 2022 10:00:03 -0700
Subject: [PATCH] Fix resources, Fix CMake

S
---
 CMakeLists.txt                | 5 +++++
 cmake/BuildParameters.cmake   | 9 +++++++++
 pcsx2-qt/CMakeLists.txt       | 6 ++++++
 pcsx2/Frontend/CommonHost.cpp | 8 +++++---
 4 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 35622ee3c..bcdca1954 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,6 +25,9 @@ endif()
 # include some generic functions to ensure correctness of the env
 include(Pcsx2Utils)
 
+set(EXECUTEABLE "pcsx2-qt")
+set(PCSX2_MENU_CATEGORIES "Game;Emulator;")
+
 check_no_parenthesis_in_path()
 detectOperatingSystem()
 check_compiler_version("7.0" "7.0")
@@ -63,3 +66,5 @@ if(ACTUALLY_ENABLE_TESTS)
 	add_subdirectory(tests/ctest)
 endif()
 
+INSTALL(DIRECTORY "${CMAKE_BINARY_DIR}/bin/resources" DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/PCSX2)
+INSTALL(FILES "${CMAKE_BINARY_DIR}/bin/PCSX2.desktop" DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake
index a402ab883..abb4b228f 100644
--- a/cmake/BuildParameters.cmake
+++ b/cmake/BuildParameters.cmake
@@ -36,6 +36,15 @@ if(UNIX AND NOT APPLE)
 	option(WAYLAND_API "Enable Wayland support" ON)
 endif()
 
+if(PACKAGE_MODE)
+	file(RELATIVE_PATH relative_datadir ${CMAKE_INSTALL_FULL_BINDIR} ${CMAKE_INSTALL_FULL_DATADIR}/PCSX2)
+	file(RELATIVE_PATH relative_docdir ${CMAKE_INSTALL_FULL_BINDIR} ${CMAKE_INSTALL_FULL_DOCDIR})
+	# Compile all source codes with those defines
+	list(APPEND PCSX2_DEFS
+		PCSX2_APP_DATADIR="${relative_datadir}"
+		PCSX2_APP_DOCDIR="${relative_docdir}")
+endif()
+
 if(APPLE)
 	option(OSX_USE_DEFAULT_SEARCH_PATH "Don't prioritize system library paths" OFF)
 	option(SKIP_POSTPROCESS_BUNDLE "Skip postprocessing bundle for redistributability" OFF)
diff --git a/pcsx2-qt/CMakeLists.txt b/pcsx2-qt/CMakeLists.txt
index 20590de61..10bf6583c 100644
--- a/pcsx2-qt/CMakeLists.txt
+++ b/pcsx2-qt/CMakeLists.txt
@@ -4,6 +4,12 @@ set(CMAKE_AUTOUIC ON)
 
 add_executable(pcsx2-qt)
 
+if(PACKAGE_MODE)
+	install(TARGETS pcsx2-qt DESTINATION ${CMAKE_INSTALL_BINDIR})
+ else()
+	install(TARGETS pcsx2-qt DESTINATION ${CMAKE_SOURCE_DIR}/bin)
+endif()
+
 target_sources(pcsx2-qt PRIVATE
 	AboutDialog.cpp
 	AboutDialog.h
diff --git a/pcsx2/Frontend/CommonHost.cpp b/pcsx2/Frontend/CommonHost.cpp
index 9da1dafd9..d948ac704 100644
--- a/pcsx2/Frontend/CommonHost.cpp
+++ b/pcsx2/Frontend/CommonHost.cpp
@@ -128,12 +128,14 @@ void CommonHost::SetAppRoot()
 
 void CommonHost::SetResourcesDirectory()
 {
-#ifndef __APPLE__
+#ifdef __APPLE__
+	// On macOS, this is in the bundle resources directory.
+	EmuFolders::Resources = Path::Canonicalize(Path::Combine(EmuFolders::AppRoot, "../Resources"));
+#elif !defined(PCSX2_APP_DATADIR)
 	// On Windows/Linux, these are in the binary directory.
 	EmuFolders::Resources = Path::Combine(EmuFolders::AppRoot, "resources");
 #else
-	// On macOS, this is in the bundle resources directory.
-	EmuFolders::Resources = Path::Canonicalize(Path::Combine(EmuFolders::AppRoot, "../Resources"));
+	EmuFolders::Resources = Path::Canonicalize(Path::Combine(EmuFolders::AppRoot, PCSX2_APP_DATADIR "/resources"));
 #endif
 }
 
-- 
2.39.0