Update Project Configuration and Srouce code for macOS Release Build
This commit is contained in:
parent
4870b452c9
commit
f114be4103
@ -38,9 +38,11 @@ message(STATUS "Define EXECUTABLE_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH}")
|
|||||||
message(STATUS "Define CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}")
|
message(STATUS "Define CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}")
|
||||||
|
|
||||||
if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
||||||
|
set(BUILD_FLAG 0)
|
||||||
message(STATUS "Build Type RELEASE")
|
message(STATUS "Build Type RELEASE")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O2")
|
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O2")
|
||||||
else()
|
else()
|
||||||
|
set(BUILD_FLAG 1)
|
||||||
message(STATUS "Build Type DEBUG")
|
message(STATUS "Build Type DEBUG")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-Wall")
|
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-Wall")
|
||||||
endif()
|
endif()
|
||||||
|
@ -20,11 +20,16 @@
|
|||||||
#define MACOS 1
|
#define MACOS 1
|
||||||
#define LINUX 2
|
#define LINUX 2
|
||||||
|
|
||||||
|
#define RELEASE 0
|
||||||
|
#define DEBUG 1
|
||||||
|
|
||||||
#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 OS_PLATFORM @OS_PLATFORM@
|
||||||
|
|
||||||
|
#define BUILD_FLAG @BUILD_FLAG@
|
||||||
|
|
||||||
#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@
|
||||||
#define VERSION_PATCH @CMAKE_PROJECT_VERSION_PATCH@
|
#define VERSION_PATCH @CMAKE_PROJECT_VERSION_PATCH@
|
||||||
@ -34,11 +39,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
|
#if OS_PLATFORM == MACOS && BUILD_FLAG == RELEASE
|
||||||
# define RESOURCE_DIR(appDir) (appDir + "../Resources/")
|
# define RESOURCE_DIR(appDir) (appDir + "/../Resources/")
|
||||||
#else
|
#else
|
||||||
# define RESOURCE_DIR(appDir) (appDir)
|
# define RESOURCE_DIR(appDir) (appDir)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif //GPGFRONTEND_H_IN
|
#endif //GPGFRONTEND_H_IN
|
||||||
|
@ -90,14 +90,8 @@ if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
|||||||
COMMAND /bin/mv -n ./Resources ./gpgfrontend.app/Contents/
|
COMMAND /bin/mv -n ./Resources ./gpgfrontend.app/Contents/
|
||||||
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
||||||
COMMENT "Copying Resources INTO App Bundle Resource")
|
COMMENT "Copying Resources INTO App Bundle Resource")
|
||||||
add_custom_command(TARGET gpgfrontend POST_BUILD
|
else()
|
||||||
COMMAND /bin/rm -rf ./GpgFrontend.app
|
add_executable(gpgfrontend ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
|
||||||
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
|
||||||
COMMENT "Deleting Old Final App Bundle")
|
|
||||||
add_custom_command(TARGET gpgfrontend POST_BUILD
|
|
||||||
COMMAND /bin/mv -n ./gpgfrontend.app ./GpgFrontend.app
|
|
||||||
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
|
||||||
COMMENT "Rename Build App Bundle to Final App Bundle")
|
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
add_executable(gpgfrontend ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
|
add_executable(gpgfrontend ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
|
||||||
|
10
src/main.cpp
10
src/main.cpp
@ -43,7 +43,7 @@ int main(int argc, char *argv[]) {
|
|||||||
QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf-8"));
|
QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf-8"));
|
||||||
|
|
||||||
// css
|
// css
|
||||||
QFile file(qApp->applicationDirPath() + "/css/default.qss");
|
QFile file(RESOURCE_DIR(qApp->applicationDirPath()) + "/css/default.qss");
|
||||||
file.open(QFile::ReadOnly);
|
file.open(QFile::ReadOnly);
|
||||||
QString styleSheet = QLatin1String(file.readAll());
|
QString styleSheet = QLatin1String(file.readAll());
|
||||||
qApp->setStyleSheet(styleSheet);
|
qApp->setStyleSheet(styleSheet);
|
||||||
@ -53,8 +53,8 @@ int main(int argc, char *argv[]) {
|
|||||||
* internationalisation. loop to restart mainwindow
|
* internationalisation. loop to restart mainwindow
|
||||||
* with changed translation when settings change.
|
* with changed translation when settings change.
|
||||||
*/
|
*/
|
||||||
if(!QDir(appPath + "/conf").exists()) {
|
if(!QDir(RESOURCE_DIR(appPath) + "/conf").exists()) {
|
||||||
QDir().mkdir(appPath + "/conf");
|
QDir().mkdir(RESOURCE_DIR(appPath) + "/conf");
|
||||||
}
|
}
|
||||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||||
QSettings settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat);
|
QSettings settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", QSettings::IniFormat);
|
||||||
@ -72,12 +72,12 @@ int main(int argc, char *argv[]) {
|
|||||||
lang = QLocale::system().name();
|
lang = QLocale::system().name();
|
||||||
}
|
}
|
||||||
qDebug() << "Language set" << lang;
|
qDebug() << "Language set" << lang;
|
||||||
translator.load( appPath + "/ts/" + "gpgfrontend_" + lang);
|
translator.load(RESOURCE_DIR(appPath) + "/ts/" + "gpgfrontend_" + lang);
|
||||||
qDebug() << "Translator" << translator.filePath();
|
qDebug() << "Translator" << translator.filePath();
|
||||||
QApplication::installTranslator(&translator);
|
QApplication::installTranslator(&translator);
|
||||||
|
|
||||||
// set qt translations
|
// set qt translations
|
||||||
translator2.load("./ts/qt_" + lang, appPath);
|
translator2.load(RESOURCE_DIR(appPath) + "/ts/qt_" + lang);
|
||||||
qDebug() << "Translator2" << translator2.filePath();
|
qDebug() << "Translator2" << translator2.filePath();
|
||||||
QApplication::installTranslator(&translator2);
|
QApplication::installTranslator(&translator2);
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ QHash<QString, QString> SettingsDialog::listLanguages() {
|
|||||||
languages.insert("", tr("System Default"));
|
languages.insert("", tr("System Default"));
|
||||||
|
|
||||||
QString appPath = qApp->applicationDirPath();
|
QString appPath = qApp->applicationDirPath();
|
||||||
QDir qmDir = QDir(appPath + "/ts/");
|
QDir qmDir = QDir(RESOURCE_DIR(appPath) + "/ts/");
|
||||||
QStringList fileNames =
|
QStringList fileNames =
|
||||||
qmDir.entryList(QStringList("gpgfrontend_*.qm"));
|
qmDir.entryList(QStringList("gpgfrontend_*.qm"));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user