Skip to content

Commit

Permalink
Deploy for windows and mac (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
sithlord48 authored Oct 3, 2022
1 parent 671e288 commit 834ef17
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 12 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
# This workflow contains a single job called "build"
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, windows-latest, macos-latest]
# The type of runner that the job will run on
Expand All @@ -25,15 +26,18 @@ jobs:
- uses: actions/checkout@v3
- name: Install Qt
uses: jurplel/install-qt-action@v2
- name: Build Qt
- name: Build
run: |
cmake -S. -Bbuild
cmake --build build --target package
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --target package
# ship artifacts each os
- uses: actions/upload-artifact@v3
with:
name: frog-archiver-${{ matrix.os }}
path: build/*.tar.gz
path: |
build/*.tar.gz
build/*.zip
build/*.dmg
docs:
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'push' }}
Expand Down
61 changes: 57 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@

find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets)
get_target_property(qmake_executable Qt5::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${qmake_executable}" DIRECTORY)
if(WIN32 OR APPLE)
if(WIN32)
set(deployqtapp windeployqt)
elseif(APPLE)
set(deployqtapp macdeployqt)
endif()
find_program(PLATFORMDEPLOYQT ${deployqtapp} HINTS "${_qt_bin_dir}")
endif()

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

set(CXX_STANDARD 11)
add_subdirectory(i18n)
add_executable(frogarchiver
add_executable(frogarchiver WIN32 MACOSX_BUNDLE
main.cpp
mainwindow.cpp
about.cpp
Expand All @@ -33,24 +43,67 @@ add_executable(frogarchiver
FrogArchiver.qrc
)

if(APPLE)
set_target_properties(frogarchiver PROPERTIES
MACOSX_BUNDLE_BUNDLE_VERSION ${CMAKE_PROJECT_VERSION}
)
install(TARGETS frogarchiver BUNDLE DESTINATION .)
target_compile_options(frogarchiver PRIVATE -stdlib=libc++)
add_custom_command(
TARGET frogarchiver POST_BUILD
COMMAND ${PLATFORMDEPLOYQT} frogarchiver.app
)
elseif(UNIX AND NOT APPLE)
install(TARGETS frogarchiver RUNTIME DESTINATION bin)
install(FILES ${PROJECT_SOURCE_DIR}/LICENSE DESTINATION share/licenses/frogarchive/)
elseif(WIN32)
install(TARGETS frogarchiver RUNTIME DESTINATION .)
install(FILES ${PROJECT_SOURCE_DIR}/LICENSE DESTINATION .)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .)
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
include(InstallRequiredSystemLibraries)
add_custom_command(
TARGET frogarchiver POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/qtDeploy
COMMAND ${PLATFORMDEPLOYQT} --no-compiler-runtime --no-system-d3d-compiler --no-quick-import -xml -qml -network --dir ${CMAKE_BINARY_DIR}/qtDeploy $<TARGET_FILE:frogarchiver>
)
install(
DIRECTORY ${CMAKE_BINARY_DIR}/qtDeploy/
DESTINATION .
FILES_MATCHING PATTERN "*.*"
)
endif()

target_link_libraries(frogarchiver PRIVATE Qt::Core Qt::Gui Qt::Widgets)

install (TARGETS frogarchiver RUNTIME DESTINATION .)
#NOT SURE WHERE THESE SHOULD GO
install (
FILES
config/config.xml
packages/org.berviantoleo.frogarchiver/packages.xml
DESTINATION .
)


#PACKAGING
set(CPACK_STRIP_FILES TRUE)
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_NAME "Frog Archiver")
set(CPACK_PACKAGE_VENDOR "berv-uni-project")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/berv-uni-project/Frog-Archiver")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CMAKE_PROJECT_DESCRIPTION})

if(NOT CPACK_GENERATOR)
if(NOT CPACK_PACKAGE_VERSION)
set(CPACK_PACKAGE_VERSION ${CMAKE_PROJECT_VERSION})
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(CPACK_GENERATOR "ZIP")
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CPACK_DMG_VOLUME_NAME "Frog-Archiver")
set(CPACK_GENERATOR "DragNDrop")
else()
set(CPACK_GENERATOR "TGZ")
endif()

include (CPack)

13 changes: 12 additions & 1 deletion src/i18n/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@ set ( app_TRS
qt_create_translation(TRS ${CMAKE_SOURCE_DIR} ${app_TRS} OPTIONS -no-ui-lines -locations none)
add_custom_target(app_translations ALL DEPENDS ${TRS})

install(FILES ${TRS} DESTINATION i18n)
if(UNIX AND NOT APPLE)
install(FILES ${TRS} DESTINATION share/frogarchiver/i18n)
elseif(WIN32)
install(FILES ${TRS} DESTINATION i18n)
elseif(APPLE)
set(MAC_LANG_PATH Frog_Archiver.app/Contents/MacOS)
set(MAC_QT_LANG_PATH ${Qt${QT_DEFAULT_MAJOR_VERSION}_DIR}/../../../translations)
install(FILES ${TRS} DESTINATION ${MAC_LANG_PATH}/i18n)
install(FILES ${MAC_QT_LANG_PATH}/qtbase_en.qm DESTINATION ${MAC_LANG_PATH}/translations RENAME qt_en.qm)
install(FILES ${MAC_QT_LANG_PATH}/qtbase_es.qm DESTINATION ${MAC_LANG_PATH}/translations RENAME qt_es.qm)
install(FILES ${MAC_QT_LANG_PATH}/qtbase_fr.qm DESTINATION ${MAC_LANG_PATH}/translations RENAME qt_fr.qm)
endif()
20 changes: 17 additions & 3 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ MainWindow::MainWindow(QWidget *parent)
compressWindow(new CompressWindow(this)),
extractWindow(new ExtractWindow(this)) {
ui->setupUi(this);
m_settings = new QSettings(QStringLiteral("%1/settings.ini").arg(QCoreApplication::applicationDirPath()), QSettings::IniFormat);
if (QFile(QStringLiteral("%1/settings.ini").arg(QCoreApplication::applicationDirPath())).exists())
m_settings = new QSettings(QStringLiteral("%1/settings.ini").arg(QCoreApplication::applicationDirPath()), QSettings::IniFormat);
else
m_settings = new QSettings(QSettings::NativeFormat, QSettings::UserScope, QStringLiteral("berv-uni"), QStringLiteral("frogarchiver"));
detectTranslations();

QSize iconSize = QSize(fontMetrics().height(), fontMetrics().height());
Expand Down Expand Up @@ -61,9 +64,20 @@ void MainWindow::detectTranslations()
{
ui->menuLanguage->clear();
m_translations.clear();
const QStringList nameFilter{QStringLiteral("FrogArchiver_*.qm")};
const QString qt_ = QStringLiteral("qt_");
const QStringList nameFilter ={ QStringLiteral("FrogArchiver_*.qm") };
QDir i18nDir (QStringLiteral("%1/i18n/").arg(qApp->applicationDirPath()));

QDir i18nDir(QStringLiteral("%1/%2").arg(QCoreApplication::applicationDirPath(), QStringLiteral("i18n")));
if (i18nDir.entryList(nameFilter, QDir::Files, QDir::Name).isEmpty()) {
i18nDir.setPath(QStringLiteral("%1/../i18n").arg(QCoreApplication::applicationDirPath()));
if (i18nDir.entryList(nameFilter, QDir::Files, QDir::Name).isEmpty()) {
i18nDir.setPath(QStringLiteral("%1/../share/frogarchiver/i18n").arg(QCoreApplication::applicationDirPath()));
if (i18nDir.entryList(nameFilter, QDir::Files, QDir::Name).isEmpty()) {
i18nDir.setPath(QStringLiteral("/usr/share/frogarchiver/i18n"));
}
}
}

const QStringList langList = i18nDir.entryList(nameFilter,QDir::Files, QDir::Name);
for (const QString &translation : langList) {
auto *appTranslator = new QTranslator;
Expand Down

0 comments on commit 834ef17

Please sign in to comment.