Skip to content

Commit

Permalink
CMake: Added PACKAGE_MODE option
Browse files Browse the repository at this point in the history
Set paths, add check in SetResourcesDir
  • Loading branch information
weirdbeardgame authored and F0bes committed Aug 12, 2024
1 parent 4c5253c commit 0c949db
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,4 @@ oprofile_data/
CMakeSettings.json
/ci-artifacts/
/out/
/.cache/
12 changes: 12 additions & 0 deletions cmake/BuildParameters.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# Extra preprocessor definitions that will be added to all pcsx2 builds
set(PCSX2_DEFS "")

include(GNUInstallDirs)

#-------------------------------------------------------------------------------
# Misc option
#-------------------------------------------------------------------------------
option(ENABLE_TESTS "Enables building the unit tests" ON)
option(ENABLE_GSRUNNER "Enables building the GSRunner" OFF)
option(LTO_PCSX2_CORE "Enable LTO/IPO/LTCG on the subset of pcsx2 that benefits most from it but not anything else")
option(USE_VTUNE "Plug VTUNE to profile GS JIT.")
option(PACKAGE_MODE "Use this option to ease packaging of PCSX2 (developer/distribution option)")

#-------------------------------------------------------------------------------
# Graphical option
Expand Down Expand Up @@ -199,6 +202,15 @@ if(MSVC)
)
endif()

if(PACKAGE_MODE)
file(RELATIVE_PATH relative_datadir ${CMAKE_INSTALL_FULL_BINDIR} ${CMAKE_INSTALL_FULL_DATADIR}/PCSX2)

# Compile all source codes with those defines
list(APPEND PCSX2_DEFS
PCSX2_APP_DATADIR="${relative_datadir}")
endif()


if(USE_VTUNE)
list(APPEND PCSX2_DEFS ENABLE_VTUNE)
endif()
Expand Down
10 changes: 10 additions & 0 deletions pcsx2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,16 @@ function(setup_main_executable target)
install(CODE "file(WRITE \"${CMAKE_SOURCE_DIR}/bin/qt.conf\" \"[Paths]\\nPlugins = ./QtPlugins\")")
endif()


if (UNIX AND NOT APPLE)
if (PACKAGE_MODE)
install(TARGETS pcsx2-qt DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
install(DIRECTORY ${CMAKE_SOURCE_DIR}/bin/resources DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/PCSX2)
else()
install(TARGETS pcsx2-qt DESTINATION ${CMAKE_SOURCE_DIR}/bin)
endif()
endif()

if(APPLE)
if(CMAKE_GENERATOR MATCHES "Xcode")
# If we're generating an xcode project, you can just add the shaders to the main pcsx2 target and xcode will deal with them properly
Expand Down
10 changes: 7 additions & 3 deletions pcsx2/Pcsx2Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1870,9 +1870,13 @@ void EmuFolders::SetAppRoot()

bool EmuFolders::SetResourcesDirectory()
{
#ifndef __APPLE__
// On Windows/Linux, these are in the binary directory.
Resources = Path::Combine(AppRoot, "resources");
#ifndef __APPLE__
#ifndef PCSX2_APP_DATADIR
// On Windows/Linux, these are in the binary directory.
Resources = Path::Combine(AppRoot, "resources");
#else
Resources = Path::Canonicalize(Path::Combine(AppRoot, PCSX2_APP_DATADIR "/resources"));
#endif
#else
// On macOS, this is in the bundle resources directory.
Resources = Path::Canonicalize(Path::Combine(AppRoot, "../Resources"));
Expand Down

0 comments on commit 0c949db

Please sign in to comment.