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,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)

View File

@ -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