Skip to content

Commit bb59e64

Browse files
committed
Refactor macOS packaging and update license years
Streamlined the macOS release workflow to use CPack for DMG creation and dependency bundling, moving related logic from the GitHub Actions workflow into CMake. Updated CMake configuration to prevent dependencies from installing their files, improved app bundle naming, and set custom DMG filenames based on architecture. Also updated the copyright year in LICENSE.txt.
1 parent 9b280f6 commit bb59e64

File tree

3 files changed

+73
-29
lines changed

3 files changed

+73
-29
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
name: "macOS Apple Silicon",
2626
os: macos-14,
2727
preset: "macos-arm64-cpm",
28-
arch: "Apple Silicon",
28+
arch: "Apple-Silicon",
2929
flags: "-DHDRVIEW_ENABLE_HEIC=OFF -DHDRVIEW_ENABLE_AVCI=OFF",
3030
}
3131
- {
@@ -69,34 +69,13 @@ jobs:
6969
- name: Build
7070
run: cmake --build --preset ${{ matrix.config.preset }}-release
7171

72-
- name: Rename app bundle with version
73-
run: |
74-
cd ${{github.workspace}}/build/${{ matrix.config.preset }}/${{env.BUILD_TYPE}}
75-
mv HDRView.app "HDRView ${VERSION_NO_V}.app"
72+
- name: Package with CPack
73+
working-directory: ${{github.workspace}}/build/${{ matrix.config.preset }}
74+
run: cpack -C ${{env.BUILD_TYPE}} -G DragNDrop
7675

7776
- name: Checking that HDRView runs
7877
run: |
79-
"${{github.workspace}}/build/${{ matrix.config.preset }}/${{env.BUILD_TYPE}}/HDRView ${VERSION_NO_V}.app/Contents/MacOS/HDRView" --help
80-
81-
- name: Bundle dependencies
82-
run: |
83-
dylibbundler -od -b -x "${{github.workspace}}/build/${{ matrix.config.preset }}/${{env.BUILD_TYPE}}/HDRView ${VERSION_NO_V}.app/Contents/MacOS/HDRView" -d "${{github.workspace}}/build/${{ matrix.config.preset }}/${{env.BUILD_TYPE}}/HDRView ${VERSION_NO_V}.app/Contents/libs/"
84-
85-
- name: Creating dmg
86-
run: |
87-
RESULT="${{github.workspace}}/build/${{ matrix.config.preset }}/${{env.BUILD_TYPE}}/HDRView-${VERSION} (${{ matrix.config.arch }}).dmg"
88-
test -f $RESULT && rm $RESULT
89-
for i in 1 2 3; do
90-
if sudo create-dmg --window-size 500 300 --icon-size 96 --volname "HDRView Installer" --app-drop-link 360 105 --icon "HDRView ${VERSION_NO_V}.app" 130 105 $RESULT "${{github.workspace}}/build/${{ matrix.config.preset }}/${{env.BUILD_TYPE}}/HDRView ${VERSION_NO_V}.app"; then
91-
break
92-
elif [ $i -eq 3 ]; then
93-
echo "create-dmg failed after 3 attempts"
94-
exit 1
95-
else
96-
echo "create-dmg failed, retrying ($i)..."
97-
sleep 2
98-
fi
99-
done
78+
"${{github.workspace}}/build/${{ matrix.config.preset }}/install/HDRView ${VERSION_NO_V}.app/Contents/MacOS/HDRView" --help
10079
10180
- name: Archive build artifacts
10281
uses: actions/upload-artifact@v4
@@ -108,7 +87,7 @@ jobs:
10887
- name: Release
10988
uses: softprops/action-gh-release@v2
11089
with:
111-
files: "${{github.workspace}}/build/${{ matrix.config.preset }}/${{env.BUILD_TYPE}}/HDRView-${{ env.VERSION }} (${{ matrix.config.arch }}).dmg"
90+
files: "${{github.workspace}}/build/${{ matrix.config.preset }}/HDRView-${{ env.VERSION }}-${{ matrix.config.arch }}.dmg"
11291
env:
11392
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11493

CMakeLists.txt

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ set(HELLOIMGUI_EMSCRIPTEN_PTHREAD OFF)
340340
set(HELLOIMGUI_EMSCRIPTEN_PTHREAD_ALLOW_MEMORY_GROWTH OFF)
341341
set(IMGUI_DISABLE_OBSOLETE_FUNCTIONS ON)
342342

343+
# Prevent dependencies from installing their files
344+
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)
345+
343346
CPMAddPackage(
344347
NAME hello_imgui
345348
GITHUB_REPOSITORY pthom/hello_imgui
@@ -348,6 +351,7 @@ CPMAddPackage(
348351
GIT_TAG v1.92.5
349352
OPTIONS "HELLOIMGUI_EMSCRIPTEN_PTHREAD OFF" "HELLOIMGUI_EMSCRIPTEN_PTHREAD_ALLOW_MEMORY_GROWTH OFF"
350353
"IMGUI_DISABLE_OBSOLETE_FUNCTIONS ON"
354+
EXCLUDE_FROM_ALL YES
351355
SYSTEM YES
352356
)
353357
if(hello_imgui_ADDED)
@@ -1479,8 +1483,69 @@ set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
14791483
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}")
14801484

