Skip to content

Commit

Permalink
Package macOS version as a bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
Lethja committed Dec 8, 2023
1 parent dd91e5d commit df9cdc8
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 57 deletions.
118 changes: 71 additions & 47 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: CMake

on:

push:
paths:
- src/**
Expand All @@ -15,10 +14,8 @@ on:
- .github/workflows/cmake.yml

jobs:

linux:
name: "Ubuntu 22.04LTS x86_64"

runs-on: ubuntu-22.04

steps:
Expand All @@ -31,30 +28,37 @@ jobs:
target: 'desktop'
arch: 'gcc_64'

- name: Install AppImage
run: |
wget -q https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool
chmod a+x appimagetool
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure CMake
- name: CMake Configure
env:
CMAKE_PREFIX_PATH: ${{env.Qt5_Dir}}
run: >-
cmake .
run: cmake .

- name: Build
run: |
cmake --build . && mkdir artifact && mv 86boxman artifact
- name: CMake Build
run: cmake --build . -j`nproc`

- name: CMake Install
env:
DESTDIR: "AppDir"
run: cmake --install . --prefix /usr

- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: '86boxman Ubuntu 22.04LTS x86_64'
path: artifact
path: AppDir

windows:
name: "Windows x86_64 (MXE)"

runs-on: ubuntu-20.04

env:
Expand All @@ -75,53 +79,73 @@ jobs:
with:
fetch-depth: 0

- name: Configure CMake
run: >-
${MXE_CMAKE} .
- name: CMake Configure
run: ${MXE_CMAKE} .

- name: CMake Build
run: ${MXE_CMAKE} --build . -j`nproc`

- name: Build
- name: CMake Install
env:
DESTDIR: "ZipDir"
run: cmake --install . --prefix /

- name: Package
run: |
${MXE_CMAKE} --build . && mkdir artifact && mv 86boxman.exe artifact
mkdir Package
zip Package/86boxman.zip -kj9 ZipDir/*
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: '86boxman Windows x86_64 (MXE)'
path: artifact
path: Package

macos:
name: "MacOS 11 x86_64"

runs-on: macos-11

steps:
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: '5.15.2'
host: 'mac'
target: 'desktop'
arch: 'clang_64'

- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: '5.15.2'
host: 'mac'
target: 'desktop'
arch: 'clang_64'

- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure CMake
env:
CMAKE_PREFIX_PATH: ${{env.Qt5_Dir}}
run: >-
cmake .
- name: Build
run: |
cmake --build . && mkdir artifact && mv 86boxman artifact
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: '86boxman MacOS 11 x86_64'
path: artifact
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: CMake Configure
env:
CMAKE_PREFIX_PATH: ${{env.Qt5_Dir}}
run: cmake .

- name: CMake Build
run: cmake --build . -j`sysctl -n hw.ncpu`

- name: Install
run: |
mkdir AppDir
mv 86boxman.app AppDir
- name: Package
uses: QQxiaoming/[email protected]
with:
name: '86boxman'
srcdir: 'AppDir'

- name: Move DMG
run: |
mkdir Package
mv 86boxman.dmg Package
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: '86boxman MacOS 11 x86_64'
path: Package
34 changes: 25 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
cmake_minimum_required(VERSION 3.1...3.4)
option(APP_IMAGE "Build portable App Image on Linux" ON)

if (APPLE OR (LINUX AND APP_IMAGE))
cmake_minimum_required(VERSION 3.21)
else ()
cmake_minimum_required(VERSION 3.1...3.21)
endif ()

set(PROJECT_NAME "86boxman")

project(${PROJECT_NAME} VERSION 0.01)

set(CMAKE_CXX_STANDARD 98)
Expand All @@ -15,7 +22,8 @@ find_package(Qt5 COMPONENTS
Widgets
REQUIRED)

add_executable(${PROJECT_NAME} src/main.cpp
add_executable(${PROJECT_NAME} MACOSX_BUNDLE
src/main.cpp
src/boxman.cpp
src/boxman.h
src/MainWindow.ui
Expand All @@ -34,15 +42,23 @@ target_link_libraries(${PROJECT_NAME}
Qt5::Widgets
)

if (APPLE)
find_program(MACDEPLOYQT_EXECUTABLE macdeployqt HINTS "${_qt_bin_dir}")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND "${MACDEPLOYQT_EXECUTABLE}"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/../.."
-always-overwrite
COMMENT "Running macdeployqt..."
)
endif ()

if (WIN32)
target_link_options(${PROJECT_NAME} PRIVATE -mwindows)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} ${PROJECT_NAME}.exe)
else ()
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} ${PROJECT_NAME})
endif ()

install(TARGETS ${PROJECT_NAME})

if (NOT WIN32)
install(FILES res/86boxman.desktop DESTINATION share/applications)
endif ()
if (LINUX AND APP_IMAGE)
install(TARGETS ${PROJECT_NAME} RUNTIME_DEPENDENCIES )
else ()
install(TARGETS ${PROJECT_NAME} BUNDLE DESTINATION . )
endif ()
2 changes: 1 addition & 1 deletion res/86boxman.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Type=Application

# The version of the desktop entry specification to which this file complies
Version=1.0
Version=0.01

# The name of the application
Name=86BoxMan
Expand Down
10 changes: 10 additions & 0 deletions res/AppRun
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

RLINK=$(readlink -f "$0")
DNAME=$(dirname "$RLINK")
export APPDIR=$DNAME

export PATH="$APPDIR/usr/bin:$PATH"
export LD_LIBRARY_PATH="$APPDIR/usr/lib:$PATH"

"$APPDIR"/bin/86boxman "$@"

0 comments on commit df9cdc8

Please sign in to comment.