CMake: Use relative paths for package mode

Allows relocating install prefix without recompiling
This commit is contained in:
TellowKrinkle 2021-12-12 17:05:56 -06:00 committed by tellowkrinkle
parent 176917caf4
commit 88c0c41a70
6 changed files with 14 additions and 31 deletions

View File

@ -1,7 +1,3 @@
#!/bin/bash
ln -sf $APPDIR/usr/bin/app /tmp/PCSX2
$APPDIR/AppRun-patched
unlink /tmp/PCSX2

View File

@ -12,8 +12,6 @@ else
ARCH="x86_64"
LIBARCH="x86_64-linux-gnu"
fi
BUILDPATH="$GITHUB_WORKSPACE"/build
BUILDBIN="$BUILDPATH"/pcsx2
cd /tmp
curl -sSfLO "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-$ARCH.AppImage"
chmod a+x linuxdeploy*.AppImage
@ -23,10 +21,7 @@ chmod a+x /tmp/squashfs-root/usr/bin/linuxdeploy-plugin-gtk.sh
mv /tmp/squashfs-root/usr/bin/patchelf /tmp/squashfs-root/usr/bin/patchelf.orig
sudo cp /usr/local/bin/patchelf /tmp/squashfs-root/usr/bin/patchelf
cd "$GITHUB_WORKSPACE"
mkdir -p squashfs-root/usr/bin
ls -al "$BUILDBIN"
cp -P "$BUILDBIN"/pcsx2 "$GITHUB_WORKSPACE"/squashfs-root/usr/bin/
patchelf --set-rpath /tmp/PCSX2 "$GITHUB_WORKSPACE"/squashfs-root/usr/bin/pcsx2
ninja -C build install
cp ./pcsx2/gui/Resources/AppIcon64.png ./squashfs-root/PCSX2.png
cp ./linux_various/PCSX2.desktop.in ./squashfs-root/PCSX2.desktop
sed -i -e 's|Categories=@PCSX2_MENU_CATEGORIES@|Categories=Game;Emulator;|g' ./squashfs-root/PCSX2.desktop
@ -47,10 +42,7 @@ chmod a+x ./squashfs-root/runtime
chmod a+x ./squashfs-root/AppRun-patched
chmod a+x ./squashfs-root/usr/optional/exec.so
echo "$name" > "$GITHUB_WORKSPACE"/squashfs-root/version.txt
mkdir -p "$GITHUB_WORKSPACE"/squashfs-root/usr/bin/app
mkdir -p "$GITHUB_WORKSPACE"/squashfs-root/apprun-hooks
cp -r "$GITHUB_WORKSPACE"/bin/resources "$GITHUB_WORKSPACE"/squashfs-root/usr/bin/app/
cp "$GITHUB_WORKSPACE"/bin/docs/{Configuration_Guide.pdf,PCSX2_FAQ.pdf} "$GITHUB_WORKSPACE"/squashfs-root/usr/bin/app
cp /usr/lib/$LIBARCH/libthai.so.0 "$GITHUB_WORKSPACE"/squashfs-root/usr/lib/
cp --dereference /usr/lib/"$LIBARCH"/libstdc++.so.6 "$GITHUB_WORKSPACE"/squashfs-root/usr/optional/libstdc++/libstdc++.so.6
cp --dereference /lib/"$LIBARCH"/libgcc_s.so.1 "$GITHUB_WORKSPACE"/squashfs-root/usr/optional/libgcc_s/libgcc_s.so.1

View File

@ -22,9 +22,8 @@ cmake \
-DPACKAGE_MODE=TRUE \
-DWAYLAND_API=TRUE \
-DDISABLE_ADVANCE_SIMD=TRUE \
-DCMAKE_INSTALL_LIBDIR="/tmp/" \
-DCMAKE_INSTALL_DATADIR="/tmp/" \
-DCMAKE_INSTALL_DOCDIR="/tmp/PCSX2" \
-DDISABLE_PCSX2_WRAPPER=TRUE \
-DCMAKE_INSTALL_PREFIX="squashfs-root/usr/" \
-DOpenGL_GL_PREFERENCE="LEGACY" \
-DOPENGL_opengl_LIBRARY="" \
-DXDG_STD=TRUE \

View File

@ -57,10 +57,12 @@ if(UNIX AND NOT APPLE)
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="${CMAKE_INSTALL_FULL_DATADIR}/PCSX2"
DOC_DIR_COMPILATION=${CMAKE_INSTALL_FULL_DOCDIR})
PCSX2_APP_DATADIR="${relative_datadir}"
PCSX2_APP_DOCDIR="${relative_docdir}")
endif()
if(APPLE)

View File

@ -190,7 +190,7 @@ namespace PathDefs
#else
// Each linux distributions have his rules for path so we give them the possibility to
// change it with compilation flags. -- Gregory
return wxDirName(PCSX2_APP_DATADIR);
return wxDirName(PCSX2_APP_DATADIR).MakeAbsolute(AppRoot().ToString());
#endif
}
@ -202,7 +202,6 @@ namespace PathDefs
wxDirName GetBios()
{
return GetDocuments() + Base::Bios();
;
}
wxDirName GetCheats()
@ -217,7 +216,11 @@ namespace PathDefs
wxDirName GetDocs()
{
#if !defined(PCSX2_APP_DOCDIR)
return AppRoot() + Base::Docs();
#else
return wxDirName(PCSX2_APP_DOCDIR).MakeAbsolute(AppRoot().ToString());
#endif
}
wxDirName GetSavestates()

View File

@ -70,17 +70,8 @@ Panels::FirstTimeIntroPanel::FirstTimeIntroPanel( wxWindow* parent )
SetMinWidth( MSW_GetDPIScale() * 600 );
FastFormatUnicode configFile, faqFile;
#ifndef DOC_DIR_COMPILATION
configFile.Write( L"file:///%s/Docs/Configuration_Guide.pdf", WX_STR(InstallFolder.ToString()) );
faqFile.Write( L"file:///%s/Docs/PCSX2_FAQ.pdf", WX_STR(InstallFolder.ToString()) );
#else
// Each linux distributions have his rules for path so we give them the possibility to
// change it with compilation flags. -- Gregory
#define xDOC_str(s) DOC_str(s)
#define DOC_str(s) #s
configFile.Write( L"file://%s/Configuration_Guide.pdf", WX_STR(wxDirName(xDOC_str(DOC_DIR_COMPILATION)).ToString()) );
faqFile.Write( L"file://%s/PCSX2_FAQ.pdf", WX_STR(wxDirName(xDOC_str(DOC_DIR_COMPILATION)).ToString()) );
#endif
configFile.Write(L"file:///%s/Configuration_Guide.pdf", WX_STR(PathDefs::GetDocs().ToString()));
faqFile.Write(L"file:///%s/PCSX2_FAQ.pdf", WX_STR(PathDefs::GetDocs().ToString()));
wxStaticBoxSizer& langSel = *new wxStaticBoxSizer( wxVERTICAL, this, _("Language selector") );