14811485
if(APPLE)
1482-
install(TARGETS HDRView BUNDLE DESTINATION ${CMAKE_INSTALL_PREFIX})
1486+
install(TARGETS HDRView BUNDLE DESTINATION . COMPONENT Runtime)
14831487
set(CPACK_GENERATOR "DragNDrop")
1488+
1489+
# Strip leading 'v' from VERSION if present for app naming
1490+
string(REGEX REPLACE "^v" "" VERSION_NO_V "${VERSION}")
1491+
1492+
# Rename app bundle to include version
1493+
set(VERSIONED_APP_NAME "HDRView ${VERSION_NO_V}.app")
1494+
install(CODE "
1495+
if(EXISTS \"\${CMAKE_INSTALL_PREFIX}/HDRView.app\")
1496+
file(RENAME
1497+
\"\${CMAKE_INSTALL_PREFIX}/HDRView.app\"
1498+
\"\${CMAKE_INSTALL_PREFIX}/${VERSIONED_APP_NAME}\")
1499+
endif()
1500+
" COMPONENT Runtime)
1501+
1502+
# Bundle dependencies using dylibbundler when packaging
1503+
find_program(DYLIBBUNDLER_EXECUTABLE dylibbundler)
1504+
if(DYLIBBUNDLER_EXECUTABLE)
1505+
install(CODE "
1506+
execute_process(
1507+
COMMAND ${DYLIBBUNDLER_EXECUTABLE} -od -b
1508+
-x \"\${CMAKE_INSTALL_PREFIX}/${VERSIONED_APP_NAME}/Contents/MacOS/HDRView\"
1509+
-d \"\${CMAKE_INSTALL_PREFIX}/${VERSIONED_APP_NAME}/Contents/libs/\"
1510+
RESULT_VARIABLE DYLIB_RESULT
1511+
)
1512+
if(NOT DYLIB_RESULT EQUAL 0)
1513+
message(WARNING \"dylibbundler failed with code \${DYLIB_RESULT}\")
1514+
endif()
1515+
" COMPONENT Runtime)
1516+
else()
1517+
message(STATUS "dylibbundler not found - DMG will not include bundled dependencies")
1518+
endif()
1519+
1520+
# CPack DragNDrop settings
1521+
set(CPACK_DMG_VOLUME_NAME "HDRView Installer")
1522+
set(CPACK_DMG_FORMAT "UDBZ")
1523+
1524+
# Determine architecture suffix for DMG filename
1525+
if(CMAKE_OSX_ARCHITECTURES MATCHES "arm64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
1526+
set(ARCH_SUFFIX "Apple-Silicon")
1527+
elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
1528+
set(ARCH_SUFFIX "Intel")
1529+
elseif(CMAKE_OSX_ARCHITECTURES MATCHES "arm64;x86_64|x86_64;arm64")
1530+
set(ARCH_SUFFIX "Universal")
1531+
else()
1532+
set(ARCH_SUFFIX "macOS")
1533+
endif()
1534+
1535+
# Set custom DMG filename: e.g. HDRView-v2.7.0-Apple-Silicon.dmg
1536+
set(CPACK_PACKAGE_FILE_NAME "HDRView-${VERSION}-${ARCH_SUFFIX}")
1537+
1538+
# Configure the AppleScript with the versioned app name
1539+
configure_file(
1540+
"${CMAKE_SOURCE_DIR}/cmake/DMGSetup.scpt.in"
1541+
"${CMAKE_BINARY_DIR}/DMGSetup.scpt"
1542+
@ONLY
1543+
)
1544+
set(CPACK_DMG_DS_STORE_SETUP_SCRIPT "${CMAKE_BINARY_DIR}/DMGSetup.scpt")
1545+
1546+
# Only install Runtime component to avoid dependency files
1547+
set(CPACK_COMPONENTS_ALL Runtime)
1548+
set(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_BINARY_DIR};${PROJECT_NAME};Runtime;/")
14841549
endif()
14851550

14861551
include(CPack)

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2017 Wojciech Jarosz. All rights reserved.
1+
Copyright (c) 2017-2026 Wojciech Jarosz. All rights reserved.
22

33
Redistribution and use in source and binary forms, with or without
44
modification, are permitted provided that the following conditions are met:

0 commit comments

Comments
 (0)