Include Mac OS X platform in installer project

refs #615
This commit is contained in:
Roland Winklmeier
2016-04-10 23:52:27 +02:00
parent 59551c0f1b
commit 45b0503896
21 changed files with 121 additions and 51 deletions

View File

@@ -23,8 +23,19 @@ win32 {
qt5_target.path = $${PREFIX}/bin qt5_target.path = $${PREFIX}/bin
QT5_LIBRARY_DIR = $$[QT_INSTALL_BINS] QT5_LIBRARY_DIR = $$[QT_INSTALL_BINS]
} }
else:macx {
unix:!macx { # OSX workaround using rsync. Otherwise all headers are also copied.
qt5_target.path = $${PREFIX}/lib/QtCore.framework
qt5_target.extra += rsync -avz --exclude \'Headers*\' --exclude \'*debug*\' $$[QT_INSTALL_LIBS]/QtCore.framework/ $${PREFIX}/lib/QtCore.framework/ &&
qt5_target.extra += rsync -avz --exclude \'Headers*\' --exclude \'*debug*\' $$[QT_INSTALL_LIBS]/QtGui.framework/ $${PREFIX}/lib/QtGui.framework/ &&
qt5_target.extra += rsync -avz --exclude \'Headers*\' --exclude \'*debug*\' $$[QT_INSTALL_LIBS]/QtNetwork.framework/ $${PREFIX}/lib/QtNetwork.framework/ &&
qt5_target.extra += rsync -avz --exclude \'Headers*\' --exclude \'*debug*\' $$[QT_INSTALL_LIBS]/QtDBus.framework/ $${PREFIX}/lib/QtDBus.framework/ &&
qt5_target.extra += rsync -avz --exclude \'Headers*\' --exclude \'*debug*\' $$[QT_INSTALL_LIBS]/QtXml.framework/ $${PREFIX}/lib/QtXml.framework/ &&
qt5_target.extra += rsync -avz --exclude \'Headers*\' --exclude \'*debug*\' $$[QT_INSTALL_LIBS]/QtMultimedia.framework/ $${PREFIX}/lib/QtMultimedia.framework/ &&
qt5_target.extra += rsync -avz --exclude \'Headers*\' --exclude \'*debug*\' $$[QT_INSTALL_LIBS]/QtSvg.framework/ $${PREFIX}/lib/QtSvg.framework/ &&
qt5_target.extra += rsync -avz --exclude \'Headers*\' --exclude \'*debug*\' $$[QT_INSTALL_LIBS]/QtWidgets.framework/ $${PREFIX}/lib/QtWidgets.framework/
}
else:unix: {
QT5_LIBRARIES *= libQt5Core.so.5 QT5_LIBRARIES *= libQt5Core.so.5
QT5_LIBRARIES *= libQt5DBus.so.5 QT5_LIBRARIES *= libQt5DBus.so.5
QT5_LIBRARIES *= libQt5Gui.so.5 QT5_LIBRARIES *= libQt5Gui.so.5
@@ -56,13 +67,9 @@ INSTALLS += qt5_target
############### Install Qt5 platform plugins ############## ############### Install Qt5 platform plugins ##############
win32 { win32: QT5_PLATFORM_PLUGINS *= qwindows$${DLL_DEBUG_SUFFIX}.dll
QT5_PLATFORM_PLUGINS *= qwindows$${DLL_DEBUG_SUFFIX}.dll else:macx: QT5_PLATFORM_PLUGINS *= libqcocoa.dylib
} else:unix:QT5_PLATFORM_PLUGINS *= libqxcb.so
unix:!macx {
QT5_PLATFORM_PLUGINS *= libqxcb.so
}
qt5_plugin_target.path = $${PREFIX}/bin/platforms qt5_plugin_target.path = $${PREFIX}/bin/platforms
@@ -74,14 +81,16 @@ for (PLUGIN, QT5_PLATFORM_PLUGINS) {
INSTALLS += qt5_plugin_target INSTALLS += qt5_plugin_target
############### Install DBus ############## ############### Install DBus ##############
win32-g++ { win32-g++ {
DBUS_BINARY_SOURCE_DIR = $$[QT_INSTALL_BINS] DBUS_BINARY_SOURCE_DIR = $$[QT_INSTALL_BINS]
DBUS_BINARIES *= libdbus-1-3.dll
DBUS_BINARIES *= dbus-daemon.exe DBUS_BINARIES *= dbus-daemon.exe
dbus_target.path = $${PREFIX}/bin dbus_binary_target.path = $${PREFIX}/bin
DBUS_LIBARY_SOURCE_DIR = $$[QT_INSTALL_BINS]
DBUS_LIBRARIES *= libdbus-1-3.dll
dbus_library_target.path = $${PREFIX}/bin
DBUS_CONFIG_SOURCE_DIR = $$[QT_INSTALL_BINS]/.. DBUS_CONFIG_SOURCE_DIR = $$[QT_INSTALL_BINS]/..
DBUS_CONFIG_FILES *= share/dbus-1/* DBUS_CONFIG_FILES *= share/dbus-1/*
@@ -90,20 +99,44 @@ win32-g++ {
win32-msvc2015 { win32-msvc2015 {
DBUS_BINARY_SOURCE_DIR = $$[QT_INSTALL_BINS] DBUS_BINARY_SOURCE_DIR = $$[QT_INSTALL_BINS]
DBUS_BINARIES *= expat.dll
DBUS_BINARIES *= dbus-1-3.dll
DBUS_BINARIES *= dbus-daemon.exe DBUS_BINARIES *= dbus-daemon.exe
dbus_target.path = $${PREFIX}/bin dbus_binary_target.path = $${PREFIX}/bin
DBUS_LIBARY_SOURCE_DIR = $$[QT_INSTALL_BINS]
DBUS_LIBRARIES *= expat.dll
DBUS_LIBRARIES *= dbus-1-3.dll
dbus_library_target.path = $${PREFIX}/bin
DBUS_CONFIG_SOURCE_DIR = $$[QT_INSTALL_BINS]/.. DBUS_CONFIG_SOURCE_DIR = $$[QT_INSTALL_BINS]/..
DBUS_CONFIG_FILES *= share/dbus-1/* DBUS_CONFIG_FILES *= share/dbus-1/*
dbus_config_target.path = $${PREFIX}/share/dbus-1 dbus_config_target.path = $${PREFIX}/share/dbus-1
} }
macx {
DBUS_BINARY_SOURCE_DIR = /usr/local/bin
DBUS_BINARIES *= dbus-daemon
dbus_binary_target.path = $${PREFIX}/bin
DBUS_LIBARY_SOURCE_DIR = /usr/local/lib
DBUS_LIBRARIES *= libdbus-1.3.dylib
dbus_library_target.path = $${PREFIX}/lib
DBUS_CONFIG_SOURCE_DIR = /usr/local/share/dbus-1
DBUS_CONFIG_FILES *= session.conf
DBUS_CONFIG_FILES *= system.conf
dbus_config_target.path = $${PREFIX}/share/dbus-1
}
for (BINARY, DBUS_BINARIES) { for (BINARY, DBUS_BINARIES) {
BINARY_PATH = $${DBUS_BINARY_SOURCE_DIR}/$${BINARY} BINARY_PATH = $${DBUS_BINARY_SOURCE_DIR}/$${BINARY}
!exists($$BINARY_PATH): error("Cannot find $${BINARY_PATH}") !exists($$BINARY_PATH): error("Cannot find $${BINARY_PATH}")
dbus_target.files *= $${BINARY_PATH} dbus_binary_target.files *= $${BINARY_PATH}
}
for (LIBRARY, DBUS_LIBRARIES) {
LIBRARY_PATH = $${DBUS_LIBARY_SOURCE_DIR}/$${LIBRARY}
!exists($$LIBRARY_PATH): error("Cannot find $${LIBRARY_PATH}")
dbus_library_target.files *= $${LIBRARY_PATH}
} }
for (DBUS_CONFIG_FILE, DBUS_CONFIG_FILES) { for (DBUS_CONFIG_FILE, DBUS_CONFIG_FILES) {
@@ -112,7 +145,7 @@ for (DBUS_CONFIG_FILE, DBUS_CONFIG_FILES) {
dbus_config_target.files *= $${DBUS_CONFIG_FILE_PATH} dbus_config_target.files *= $${DBUS_CONFIG_FILE_PATH}
} }
win32: INSTALLS += dbus_target dbus_config_target win32|macx: INSTALLS += dbus_binary_target dbus_library_target dbus_config_target
############### Install VC runtime ############## ############### Install VC runtime ##############
@@ -183,11 +216,13 @@ bitrock_builder_bin = $$(BITROCK_BUILDER)
create_updater.depends = copy_installer_project create_updater.depends = copy_installer_project
win32: create_updater.commands = $${bitrock_customize_bin} build $${bitrock_autoupdateproject} windows win32: create_updater.commands = $${bitrock_customize_bin} build $${bitrock_autoupdateproject} windows
unix:!macx: create_updater.commands = $${bitrock_customize_bin} build $${bitrock_autoupdateproject} linux-x64 else:macx: create_updater.commands = $${bitrock_customize_bin} build $${bitrock_autoupdateproject} osx
else:unix: create_updater.commands = $${bitrock_customize_bin} build $${bitrock_autoupdateproject} linux-x64
QMAKE_EXTRA_TARGETS += create_updater QMAKE_EXTRA_TARGETS += create_updater
create_installer.depends = create_updater create_installer.depends = create_updater
win32: create_installer.commands = $${bitrock_builder_bin} build $${bitrock_project} windows --setvars project.outputDirectory=$$shell_path($${PREFIX}/..) win32: create_installer.commands = $${bitrock_builder_bin} build $${bitrock_project} windows --setvars project.outputDirectory=$$shell_path($${PREFIX}/..)
unix:!macx: create_installer.commands = $${bitrock_builder_bin} build $${bitrock_project} linux-x64 --setvars project.outputDirectory=$$shell_path($${PREFIX}/..) else:macx: create_installer.commands = $${bitrock_builder_bin} build $${bitrock_project} osx --setvars project.outputDirectory=$$shell_path($${PREFIX}/..)
else:unix: create_installer.commands = $${bitrock_builder_bin} build $${bitrock_project} linux-x64 --setvars project.outputDirectory=$$shell_path($${PREFIX}/..)
QMAKE_EXTRA_TARGETS += create_installer QMAKE_EXTRA_TARGETS += create_installer
} }

View File

@@ -5,11 +5,24 @@
equals (TEMPLATE, lib) { equals (TEMPLATE, lib) {
# Uncomment line below to supress the default RPATH # Uncomment line below to supress the default RPATH
# QMAKE_LFLAGS_RPATH = # QMAKE_LFLAGS_RPATH =
QMAKE_LFLAGS *= '-Wl,-rpath,\'\$$ORIGIN\''
macx: QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
else:unix: QMAKE_LFLAGS *= '-Wl,-rpath,\'\$$ORIGIN\''
} }
equals (TEMPLATE, app) { equals (TEMPLATE, app) {
QMAKE_LFLAGS *= '-Wl,-rpath,\'\$$ORIGIN/../lib\'' # Uncomment line below to supress the default RPATH
# QMAKE_LFLAGS_RPATH =
# Add rpath to externals to run tests without installing.
# DYLD_LIBRARY_PATH isn't working anymore since OS X 10.11.
unix: QMAKE_LFLAGS *= '-Wl,-rpath,\'$$EXTERNALSDIR\''
macx {
contains(CONFIG, app_bundle): QMAKE_LFLAGS *= -Wl,-rpath,@executable_path/../../../../lib/
else: QMAKE_LFLAGS *= -Wl,-rpath,@executable_path/../lib/
}
else:unix: QMAKE_LFLAGS *= '-Wl,-rpath,\'\$$ORIGIN/../lib\''
} }
################################ ################################

View File

@@ -3,7 +3,7 @@ LIBS *= -L$$DestRoot/lib
unix:!macx { unix:!macx {
# Set the rpath-link to find dependent shared libraries when linking # Set the rpath-link to find dependent shared libraries when linking
# Note: This does not add any rpath into the binaries. # Note: This does not add any rpath into the binaries.
LIBS += -Wl,-rpath-link,$$DestRoot/lib LIBS += -Wl,-rpath-link,$$DestRoot/lib -Wl,-rpath-link,$$[QT_INSTALL_LIBS]
} }
blackgui { blackgui {

View File

@@ -8,7 +8,6 @@ TEMPLATE = app
CONFIG += console CONFIG += console
CONFIG -= app_bundle CONFIG -= app_bundle
CONFIG += blackmisc blackcore CONFIG += blackmisc blackcore
CONFIG -= app_bundle
DEPENDPATH += . $$SourceRoot/src/blackmisc $$SourceRoot/src/blackcore DEPENDPATH += . $$SourceRoot/src/blackmisc $$SourceRoot/src/blackcore
INCLUDEPATH += . $$SourceRoot/src INCLUDEPATH += . $$SourceRoot/src

View File

@@ -6,7 +6,6 @@ TARGET = sampleblackmiscsim
TEMPLATE = app TEMPLATE = app
CONFIG += console CONFIG += console
CONFIG -= app_bundle
CONFIG += blackmisc blacksim blackcore CONFIG += blackmisc blacksim blackcore
CONFIG -= app_bundle CONFIG -= app_bundle

View File

@@ -8,7 +8,6 @@ TEMPLATE = app
CONFIG += console CONFIG += console
CONFIG -= app_bundle CONFIG -= app_bundle
CONFIG += blackmisc blackcore CONFIG += blackmisc blackcore
CONFIG -= app_bundle
DEPENDPATH += . $$SourceRoot/src DEPENDPATH += . $$SourceRoot/src
INCLUDEPATH += . $$SourceRoot/src INCLUDEPATH += . $$SourceRoot/src

View File

@@ -7,9 +7,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = samplehotkey TARGET = samplehotkey
TEMPLATE = app TEMPLATE = app
CONFIG -= app_bundle
CONFIG += blackmisc blackinput blackcore blackgui CONFIG += blackmisc blackinput blackcore blackgui
CONFIG -= app_bundle
DEPENDPATH += . $$SourceRoot/src DEPENDPATH += . $$SourceRoot/src
INCLUDEPATH += . $$SourceRoot/src INCLUDEPATH += . $$SourceRoot/src

View File

@@ -6,7 +6,6 @@ TARGET = sampleweatherdata
TEMPLATE = app TEMPLATE = app
CONFIG += console CONFIG += console
CONFIG -= app_bundle
CONFIG += blackmisc blackcore CONFIG += blackmisc blackcore
CONFIG -= app_bundle CONFIG -= app_bundle

View File

@@ -436,6 +436,14 @@ namespace BlackCore
} }
} }
QString CApplication::applicationDirPath()
{
QString appDirectoryString(qApp->applicationDirPath());
if (appDirectoryString.endsWith("Contents/MacOS")) { appDirectoryString += "/../../.."; }
QDir appDirectory(appDirectoryString);
return appDirectory.absolutePath();
}
bool CApplication::useContexts(const CCoreFacadeConfig &coreConfig) bool CApplication::useContexts(const CCoreFacadeConfig &coreConfig)
{ {
Q_ASSERT_X(this->m_parsed, Q_FUNC_INFO, "Call this function after parsing"); Q_ASSERT_X(this->m_parsed, Q_FUNC_INFO, "Call this function after parsing");

View File

@@ -158,6 +158,10 @@ namespace BlackCore
//! Clear the caches //! Clear the caches
static QStringList clearCaches(); static QStringList clearCaches();
//! Returns the directory of the application. In contrast to QCoreApplication::applicationDirPath()
//! it takes Mac OS X app bundles into account and returns the directory of the bundle.
static QString applicationDirPath();
// ----------------------- parsing ---------------------------------------- // ----------------------- parsing ----------------------------------------
//! \name parsing of command line options //! \name parsing of command line options

View File

@@ -8,6 +8,7 @@
*/ */
#include "blackcore/pluginmanager.h" #include "blackcore/pluginmanager.h"
#include "blackcore/application.h"
#include "blackmisc/logmessage.h" #include "blackmisc/logmessage.h"
#include "blackmisc/statusmessage.h" #include "blackmisc/statusmessage.h"
@@ -54,7 +55,7 @@ namespace BlackCore
QString IPluginManager::pluginDirectory() const QString IPluginManager::pluginDirectory() const
{ {
return qApp->applicationDirPath() % QStringLiteral("/plugins"); return sApp->applicationDirPath() % QStringLiteral("/plugins");
} }
bool IPluginManager::isValid(const QJsonObject &metadata) const bool IPluginManager::isValid(const QJsonObject &metadata) const

View File

@@ -7,6 +7,7 @@
* contained in the LICENSE file. * contained in the LICENSE file.
*/ */
#include "blackcore/application.h"
#include "blackcore/pluginmanagersimulator.h" #include "blackcore/pluginmanagersimulator.h"
#include "blackcore/simulator.h" #include "blackcore/simulator.h"
@@ -134,7 +135,7 @@ namespace BlackCore
QString CPluginManagerSimulator::pluginDirectory() const QString CPluginManagerSimulator::pluginDirectory() const
{ {
return qApp->applicationDirPath() % QStringLiteral("/plugins/simulator"); return sApp->applicationDirPath() % QStringLiteral("/plugins/simulator");
} }
} }

View File

@@ -7,6 +7,7 @@
* contained in the LICENSE file. * contained in the LICENSE file.
*/ */
#include "blackcore/application.h"
#include "blackcore/pluginmanagerweatherdata.h" #include "blackcore/pluginmanagerweatherdata.h"
#include "blackcore/weatherdata.h" #include "blackcore/weatherdata.h"
@@ -66,7 +67,7 @@ namespace BlackCore
QString CPluginManagerWeatherData::pluginDirectory() const QString CPluginManagerWeatherData::pluginDirectory() const
{ {
return qApp->applicationDirPath() % QStringLiteral("/plugins/weatherdata"); return sApp->applicationDirPath() % QStringLiteral("/plugins/weatherdata");
} }
} }

View File

@@ -68,6 +68,15 @@ namespace BlackMisc
#endif #endif
} }
bool CBuildConfig::isRunningOnMacOSXPlatform()
{
#ifdef Q_OS_OSX
return true;
#else
return false;
#endif
}
bool CBuildConfig::isDebugBuild() bool CBuildConfig::isDebugBuild()
{ {
#ifdef QT_DEBUG #ifdef QT_DEBUG
@@ -119,10 +128,27 @@ namespace BlackMisc
return s; return s;
} }
bool isAppBundle()
{
QDir bundleDir(CBuildConfig::getApplicationDir());
bundleDir.cd("../..");
static const bool isBundled = QFileInfo(bundleDir.absolutePath()).isBundle();
return isBundled;
}
QString getSwiftResourceDirImpl() QString getSwiftResourceDirImpl()
{ {
QDir dir(CBuildConfig::getApplicationDir()); QDir dir(CBuildConfig::getApplicationDir());
if (dir.cdUp() && dir.cd("data")) bool success = true;
static const bool appBundle = isAppBundle();
if (CBuildConfig::isRunningOnMacOSXPlatform() && appBundle)
{
success = dir.cd("../../../../data");
}
else { success = dir.cd("../data"); }
if (success)
{ {
Q_ASSERT_X(dir.exists(), Q_FUNC_INFO, "missing dir"); Q_ASSERT_X(dir.exists(), Q_FUNC_INFO, "missing dir");
return dir.absolutePath(); return dir.absolutePath();

View File

@@ -74,6 +74,9 @@ namespace BlackMisc
//! Running on Windows NT platform? //! Running on Windows NT platform?
static bool isRunningOnWindowsNtPlatform(); static bool isRunningOnWindowsNtPlatform();
//! Running on Mac OS X platform?
static bool isRunningOnMacOSXPlatform();
//! Application directory where current application is located //! Application directory where current application is located
//! \todo Move to to CApplication //! \todo Move to to CApplication
static const QString &getApplicationDir(); static const QString &getApplicationDir();

View File

@@ -8,6 +8,7 @@
*/ */
#include "simulatorxplaneconfigwindow.h" #include "simulatorxplaneconfigwindow.h"
#include "blackcore/application.h"
#include "blackmisc/dbusserver.h" #include "blackmisc/dbusserver.h"
#include "blackmisc/fileutils.h" #include "blackmisc/fileutils.h"
#include "blackmisc/simulation/xplane/xplaneutil.h" #include "blackmisc/simulation/xplane/xplaneutil.h"
@@ -32,7 +33,7 @@ namespace
{ {
QString xBusOriginDir() QString xBusOriginDir()
{ {
return QCoreApplication::applicationDirPath() % QStringLiteral("/../xbus"); return sApp->applicationDirPath() % QStringLiteral("/../xbus");
} }
} }

View File

@@ -1,6 +1,6 @@
load(common_pre) load(common_pre)
QT += core dbus widgets QT += core dbus network widgets
TARGET = simulatorxplaneconfig TARGET = simulatorxplaneconfig
TEMPLATE = lib TEMPLATE = lib

View File

@@ -11,7 +11,6 @@ SOURCES += *.cpp
HEADERS += *.h HEADERS += *.h
FORMS += *.ui FORMS += *.ui
CONFIG += blackmisc blacksound blackinput blackcore blackgui CONFIG += blackmisc blacksound blackinput blackcore blackgui
CONFIG -= app_bundle
DEPENDPATH += . $$SourceRoot/src/blackmisc \ DEPENDPATH += . $$SourceRoot/src/blackmisc \
$$SourceRoot/src/blacksound \ $$SourceRoot/src/blacksound \

View File

@@ -11,8 +11,6 @@ SOURCES += *.cpp
HEADERS += *.h HEADERS += *.h
FORMS += *.ui FORMS += *.ui
CONFIG += blackmisc blacksound blackinput blackcore blackgui CONFIG += blackmisc blacksound blackinput blackcore blackgui
CONFIG -= app_bundle
DEPENDPATH += . $$SourceRoot/src/blackmisc \ DEPENDPATH += . $$SourceRoot/src/blackmisc \
$$SourceRoot/src/blacksound \ $$SourceRoot/src/blacksound \

View File

@@ -11,13 +11,6 @@ SOURCES += *.cpp
HEADERS += *.h HEADERS += *.h
FORMS += *.ui FORMS += *.ui
CONFIG += blackmisc blacksound blackinput blackcore blackgui CONFIG += blackmisc blacksound blackinput blackcore blackgui
CONFIG -= app_bundle
macx {
deployment.files = ../blackgui/qss
deployment.path = Contents/MacOS
QMAKE_BUNDLE_DATA += deployment
}
DEPENDPATH += . $$SourceRoot/src/blackmisc \ DEPENDPATH += . $$SourceRoot/src/blackmisc \
$$SourceRoot/src/blacksound \ $$SourceRoot/src/blacksound \

View File

@@ -11,13 +11,6 @@ SOURCES += *.cpp
HEADERS += *.h HEADERS += *.h
FORMS += *.ui FORMS += *.ui
CONFIG += blackmisc blacksound blackinput blackcore blackgui CONFIG += blackmisc blacksound blackinput blackcore blackgui
CONFIG -= app_bundle
macx {
deployment.files = ../blackgui/qss
deployment.path = Contents/MacOS
QMAKE_BUNDLE_DATA += deployment
}
DEPENDPATH += . $$SourceRoot/src/blackmisc \ DEPENDPATH += . $$SourceRoot/src/blackmisc \
$$SourceRoot/src/blacksound \ $$SourceRoot/src/blacksound \