Qt: Handle relative DATADIR

This commit is contained in:
Vicki Pfau 2022-04-20 18:53:05 -07:00
parent 96fe40efc1
commit 770b121b10
2 changed files with 8 additions and 1 deletions

View File

@ -272,8 +272,12 @@ if(BUILD_GL OR BUILD_GLES2 OR BUILD_EPOXY)
endif() endif()
install(FILES ${CMAKE_SOURCE_DIR}/res/nointro.dat DESTINATION ${DATADIR} COMPONENT ${BINARY_NAME}-qt) install(FILES ${CMAKE_SOURCE_DIR}/res/nointro.dat DESTINATION ${DATADIR} COMPONENT ${BINARY_NAME}-qt)
if(NOT WIN32 AND NOT APPLE) if(NOT WIN32 AND NOT APPLE)
if(DATADIR MATCHES "^\\.[.\\]")
list(APPEND QT_DEFINES DATADIR="${DATADIR}")
else()
list(APPEND QT_DEFINES DATADIR="${CMAKE_INSTALL_PREFIX}/${DATADIR}") list(APPEND QT_DEFINES DATADIR="${CMAKE_INSTALL_PREFIX}/${DATADIR}")
endif() endif()
endif()
find_package(Qt5LinguistTools) find_package(Qt5LinguistTools)
if(Qt5LinguistTools_FOUND) if(Qt5LinguistTools_FOUND)

View File

@ -207,6 +207,9 @@ QString GBAApp::getOpenDirectoryName(QWidget* owner, const QString& title, const
QString GBAApp::dataDir() { QString GBAApp::dataDir() {
#ifdef DATADIR #ifdef DATADIR
QString path = QString::fromUtf8(DATADIR); QString path = QString::fromUtf8(DATADIR);
if (path.startsWith("./") || path.startsWith("../")) {
path = QCoreApplication::applicationDirPath() + "/" + path;
}
#else #else
QString path = QCoreApplication::applicationDirPath(); QString path = QCoreApplication::applicationDirPath();
#ifdef Q_OS_MAC #ifdef Q_OS_MAC