mac icon added
This commit is contained in:
@ -61,7 +61,15 @@ set(TETRIS_SOURCES
|
||||
)
|
||||
|
||||
if(APPLE)
|
||||
set(APP_ICON "${CMAKE_SOURCE_DIR}/assets/favicon/AppIcon.icns")
|
||||
if(EXISTS "${APP_ICON}")
|
||||
add_executable(tetris MACOSX_BUNDLE ${TETRIS_SOURCES} "${APP_ICON}")
|
||||
set_source_files_properties("${APP_ICON}" PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
|
||||
set_target_properties(tetris PROPERTIES MACOSX_BUNDLE_ICON_FILE "AppIcon.icns")
|
||||
else()
|
||||
message(WARNING "App icon not found at ${APP_ICON}; bundle will use default icon")
|
||||
add_executable(tetris MACOSX_BUNDLE ${TETRIS_SOURCES})
|
||||
endif()
|
||||
else()
|
||||
add_executable(tetris ${TETRIS_SOURCES})
|
||||
endif()
|
||||
|
||||
@ -13,6 +13,8 @@ VERSION="$(date +"%Y.%m.%d")"
|
||||
CLEAN=0
|
||||
PACKAGE_ONLY=0
|
||||
PACKAGE_RUNTIME_DIR=""
|
||||
APP_ICON_SRC="assets/favicon/favicon-512x512.png"
|
||||
APP_ICON_ICNS="assets/favicon/AppIcon.icns"
|
||||
|
||||
print_usage() {
|
||||
cat <<'USAGE'
|
||||
@ -68,6 +70,34 @@ configure_paths() {
|
||||
PACKAGE_DIR="${OUTPUT_DIR}/TetrisGame-mac"
|
||||
}
|
||||
|
||||
generate_icns_if_needed() {
|
||||
if [[ -f "$APP_ICON_ICNS" ]]; then
|
||||
return
|
||||
fi
|
||||
if [[ ! -f "$APP_ICON_SRC" ]]; then
|
||||
log WARN "Icon source PNG not found ($APP_ICON_SRC); skipping .icns generation"
|
||||
return
|
||||
fi
|
||||
if ! command -v iconutil >/dev/null 2>&1; then
|
||||
log WARN "iconutil not available; skipping .icns generation"
|
||||
return
|
||||
fi
|
||||
log INFO "Generating AppIcon.icns from $APP_ICON_SRC ..."
|
||||
tmpdir=$(mktemp -d)
|
||||
iconset="$tmpdir/AppIcon.iconset"
|
||||
mkdir -p "$iconset"
|
||||
# Generate required sizes from 512 base; sips will downscale
|
||||
for size in 16 32 64 128 256 512; do
|
||||
sips -s format png "$APP_ICON_SRC" --resampleHeightWidth $size $size --out "$iconset/icon_${size}x${size}.png" >/dev/null
|
||||
sips -s format png "$APP_ICON_SRC" --resampleHeightWidth $((size*2)) $((size*2)) --out "$iconset/icon_${size}x${size}@2x.png" >/dev/null
|
||||
done
|
||||
iconutil -c icns "$iconset" -o "$APP_ICON_ICNS" || log WARN "iconutil failed to create .icns"
|
||||
rm -rf "$tmpdir"
|
||||
if [[ -f "$APP_ICON_ICNS" ]]; then
|
||||
log OK "Created $APP_ICON_ICNS"
|
||||
fi
|
||||
}
|
||||
|
||||
clean_previous() {
|
||||
if (( CLEAN )); then
|
||||
log INFO "Cleaning previous build artifacts..."
|
||||
@ -296,6 +326,7 @@ main() {
|
||||
log INFO "Output: $OUTPUT_DIR"
|
||||
|
||||
clean_previous
|
||||
generate_icns_if_needed
|
||||
configure_and_build
|
||||
resolve_executable
|
||||
prepare_package_dir
|
||||
|
||||
Reference in New Issue
Block a user