Update CMakeLists.txt;

Change Resource File Loading Path For macOS
This commit is contained in:
Saturneric 2021-06-26 05:28:27 +08:00
parent 28a80b6cfa
commit 4870b452c9
10 changed files with 34 additions and 20 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
project(GpgFrontend VERSION 1.1.0 LANGUAGES CXX) project(GpgFrontend VERSION 1.0.6 LANGUAGES CXX)
message(STATUS "GPGFrontend Build Configuration Started CMAKE Version ${CMAKE_VERSION}") message(STATUS "GPGFrontend Build Configuration Started CMAKE Version ${CMAKE_VERSION}")
@ -81,7 +81,7 @@ IF (MINGW)
message(STATUS "Configuration For OS Platform Microsoft Windows") message(STATUS "Configuration For OS Platform Microsoft Windows")
message(STATUS "Build Environment MINGW") message(STATUS "Build Environment MINGW")
set(OS_PLATFORM "WINDOWS") set(OS_PLATFORM 0)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static") set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
@ -99,7 +99,7 @@ if(APPLE)
message(STATUS "Configuration For OS Platform MacOS") message(STATUS "Configuration For OS Platform MacOS")
set(OS_PLATFORM "MACOS") set(OS_PLATFORM 1)
set(ENV{Qt5_DIR} /usr/local/opt/qt5/lib/cmake) set(ENV{Qt5_DIR} /usr/local/opt/qt5/lib/cmake)
@ -119,7 +119,7 @@ endif()
if(LINUX) if(LINUX)
message(STATUS "Configuration For OS Platform LINUX") message(STATUS "Configuration For OS Platform LINUX")
set(OS_PLATFORM "LINUX") set(OS_PLATFORM 2)
include_directories( include_directories(
include include
@ -135,6 +135,8 @@ if(LINUX)
endif() endif()
message(STATUS "OS_PLATFORM ${OS_PLATFORM}")
find_package(Qt5 COMPONENTS Core Test Widgets PrintSupport Network LinguistTools REQUIRED) find_package(Qt5 COMPONENTS Core Test Widgets PrintSupport Network LinguistTools REQUIRED)
add_subdirectory(src) add_subdirectory(src)

View File

@ -16,9 +16,14 @@
#include <gpgme.h> #include <gpgme.h>
#define WINDOWS 0
#define MACOS 1
#define LINUX 2
#define PROJECT_NAME "@PROJECT_NAME@" #define PROJECT_NAME "@PROJECT_NAME@"
#define BUILD_VERSION "@BUILD_VERSION@" #define BUILD_VERSION "@BUILD_VERSION@"
#define GIT_VERSION "@GIT_VERSION@" #define GIT_VERSION "@GIT_VERSION@"
#define OS_PLATFORM @OS_PLATFORM@
#define VERSION_MAJOR @CMAKE_PROJECT_VERSION_MAJOR@ #define VERSION_MAJOR @CMAKE_PROJECT_VERSION_MAJOR@
#define VERSION_MINOR @CMAKE_PROJECT_VERSION_MINOR@ #define VERSION_MINOR @CMAKE_PROJECT_VERSION_MINOR@
@ -29,4 +34,11 @@
#define GIT_BRANCH_NAME "@GIT_BRANCH_NAME@" #define GIT_BRANCH_NAME "@GIT_BRANCH_NAME@"
#define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@" #define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@"
#if OS_PLATFORM == MACOS
# define RESOURCE_DIR(appDir) (appDir + "../Resources/")
#else
# define RESOURCE_DIR(appDir) (appDir)
#endif
#endif //GPGFRONTEND_H_IN #endif //GPGFRONTEND_H_IN

View File

@ -26,7 +26,7 @@
MainWindow::MainWindow() MainWindow::MainWindow()
: appPath(qApp->applicationDirPath()), : appPath(qApp->applicationDirPath()),
settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat) { settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) {
mCtx = new GpgME::GpgContext(); mCtx = new GpgME::GpgContext();

View File

@ -57,7 +57,7 @@ int main(int argc, char *argv[]) {
QDir().mkdir(appPath + "/conf"); QDir().mkdir(appPath + "/conf");
} }
QSettings::setDefaultFormat(QSettings::IniFormat); QSettings::setDefaultFormat(QSettings::IniFormat);
QSettings settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat); QSettings settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat);
QTranslator translator, translator2; QTranslator translator, translator2;
int return_from_event_loop_code; int return_from_event_loop_code;

