diff options
author | R.J.V. Bertin <rjvbertin@gmail.com> | 2017-01-09 18:08:19 +0100 |
---|---|---|
committer | R.J.V. Bertin <rjvbertin@gmail.com> | 2017-01-09 18:08:19 +0100 |
commit | f63f400787ac42f64fafe006ef19579238067f40 (patch) | |
tree | fc494e3a24e4d8d2f3ddc88792acb8d8f220f3b5 | |
parent | 9de6d0c3b642fc337cb144db51ff9a97c6cd0044 (diff) | |
download | extra-cmake-modules-f63f400787ac42f64fafe006ef19579238067f40.tar.gz extra-cmake-modules-f63f400787ac42f64fafe006ef19579238067f40.tar.bz2 |
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
-rw-r--r-- | modules/ECMAddAppIcon.cmake | 25 |
1 files changed, 25 insertions, 0 deletions
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) |