Skip to content

Commit

Permalink
feat: macOS bundle support
Browse files Browse the repository at this point in the history
  • Loading branch information
macmini authored and macmini committed Dec 1, 2024
1 parent 06af632 commit f59ed42
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: macOS CI

on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]

jobs:
build:
Expand All @@ -10,10 +10,18 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install Qt
uses: jurplel/install-qt-action@v3
uses: jurplel/install-qt-action@v4
with:
version: '6.4.2'
version: '6.8.1'
- name: Run a qt project
run: |
cmake ./ -DPREFER_QT_5=OFF
make
cmake . -Bbuild
cmake --build build
- name: Deploy
run: |
macdeployqt ./build/ppic.app -dmg
ls
- uses: actions/upload-artifact@v4
with:
name: "macos-bundle"
path: build/*.dmg
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
*.user
*.user.*

# Why, macOS, why?
.DS_Store

# Translation files
*.qm
*.mo
Expand Down
24 changes: 21 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ if (WIN32)
list(APPEND PPIC_RC_FILES assets/pineapple-pictures.rc)
endif ()

add_executable (${EXE_NAME} WIN32
add_executable (${EXE_NAME}
${PPIC_HEADER_FILES}
${PPIC_CPP_FILES}
${PPIC_QRC_FILES}
Expand Down Expand Up @@ -201,8 +201,25 @@ endif ()

# Install settings
if (WIN32)
# TODO: try to avoid install to a "bin" subfolder under windows...
# when fixed, don't forget to update the CI config file...
set_target_properties(${EXE_NAME} PROPERTIES
WIN32_EXECUTABLE TRUE
)
elseif (APPLE)
# The MACOSX_BUNDLE_ICON_FILE variable is added to the Info.plist
# generated by CMake. This variable contains the .icns file name,
# without the path.
set(MACOSX_BUNDLE_ICON_FILE app-icon.icns) # contains the .icns file name, *without* the path.
set_source_files_properties(assets/icons/app-icon.icns PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources"
)
target_sources(${EXE_NAME} PUBLIC assets/icons/app-icon.icns)
set_target_properties(${EXE_NAME} PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_BUNDLE_NAME "Pineapple Pictures"
MACOSX_BUNDLE_GUI_IDENTIFIER net.blumia.pineapple-pictures
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)
elseif (UNIX)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr)
Expand All @@ -229,6 +246,7 @@ elseif (UNIX)
endif()

set (INSTALL_TARGETS_DEFAULT_ARGS
BUNDLE DESTINATION .
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Devel
Expand Down
Binary file added assets/icons/app-icon.icns
Binary file not shown.

0 comments on commit f59ed42

Please sign in to comment.