View File

@ -27,7 +27,7 @@
#include <utility> #include <utility>
KeyMgmt::KeyMgmt(GpgME::GpgContext *ctx, QWidget *parent ) : KeyMgmt::KeyMgmt(GpgME::GpgContext *ctx, QWidget *parent ) :
QMainWindow(parent), appPath(qApp->applicationDirPath()), settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat) QMainWindow(parent), appPath(qApp->applicationDirPath()), settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat)
{ {
mCtx = ctx; mCtx = ctx;

View File

@ -29,7 +29,7 @@
KeyServerImportDialog::KeyServerImportDialog(GpgME::GpgContext *ctx, KeyList *keyList, bool automatic, KeyServerImportDialog::KeyServerImportDialog(GpgME::GpgContext *ctx, KeyList *keyList, bool automatic,
QWidget *parent) QWidget *parent)
: QDialog(parent), appPath(qApp->applicationDirPath()), : QDialog(parent), appPath(qApp->applicationDirPath()),
settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat), settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat),
mCtx(ctx), mKeyList(keyList), mAutomatic(automatic) { mCtx(ctx), mKeyList(keyList), mAutomatic(automatic) {
if(automatic) { if(automatic) {
@ -442,7 +442,7 @@ void KeyServerImportDialog::setLoading(bool status) {
KeyServerImportDialog::KeyServerImportDialog(GpgME::GpgContext *ctx, QWidget *parent) KeyServerImportDialog::KeyServerImportDialog(GpgME::GpgContext *ctx, QWidget *parent)
: QDialog(parent), appPath(qApp->applicationDirPath()), : QDialog(parent), appPath(qApp->applicationDirPath()),
settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat), settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat),
mCtx(ctx), mAutomatic(true) { mCtx(ctx), mAutomatic(true) {
setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint); setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);

View File

@ -28,7 +28,7 @@
KeyUploadDialog::KeyUploadDialog(GpgME::GpgContext *ctx, const QVector<GpgKey> &keys, QWidget *parent) KeyUploadDialog::KeyUploadDialog(GpgME::GpgContext *ctx, const QVector<GpgKey> &keys, QWidget *parent)
: appPath(qApp->applicationDirPath()), : appPath(qApp->applicationDirPath()),
settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat), settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat),
QDialog(parent) { QDialog(parent) {
ctx->exportKeys(keys, mKeyData); ctx->exportKeys(keys, mKeyData);
uploadKeyToServer(mKeyData); uploadKeyToServer(mKeyData);

View File

@ -122,7 +122,7 @@ QHash<QString, QString> SettingsDialog::listLanguages() {
GeneralTab::GeneralTab(GpgME::GpgContext *ctx, QWidget *parent) GeneralTab::GeneralTab(GpgME::GpgContext *ctx, QWidget *parent)
: QWidget(parent), appPath(qApp->applicationDirPath()), : QWidget(parent), appPath(qApp->applicationDirPath()),
settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat) { settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) {
mCtx = ctx; mCtx = ctx;
/***************************************** /*****************************************
@ -333,7 +333,7 @@ void GeneralTab::slotOwnKeyIdChanged() {
MimeTab::MimeTab(QWidget *parent) MimeTab::MimeTab(QWidget *parent)
: QWidget(parent), appPath(qApp->applicationDirPath()), : QWidget(parent), appPath(qApp->applicationDirPath()),
settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat) { settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) {
/***************************************** /*****************************************
* MIME-Parsing-Box * MIME-Parsing-Box
*****************************************/ *****************************************/
@ -404,7 +404,7 @@ void MimeTab::applySettings() {
AppearanceTab::AppearanceTab(QWidget *parent) AppearanceTab::AppearanceTab(QWidget *parent)
: QWidget(parent), appPath(qApp->applicationDirPath()), : QWidget(parent), appPath(qApp->applicationDirPath()),
settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat) { settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) {
/***************************************** /*****************************************
* Icon-Size-Box * Icon-Size-Box
*****************************************/ *****************************************/
@ -539,7 +539,7 @@ void AppearanceTab::applySettings() {
KeyserverTab::KeyserverTab(QWidget *parent) KeyserverTab::KeyserverTab(QWidget *parent)
: QWidget(parent), appPath(qApp->applicationDirPath()), : QWidget(parent), appPath(qApp->applicationDirPath()),
settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat) { settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) {
auto keyServerList = settings.value("keyserver/keyServerList").toStringList(); auto keyServerList = settings.value("keyserver/keyServerList").toStringList();
@ -611,7 +611,7 @@ void KeyserverTab::applySettings() {
AdvancedTab::AdvancedTab(QWidget *parent) AdvancedTab::AdvancedTab(QWidget *parent)
: QWidget(parent), appPath(qApp->applicationDirPath()), : QWidget(parent), appPath(qApp->applicationDirPath()),
settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat) { settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) {
/***************************************** /*****************************************
* Steganography Box * Steganography Box
*****************************************/ *****************************************/
@ -641,7 +641,7 @@ void AdvancedTab::applySettings() {
GpgPathsTab::GpgPathsTab(QWidget *parent) GpgPathsTab::GpgPathsTab(QWidget *parent)
: QWidget(parent), appPath(qApp->applicationDirPath()), : QWidget(parent), appPath(qApp->applicationDirPath()),
settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat) { settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) {
setSettings(); setSettings();
/***************************************** /*****************************************

View File

@ -30,7 +30,7 @@
Wizard::Wizard(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent) Wizard::Wizard(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent)
: QWizard(parent), appPath(qApp->applicationDirPath()), : QWizard(parent), appPath(qApp->applicationDirPath()),
settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat) { settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) {
mCtx = ctx; mCtx = ctx;
mKeyMgmt = keyMgmt; mKeyMgmt = keyMgmt;
@ -107,7 +107,7 @@ bool Wizard::importPubAndSecKeysFromDir(const QString &dir, KeyMgmt *keyMgmt) {
IntroPage::IntroPage(QWidget *parent) IntroPage::IntroPage(QWidget *parent)
: QWizardPage(parent), appPath(qApp->applicationDirPath()), : QWizardPage(parent), appPath(qApp->applicationDirPath()),
settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat) { settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) {
setTitle(tr("Getting started...")); setTitle(tr("Getting started..."));
setSubTitle(tr("... with GPGFrontend")); setSubTitle(tr("... with GPGFrontend"));
@ -202,7 +202,7 @@ void ChoosePage::slotJumpPage(const QString &page) {
ImportFromGpg4usbPage::ImportFromGpg4usbPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent) ImportFromGpg4usbPage::ImportFromGpg4usbPage(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent)
: QWizardPage(parent), appPath(qApp->applicationDirPath()), : QWizardPage(parent), appPath(qApp->applicationDirPath()),
settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat) { settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat) {
mCtx = ctx; mCtx = ctx;
mKeyMgmt = keyMgmt; mKeyMgmt = keyMgmt;
setTitle(tr("Import from...")); setTitle(tr("Import from..."));

View File

@ -31,7 +31,7 @@ KeyList::KeyList(GpgME::GpgContext *ctx,
KeyListColumn::InfoType infoType, KeyListColumn::InfoType infoType,
QWidget *parent) QWidget *parent)
: QWidget(parent), mSelectType(selectType), mInfoType(infoType), appPath(qApp->applicationDirPath()), : QWidget(parent), mSelectType(selectType), mInfoType(infoType), appPath(qApp->applicationDirPath()),
settings(appPath + "/conf/gpgfrontend.ini", QSettings::IniFormat) settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat)
{ {
mCtx = ctx; mCtx = ctx;