Skip to content

Commit

Permalink
Refactor macOS deployment structure and update icon handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dongzgh committed Feb 23, 2025
1 parent 2f5cd03 commit 718ca32
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 34 deletions.
27 changes: 11 additions & 16 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,27 @@
"version": "2.0.0",
"tasks": [
{
"label": "Build NSIS Script",
"label": "Run Shell Script",
"type": "shell",
"command": "makensis",
"args": [
"/V3",
"${file}"
],
"group": "build"
"command": "${file}",
"options": {
"cwd": "${fileDirname}"
},
"group": "build",
"problemMatcher": []
},
{
"label": "Build NSIS Script (strict)",
"label": "Build NSIS Script",
"type": "shell",
"command": "makensis",
"options": {
"cwd": "${fileDirname}"
},
"args": [
"/V3",
"/WX",
"${file}"
],
"group": "build"
},
{
"label": "Run Shell Script",
"type": "shell",
"command": "${file}",
"group": "build",
"problemMatcher": []
}
]
}
21 changes: 13 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ file(GLOB Implementation_FILES "src/*.cpp")

# Add the resource file
qt_add_resources(RESOURCES "res/resources.qrc")
set(RESOURCE_FILES "res/resources.rc")

if (APPLE)
message(STATUS "Building on macOS")

# Set macOS specific resources.
set(PLIST_MACOS "deploy/macos/Info.plist")
set(ICNS_MACOS "deploy/macos/app.icns")

# Set the bundle properties.
set(CMAKE_MACOSX_BUNDLE TRUE) # Enable macOS app bundle creation

Expand All @@ -54,14 +57,12 @@ if (APPLE)
${Implementation_FILES}
${Header_FILES}
${RESOURCES}
${RESOURCE_FILES}
res/workflow.icns # Add the icon file to the bundle
)

# Set the bundle properties.
set_target_properties(${PRODUCT} PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/Info.plist
RESOURCE "${CMAKE_SOURCE_DIR}/res/workflow.icns" # Set the icon for the app bundle
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/${PLIST_MACOS}"
MACOSX_BUNDLE_ICON_FILE "${CMAKE_SOURCE_DIR}/${ICNS_MACOS}"
)
elseif (UNIX)
message(STATUS "Building on Unix")
Expand All @@ -71,26 +72,30 @@ elseif (UNIX)
${Implementation_FILES}
${Header_FILES}
${RESOURCES}
${RESOURCE_FILES}
)
elseif (WIN32)
message(STATUS "Building on Windows")

# Set windows specific resources.
set(RESOURCE_WIN32 "res/resources.rc")

# Add the executable target.
add_executable(${PRODUCT}
WIN32
${Implementation_FILES}
${Header_FILES}
${RESOURCES}
${RESOURCE_FILES}
${RESOURCE_WIN32}
)
endif()

# Set link libraries.
target_link_libraries(${PRODUCT} Qt6::Core Qt6::Widgets Qt6::Svg)

# Set CPack targets.
if (UNIX)
if (APPLE)
add_subdirectory(${CMAKE_SOURCE_DIR}/deploy/macos)
elseif (UNIX)
add_subdirectory(${CMAKE_SOURCE_DIR}/deploy/linux)
elseif (WIN32)
add_subdirectory(${CMAKE_SOURCE_DIR}/deploy/windows)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ windeployqt <path-to-your-executable> # for Qt5
windeployqt6 <path-to-your-executable> # for Qt6
```

- Open `make-installer-win32.nsi` in Visual Studio Code
- Open `deploy/windows/make-app.nsi` in Visual Studio Code
- `F1` to open `Command Palette` and select `Tasks: Run Task`
- Select `Build NSIS Script` from the drop down list
- Installer will be created in the `scripts` folder
- Installer will be created in the `deploy/windows` folder

## Prepare Data

Expand Down
27 changes: 27 additions & 0 deletions deploy/macos/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Include the InstallRequiredSystemLibraries module.
include(InstallRequiredSystemLibraries)

# Set the CPack variables.
set(CPACK_PACKAGE_NAME "${PRODUCT}")
set(CPACK_PACKAGE_VERSION "${VERSION}")
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${DESCRIPTION}")
set(CPACK_PACKAGE_VENDOR "${PRODUCT}")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")

# Set package generator to Apple Disk Image.
set(CPACK_GENERATOR "DragNDrop")

# Include the CPack module.
include(CPack)

# Set the CPack variables for the Apple Disk Image package.
set(CPACK_DMG_VOLUME_NAME "${PRODUCT}")

# Specify the Qt components to include in the package.
set(CPACK_COMPONENTS_ALL Libraries Application)

# Install the executable to the temporary directory
install(DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PRODUCT}.app" DESTINATION "/Applications/")
File renamed without changes.
File renamed without changes.
13 changes: 5 additions & 8 deletions scripts/macos/make-icns.sh → deploy/macos/make-icns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
set -e

# Define the input PNG file and output ICNS file
INPUT_PNG="../res/workflow.png"
OUTPUT_DIR="../res/"
INPUT_PNG="../../res/workflow.png"
OUTPUT_DIR="./"

# Create the iconset directory
ICONSET_DIR="workflow.iconset"
ICONSET_ICNS="workflow.icns"
ICONSET_DIR="app.iconset"
ICONSET_ICNS="app.icns"
mkdir -p $ICONSET_DIR

# Generate the various icon sizes
Expand All @@ -27,10 +27,7 @@ sips -z 1024 1024 $INPUT_PNG --out $ICONSET_DIR/[email protected]
# Convert the iconset to an ICNS file
iconutil -c icns $ICONSET_DIR

# Move the ICNS file to the desired location
mv $ICONSET_ICNS $OUTPUT_DIR

# Clean up the iconset directory
rm -r $ICONSET_DIR
rm -rf $ICONSET_DIR

echo "ICNS file created at $OUTPUT_DIR"

0 comments on commit 718ca32

Please sign in to comment.