From 6db4b8821edafc0b963021abc74ffa1378300b27 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 2 Nov 2023 03:05:46 +0400 Subject: [PATCH] Add support for building iconset and plist without Xcode --- Telegram/CMakeLists.txt | 46 +++++++++++++++++++++++++++++++++++++++-- Telegram/Telegram.plist | 16 ++++++++------ 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 95ac565a6..3bfaa0b15 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -1540,7 +1540,39 @@ elseif (APPLE) endif() set(icons_path ${CMAKE_CURRENT_SOURCE_DIR}/Telegram/Images.xcassets) - target_add_resource(Telegram ${icons_path}) + if (CMAKE_GENERATOR STREQUAL Xcode) + target_add_resource(Telegram ${icons_path}) + else() + set(icon_path ${icons_path}/Icon.iconset) + find_program(ICONUTIL iconutil) + find_program(PNG2ICNS png2icns) + if (ICONUTIL) + add_custom_command( + OUTPUT Icon.icns + COMMAND ${ICONUTIL} + ARGS + --convert icns + --output Icon.icns + ${icon_path} + ) + elseif (PNG2ICNS) + add_custom_command( + OUTPUT Icon.icns + COMMAND ${PNG2ICNS} + ARGS + Icon.icns + ${icon_path}/icon_16x16.png + ${icon_path}/icon_32x32.png + ${icon_path}/icon_128x128.png + ${icon_path}/icon_256x256.png + ${icon_path}/icon_512x512.png + ) + endif() + if (ICONUTIL OR PNG2ICNS) + set_source_files_properties(Icon.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + target_add_resource(Telegram Icon.icns) + endif() + endif() set(lang_packs en @@ -1633,7 +1665,11 @@ if (build_macstore) COMMAND rm -rf $/../Frameworks/Breakpad.framework/Resources/Inspector ) else() - set(bundle_identifier "com.tdesktop.Telegram$<$:Debug>") + if (CMAKE_GENERATOR STREQUAL Xcode) + set(bundle_identifier "com.tdesktop.Telegram$<$:Debug>") + else() + set(bundle_identifier "com.tdesktop.Telegram") + endif() set(bundle_entitlements "Telegram.entitlements") if (LINUX AND DESKTOP_APP_USE_PACKAGED) set(output_name "telegram-desktop") @@ -1642,6 +1678,12 @@ else() endif() endif() +if (CMAKE_GENERATOR STREQUAL Xcode) + set(bundle_identifier_plist "$(PRODUCT_BUNDLE_IDENTIFIER)") +else() + set(bundle_identifier_plist ${bundle_identifier}) +endif() + set_target_properties(Telegram PROPERTIES OUTPUT_NAME ${output_name} MACOSX_BUNDLE_GUI_IDENTIFIER ${bundle_identifier} diff --git a/Telegram/Telegram.plist b/Telegram/Telegram.plist index ea6395228..53b8daf8b 100644 --- a/Telegram/Telegram.plist +++ b/Telegram/Telegram.plist @@ -3,15 +3,19 @@ CFBundleExecutable - $(PRODUCT_NAME) + @output_name@ CFBundleGetInfoString Telegram Desktop messaging app + CFBundleIconFile + Icon.icns + CFBundleIconName + Icon.icns CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) + @bundle_identifier_plist@ CFBundlePackageType APPL CFBundleShortVersionString - $(CURRENT_PROJECT_VERSION) + @desktop_app_version_string@ CFBundleSignature ???? CFBundleURLTypes @@ -22,7 +26,7 @@ CFBundleURLIconFile Icon.icns CFBundleURLName - $(PRODUCT_BUNDLE_IDENTIFIER) + @bundle_identifier_plist@ CFBundleURLSchemes tg @@ -30,13 +34,13 @@ CFBundleVersion - $(CURRENT_PROJECT_VERSION) + @desktop_app_version_string@ ITSAppUsesNonExemptEncryption LSApplicationCategoryType public.app-category.social-networking LSMinimumSystemVersion - $(MACOSX_DEPLOYMENT_TARGET) + @CMAKE_OSX_DEPLOYMENT_TARGET@ LSFileQuarantineEnabled NOTE