From 770b121b10ba9ff500e1e8ad946d57b87d8e58dc Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 20 Apr 2022 18:53:05 -0700 Subject: [PATCH] Qt: Handle relative DATADIR --- src/platform/qt/CMakeLists.txt | 6 +++++- src/platform/qt/GBAApp.cpp | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/platform/qt/CMakeLists.txt b/src/platform/qt/CMakeLists.txt index fc87441a9..203554f39 100644 --- a/src/platform/qt/CMakeLists.txt +++ b/src/platform/qt/CMakeLists.txt @@ -272,7 +272,11 @@ if(BUILD_GL OR BUILD_GLES2 OR BUILD_EPOXY) endif() install(FILES ${CMAKE_SOURCE_DIR}/res/nointro.dat DESTINATION ${DATADIR} COMPONENT ${BINARY_NAME}-qt) if(NOT WIN32 AND NOT APPLE) - list(APPEND QT_DEFINES DATADIR="${CMAKE_INSTALL_PREFIX}/${DATADIR}") + if(DATADIR MATCHES "^\\.[.\\]") + list(APPEND QT_DEFINES DATADIR="${DATADIR}") + else() + list(APPEND QT_DEFINES DATADIR="${CMAKE_INSTALL_PREFIX}/${DATADIR}") + endif() endif() find_package(Qt5LinguistTools) diff --git a/src/platform/qt/GBAApp.cpp b/src/platform/qt/GBAApp.cpp index 466cefa9f..d53985313 100644 --- a/src/platform/qt/GBAApp.cpp +++ b/src/platform/qt/GBAApp.cpp @@ -207,6 +207,9 @@ QString GBAApp::getOpenDirectoryName(QWidget* owner, const QString& title, const QString GBAApp::dataDir() { #ifdef DATADIR QString path = QString::fromUtf8(DATADIR); + if (path.startsWith("./") || path.startsWith("../")) { + path = QCoreApplication::applicationDirPath() + "/" + path; + } #else QString path = QCoreApplication::applicationDirPath(); #ifdef Q_OS_MAC