Skip to content

Commit

Permalink
More work on app icon
Browse files Browse the repository at this point in the history
  • Loading branch information
kunitoki committed Dec 9, 2024
1 parent 520e57d commit e566d34
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
Binary file added cmake/resources/app-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 20 additions & 12 deletions cmake/yup_standalone.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function (yup_standalone_app)
set (options "")
set (one_value_args
# Globals
TARGET_NAME TARGET_VERSION TARGET_CONSOLE TARGET_IDE_GROUP TARGET_APP_ID TARGET_APP_NAMESPACE
TARGET_NAME TARGET_VERSION TARGET_CONSOLE TARGET_IDE_GROUP TARGET_APP_ID TARGET_APP_NAMESPACE TARGET_ICON
# Emscripten
INITIAL_MEMORY PTHREAD_POOL_SIZE CUSTOM_PLIST CUSTOM_SHELL)
set (multi_value_args
Expand All @@ -40,6 +40,7 @@ function (yup_standalone_app)
set (target_console "${YUP_ARG_TARGET_CONSOLE}")
set (target_app_id "${YUP_ARG_TARGET_APP_ID}")
set (target_app_namespace "${YUP_ARG_TARGET_APP_NAMESPACE}")
set (target_resources "")
set (additional_definitions "")
set (additional_options "")
set (additional_libraries "")
Expand Down Expand Up @@ -92,30 +93,37 @@ function (yup_standalone_app)
if ("${yup_platform}" MATCHES "^(osx|ios)$")
if (NOT "${target_console}")
_yup_set_default (YUP_ARG_CUSTOM_PLIST "${CMAKE_SOURCE_DIR}/cmake/platforms/${yup_platform}/Info.plist")
_yup_valid_identifier_string ("org.kunitoki.yup.${target_name}" target_gui_identifier)
_yup_valid_identifier_string ("${target_app_namespace}" target_app_namespace)

_yup_set_default (YUP_ARG_TARGET_ICON "${CMAKE_SOURCE_DIR}/cmake/resources/app-icon.png")
_yup_convert_png_to_icns ("${YUP_ARG_TARGET_ICON}" "${CMAKE_CURRENT_BINARY_DIR}/icons" target_iconset)
get_filename_component (target_iconset_name "${target_iconset}" NAME)
target_sources (${target_name} PRIVATE ${target_iconset})
list (APPEND target_resources "${target_iconset}")

set_target_properties (${target_name} PROPERTIES
BUNDLE ON
CXX_EXTENSIONS OFF
MACOSX_BUNDLE_EXECUTABLE_NAME "${target_name}"
MACOSX_BUNDLE_GUI_IDENTIFIER "${target_gui_identifier}"
MACOSX_BUNDLE_GUI_IDENTIFIER "${target_app_namespace}"
MACOSX_BUNDLE_BUNDLE_NAME "${target_name}"
MACOSX_BUNDLE_BUNDLE_VERSION "${target_version}"
MACOSX_BUNDLE_LONG_VERSION_STRING "${target_version}"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${target_version_short}"
#MACOSX_BUNDLE_ICON_FILE "Icon.icns"
MACOSX_BUNDLE_INFO_PLIST "${YUP_ARG_CUSTOM_PLIST}"
#RESOURCE "${RESOURCE_FILES}"
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${target_gui_identifier}"
#XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED OFF
XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT dwarf
XCODE_ATTRIBUTE_GCC_INLINES_ARE_PRIVATE_EXTERN ON
XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME OFF)
MACOSX_BUNDLE_ICON_FILE "${target_iconset_name}"
RESOURCE "${target_resources}"
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${target_gui_identifier}")

endif()

set_target_properties (${target_name} PROPERTIES
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC OFF)
#XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED OFF
XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT dwarf
XCODE_ATTRIBUTE_GCC_INLINES_ARE_PRIVATE_EXTERN ON
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC OFF
XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME OFF)

elseif ("${yup_platform}" MATCHES "^(emscripten)$")
if (NOT "${target_console}")
Expand Down
13 changes: 8 additions & 5 deletions cmake/yup_utilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,10 @@ function (_yup_convert_png_to_icns png_path icons_path output_variable)

# TODO - check png_path has png extension

add_custom_command(
OUTPUT "${output_iconset_path}"
COMMAND mkdir -p "${temp_iconset_name}"
file (MAKE_DIRECTORY "${temp_iconset_path}")

execute_process(
COMMAND mkdir -p "${temp_iconset_path}"
COMMAND sips -z 16 16 -s format png "${png_path}" --out "${temp_iconset_path}/icon_16x16.png"
COMMAND sips -z 32 32 -s format png "${png_path}" --out "${temp_iconset_path}/icon_32x32.png"
COMMAND sips -z 32 32 -s format png "${png_path}" --out "${temp_iconset_path}/[email protected]"
Expand All @@ -238,8 +239,10 @@ function (_yup_convert_png_to_icns png_path icons_path output_variable)
COMMAND sips -z 512 512 -s format png "${png_path}" --out "${temp_iconset_path}/[email protected]"
COMMAND sips -z 512 512 -s format png "${png_path}" --out "${temp_iconset_path}/icon_512x512.png"
COMMAND sips -z 1024 1024 -s format png "${png_path}" --out "${temp_iconset_path}/[email protected]"
COMMAND iconutil -c icns "${temp_iconset_path}"
COMMAND rm -R "${temp_iconset_path}")
COMMAND iconutil -c icns -o "${output_iconset_path}" "${temp_iconset_path}"
ERROR_VARIABLE error_message)

file (REMOVE_RECURSE "${temp_iconset_path}")

set (${output_variable} "${output_iconset_path}" PARENT_SCOPE)
endfunction()
2 changes: 1 addition & 1 deletion modules/yup_graphics/native/yup_GraphicsContext_metal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class LowLevelRenderContextMetal : public GraphicsContext
m_swapchain.framebufferOnly = ! m_fiddleOptions.readableFramebuffer;
m_swapchain.pixelFormat = MTLPixelFormatBGRA8Unorm;
m_swapchain.contentsScale = dpiScale (window);
m_swapchain.displaySyncEnabled = NO;
m_swapchain.displaySyncEnabled = YES;
m_swapchain.maximumDrawableCount = 2;
view.layer = m_swapchain;

Expand Down

0 comments on commit e566d34

Please sign in to comment.