From f63f400787ac42f64fafe006ef19579238067f40 Mon Sep 17 00:00:00 2001 From: "R.J.V. Bertin" Date: Mon, 9 Jan 2017 18:08:19 +0100 Subject: ecm_add_app_icon/Mac: accept SVG icons when KIconThemes is installed KIconThemes comes with a ksvg2icns utility that converts .sgv and .sgvz files to native .icns icon files. Using this utility allows to create icons with optimum resolution regardless of the available .png images and of limitations of the host's iconutil application (limited to 256x256 on some Mac OS versions). REVIEW: 128162 --- modules/ECMAddAppIcon.cmake | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'modules/ECMAddAppIcon.cmake') diff --git a/modules/ECMAddAppIcon.cmake b/modules/ECMAddAppIcon.cmake index 06926800..7207c66e 100644 --- a/modules/ECMAddAppIcon.cmake +++ b/modules/ECMAddAppIcon.cmake @@ -90,6 +90,31 @@ function(ecm_add_app_icon appsources) message(FATAL_ERROR "Unexpected arguments to ecm_add_app_icon: ${ARG_UNPARSED_ARGUMENTS}") endif() + if(APPLE) + find_program(KSVG2ICNS NAMES ksvg2icns) + foreach(icon ${ARG_ICONS}) + get_filename_component(icon_full ${icon} ABSOLUTE) + get_filename_component(icon_type ${icon_full} EXT) + # do we have ksvg2icns in the path and did we receive an svg (or compressed svg) icon? + if(KSVG2ICNS AND (${icon_type} STREQUAL ".svg" OR ${icon_type} STREQUAL ".svgz")) + # convert the svg icon to an icon resource + execute_process(COMMAND ${KSVG2ICNS} "${icon_full}" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} RESULT_VARIABLE KSVG2ICNS_ERROR) + if(${KSVG2ICNS_ERROR}) + message(AUTHOR_WARNING "ksvg2icns could not generate an OS X application icon from ${icon}") + else() + # install the icns file we just created + get_filename_component(icon_name ${icon_full} NAME_WE) + set(MACOSX_BUNDLE_ICON_FILE ${icon_name}.icns PARENT_SCOPE) + set(${appsources} "${${appsources}};${CMAKE_CURRENT_BINARY_DIR}/${icon_name}.icns" PARENT_SCOPE) + set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${icon_name}.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + # we're done now + return() + endif() + endif() + endforeach() + endif() + set(known_sizes 16 32 48 64 128 256 512 1024) foreach(size ${known_sizes}) set(icons_at_${size}px) -- cgit v1.2.1