Create .app when building/packing macOS (#555)

This commit is contained in:
Helloyunho 2025-07-09 02:09:11 +09:00 committed by GitHub
parent da2a06ed2b
commit 2761d9985a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 283 additions and 1 deletions

View File

@ -122,7 +122,20 @@ jobs:
if: ${{ !matrix.n3ds }} if: ${{ !matrix.n3ds }}
run: | run: |
cd build cd build
cpack . success=0
max_tries=10
for i in $(seq $max_tries); do
cpack . && success=1
if test $success = 1; then
break
fi
echo "Package creation failed. Sleep 1 second and try again."
sleep 1
done
if test $success = 0; then
echo "Package creation failed after $max_tries attempts."
exit 1
fi
- name: Install linuxdeploy - name: Install linuxdeploy
if: ${{ matrix.linux }} if: ${{ matrix.linux }}

View File

@ -707,6 +707,7 @@ if (NOT (NINTENDO_3DS OR WINDOWS_STORE))
install(TARGETS isle ${install_extra_targets} install(TARGETS isle ${install_extra_targets}
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
BUNDLE DESTINATION "."
) )
endif() endif()
if (ISLE_BUILD_CONFIG) if (ISLE_BUILD_CONFIG)
@ -731,6 +732,7 @@ if (ISLE_BUILD_CONFIG)
endif() endif()
install(TARGETS isle-config install(TARGETS isle-config
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
BUNDLE DESTINATION "."
) )
endif() endif()
if(EMSCRIPTEN) if(EMSCRIPTEN)
@ -802,6 +804,8 @@ if(WINDOWS_STORE)
endif() endif()
if(MSVC) if(MSVC)
set(CPACK_GENERATOR ZIP) set(CPACK_GENERATOR ZIP)
elseif(APPLE AND NOT IOS)
set(CPACK_GENERATOR DragNDrop)
else() else()
set(CPACK_GENERATOR TGZ) set(CPACK_GENERATOR TGZ)
endif() endif()

View File

@ -24,3 +24,7 @@ endif()
if(WINDOWS_STORE) if(WINDOWS_STORE)
add_subdirectory(UWP) add_subdirectory(UWP)
endif() endif()
if(APPLE AND NOT IOS)
add_subdirectory(macos)
endif()

View File

@ -0,0 +1,99 @@
set(_icon_file AppIcon)
set(MACOSX_BUNDLE_GUI_IDENTIFIER ${APP_ID})
set(MACOSX_BUNDLE_COPYRIGHT ${APP_SPDX})
set(ISLE_TARGET_NAME isle)
set(MACOSX_ISLE_BUNDLE_NAME ${APP_NAME}) # Do note that it can be up to 15 characters long
set(MACOSX_ISLE_BUNDLE_DISPLAY_NAME ${APP_NAME})
set(CONFIG_TARGET_NAME isle-config)
set(MACOSX_CONFIG_BUNDLE_NAME "Config Isle") # Do note that it can be up to 15 characters long
set(MACOSX_CONFIG_BUNDLE_DISPLAY_NAME "Configure ${APP_NAME}")
set(MACOSX_BUNDLE_INFO_STRING ${PROJECT_VERSION})
set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION})
set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION})
set(MACOSX_BUNDLE_LONG_VERSION_STRING "Version ${PROJECT_VERSION}")
# TODO: darwin < 9
set(MACOSX_BUNDLE_REQUIRED_PLATFORM Carbon)
set(CPACK_DMG_VOLUME_NAME "Isle Portable")
if(ISLE_BUILD_APP)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/isle/Info.plist.in"
"${CMAKE_CURRENT_BINARY_DIR}/isle/Info.plist"
@ONLY
)
set(RESOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/isle/${_icon_file}.icns")
target_sources(${ISLE_TARGET_NAME} PRIVATE ${RESOURCE_FILES})
set_target_properties(${ISLE_TARGET_NAME} PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_ICON_FILE "${_icon_file}.icns"
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_BINARY_DIR}/isle/Info.plist"
RESOURCE ${RESOURCE_FILES})
install(TARGETS ${ISLE_TARGET_NAME} DESTINATION ./)
install(CODE "
include(BundleUtilities)
fixup_bundle(${CMAKE_BINARY_DIR}/${ISLE_TARGET_NAME}.app \"\" \"\")
"
COMPONENT Runtime)
install(CODE "
execute_process(COMMAND /usr/bin/codesign
--force --deep --sign - --timestamp
\"\$\{CMAKE_INSTALL_PREFIX\}/${ISLE_TARGET_NAME}.app/Contents/MacOS/${ISLE_TARGET_NAME}\")
")
install(CODE "
file(RENAME
\"\$\{CMAKE_INSTALL_PREFIX\}/${ISLE_TARGET_NAME}.app\"
\"\$\{CMAKE_INSTALL_PREFIX\}/${MACOSX_ISLE_BUNDLE_DISPLAY_NAME}.app\")
")
endif()
if(ISLE_BUILD_CONFIG)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/config/Info.plist.in"
"${CMAKE_CURRENT_BINARY_DIR}/config/Info.plist"
@ONLY
)
set(RESOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/config/${_icon_file}.icns")
target_sources(${CONFIG_TARGET_NAME} PRIVATE ${RESOURCE_FILES})
set_target_properties(${CONFIG_TARGET_NAME} PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_ICON_FILE "${_icon_file}.icns"
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_BINARY_DIR}/config/Info.plist"
RESOURCE ${RESOURCE_FILES})
install(TARGETS ${CONFIG_TARGET_NAME} DESTINATION ./)
install(CODE "
include(BundleUtilities)
fixup_bundle(${CMAKE_BINARY_DIR}/${CONFIG_TARGET_NAME}.app \"\" \"\")
"
COMPONENT Runtime)
qt_generate_deploy_app_script(
TARGET ${CONFIG_TARGET_NAME}
OUTPUT_SCRIPT deploy_script
NO_COMPILER_RUNTIME
NO_TRANSLATIONS
)
install(SCRIPT "${deploy_script}")
install(CODE "
execute_process(COMMAND /usr/bin/install_name_tool
-add_rpath \"@executable_path/../Frameworks\"
\"\$\{CMAKE_INSTALL_PREFIX\}/${CONFIG_TARGET_NAME}.app/Contents/MacOS/${CONFIG_TARGET_NAME}\")
")
install(CODE "
execute_process(COMMAND /usr/bin/codesign
--force --deep --sign - --timestamp
\"\$\{CMAKE_INSTALL_PREFIX\}/${CONFIG_TARGET_NAME}.app/Contents/MacOS/${CONFIG_TARGET_NAME}\")
")
install(CODE "
file(RENAME
\"\$\{CMAKE_INSTALL_PREFIX\}/${CONFIG_TARGET_NAME}.app\"
\"\$\{CMAKE_INSTALL_PREFIX\}/${MACOSX_CONFIG_BUNDLE_DISPLAY_NAME}.app\")
")
endif()
install(CODE "
if(IS_DIRECTORY \"\$\{CMAKE_INSTALL_PREFIX\}/bin\" OR IS_DIRECTORY \"\$\{CMAKE_INSTALL_PREFIX\}/lib\" OR EXISTS \"\$\{CMAKE_INSTALL_PREFIX\}/AppIcon.icns\")
execute_process(COMMAND /bin/rm
-rf \"\$\{CMAKE_INSTALL_PREFIX\}/bin\" \"\$\{CMAKE_INSTALL_PREFIX\}/lib\" \"\$\{CMAKE_INSTALL_PREFIX\}/AppIcon.icns\"
)
endif()
")

Binary file not shown.

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>@MACOSX_BUNDLE_INFO_STRING@</string>
<key>CFBundleIconFile</key>
<string>@MACOSX_BUNDLE_ICON_FILE@</string>
<key>CFBundleIdentifier</key>
<string>@MACOSX_BUNDLE_GUI_IDENTIFIER@</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>@MACOSX_BUNDLE_LONG_VERSION_STRING@</string>
<key>CFBundleName</key>
<string>@MACOSX_CONFIG_BUNDLE_NAME@</string>
<key>CFBundleDisplayName</key>
<string>@MACOSX_CONFIG_BUNDLE_DISPLAY_NAME@</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>@MACOSX_BUNDLE_SHORT_VERSION_STRING@</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>@MACOSX_BUNDLE_BUNDLE_VERSION@</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSRequires@MACOSX_BUNDLE_REQUIRED_PLATFORM@</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>@MACOSX_BUNDLE_COPYRIGHT@</string>
<key>SDL_FILESYSTEM_BASE_DIR_TYPE</key>
<string>resource</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>UIFileSharingEnabled</key>
<true/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiresFullScreen</key>
<true/>
<key>UIStatusBarHidden</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
</dict>
<key>CFBundleAllowMixedLocalizations</key>
<true/>
</dict>
</plist>

Binary file not shown.

View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>@MACOSX_BUNDLE_INFO_STRING@</string>
<key>CFBundleIconFile</key>
<string>@MACOSX_BUNDLE_ICON_FILE@</string>
<key>CFBundleIdentifier</key>
<string>@MACOSX_BUNDLE_GUI_IDENTIFIER@</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>@MACOSX_BUNDLE_LONG_VERSION_STRING@</string>
<key>CFBundleName</key>
<string>@MACOSX_ISLE_BUNDLE_NAME@</string>
<key>CFBundleDisplayName</key>
<string>@MACOSX_ISLE_BUNDLE_DISPLAY_NAME@</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>@MACOSX_BUNDLE_SHORT_VERSION_STRING@</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>@MACOSX_BUNDLE_BUNDLE_VERSION@</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSRequires@MACOSX_BUNDLE_REQUIRED_PLATFORM@</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>@MACOSX_BUNDLE_COPYRIGHT@</string>
<key>SDL_FILESYSTEM_BASE_DIR_TYPE</key>
<string>resource</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>UIFileSharingEnabled</key>
<true/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiresFullScreen</key>
<true/>
<key>UIStatusBarHidden</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
</dict>
<key>CFBundleAllowMixedLocalizations</key>
<true/>
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
</dict>
</plist>