Am 26.11.2014 um 22:52 schrieb Laurent Navet: > Hi, >>> On Friday 20 December 2013 14:59:45 Michal Humpula wrote: >>>> Hi there, >>>> >>>> I was wondering if there is a recommended migration path from >>>> KDE4_ADD_APP_ICON cmake makro. >>> This stuff is indeed missing on >>> http://techbase.kde.org/Development/ECM_SourceIncompatChanges .... >>> >>> Moving the discussion to kde-buildsystem. > Regarding this thread : > http://mail.kde.org/pipermail/kde-buildsystem/2014-August/010318.html it > seems there is no replacement for this macro. > > kde4_add_app_icon is the last that prevent us from completly dropping > KDELibs4Support from klettres. > > Is there any news on this ? Or should we remove it ? Append is a related cmake file migrated from KDE 4. Not sure, if it works as expected.
Ralf
>From 050a123f94a84ef625999cd96b6c3df55d270253 Mon Sep 17 00:00:00 2001 From: Ralf Habacker <ralf.habac...@freenet.de> Date: Mon, 20 Oct 2014 19:50:06 +0200 Subject: [PATCH 2/2] Introduce ECMAddAppIcon. This module, which has been migrated from the related KDE4 macto kde4_app_app_icon, supports platform specific application icon for Windows and Mac OSX. On Windows this function depends on the external tool png2ico, which is provided by the kdewin-tools binary package, sources are available at https://projects.kde.org/projects/kdesupport/kdewin. --- modules/ECMAddAppIcon.cmake | 137 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 modules/ECMAddAppIcon.cmake diff --git a/modules/ECMAddAppIcon.cmake b/modules/ECMAddAppIcon.cmake new file mode 100644 index 0000000..4c0a04e --- /dev/null +++ b/modules/ECMAddAppIcon.cmake @@ -0,0 +1,137 @@ +#.rst: +# ECMAddAppIcon +# ------------- +# +# ecm_add_app_icon(SRCS_VAR pattern) +# +# Adds an application icon to target source list. +# Make sure you have a 128x128 icon, or the icon won't display on Mac OS X. +# Mac OSX notes : the application icon is added to a Mac OS X bundle so that Finder and friends show the right thing. +# Win32 notes: the application icon(s) are compiled into the application +# Parameters: +# SRCS_VAR - specifies the list of source files +# pattern - regular expression for searching application icons +# +# example: ecm_app_app_icon(myapp_SRCS "pics/cr16-myapp.png;pics/cr32-myapp.png") + +#============================================================================= +# Copyright (c) 2006-2009 Alexander Neundorf, <neund...@kde.org> +# Copyright (c) 2006, 2007, Laurent Montel, <mon...@kde.org> +# Copyright (c) 2007 Matthias Kretz <kr...@kde.org> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file COPYING-CMAKE-SCRIPTS for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of extra-cmake-modules, substitute the full +# License text for the above reference.) + +function(ecm_add_app_icon appsources pattern) + set (_outfilename ${CMAKE_CURRENT_BINARY_DIR}/${appsources}) + + if (WIN32) + if(NOT WINCE) + find_program(PNG2ICO_EXECUTABLE NAMES png2ico) + else(NOT WINCE) + find_program(PNG2ICO_EXECUTABLE NAMES png2ico PATHS ${HOST_BINDIR} NO_DEFAULT_PATH ) + endif(NOT WINCE) + if (PNG2ICO_EXECUTABLE) + string(REPLACE "*" "(.*)" pattern_rx "${pattern}") + file(GLOB files "${pattern}") + foreach (it ${files}) + string(REGEX REPLACE "${pattern_rx}" "\\1" fn "${it}") + if (fn MATCHES ".*16.*" ) + list (APPEND _icons ${it}) + endif (fn MATCHES ".*16.*") + if (fn MATCHES ".*32.*" ) + list (APPEND _icons ${it}) + endif (fn MATCHES ".*32.*") + if (fn MATCHES ".*48.*" ) + list (APPEND _icons ${it}) + endif (fn MATCHES ".*48.*") + if (fn MATCHES ".*64.*" ) + list (APPEND _icons ${it}) + endif (fn MATCHES ".*64.*") + if (fn MATCHES ".*128.*" ) + list (APPEND _icons ${it}) + endif (fn MATCHES ".*128.*") + endforeach (it) + if (_icons) + add_custom_command(OUTPUT ${_outfilename}.ico ${_outfilename}.rc + COMMAND ${PNG2ICO_EXECUTABLE} ARGS --rcfile ${_outfilename}.rc ${_outfilename}.ico ${_icons} + DEPENDS ${PNG2ICO_EXECUTABLE} ${_icons} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + list(APPEND ${appsources} ${_outfilename}.rc) + else(_icons) + message(STATUS "Unable to find a related icon that matches pattern ${pattern} for variable ${appsources} - application will not have an application icon!") + endif(_icons) + else(PNG2ICO_EXECUTABLE) + message(STATUS "Unable to find the png2ico utility - application will not have an application icon!") + endif(PNG2ICO_EXECUTABLE) + endif(WIN32) + if (Q_WS_MAC) + # first generate .iconset directory structure, then convert to .icns format using the Mac OS X "iconutil" utility, + # to create retina compatible icon, you need png source files in pixel resolution 16x16, 32x32, 64x64, 128x128, + # 256x256, 512x512, 1024x1024 + find_program(ICONUTIL_EXECUTABLE NAMES iconutil) + if (ICONUTIL_EXECUTABLE) + file(GLOB_RECURSE files "${pattern}") + add_custom_command(OUTPUT ${_outfilename}.iconset + COMMAND ${CMAKE_COMMAND} -E make_directory ${_outfilename}.iconset + DEPENDS ${files} + ) + set(_icons) + macro(copy_icons _pattern output) + foreach(it ${files}) + if(it MATCHES ${_pattern}) + add_custom_command(OUTPUT ${_outfilename}.iconset/icon_${output}.png + COMMAND ${CMAKE_COMMAND} -E copy ${it} icon_${output}.png + WORKING_DIRECTORY ${_outfilename}.iconset + DEPENDS ${_outfilename}.iconset + ) + list(APPEND _icons ${_outfilename}.iconset/icon_${output}.png) + endif(it MATCHES ${_pattern}) + endforeach(it ${files}) + endmacro(copy_icons) + + copy_icons(".*16.*" "16x16") + copy_icons(".*32.*" "16x16@2x") + copy_icons(".*32.*" "32x32") + copy_icons(".*64.*" "32x32@2x") + copy_icons(".*128.*" "128x128") + copy_icons(".*256.*" "128x128@2x") + copy_icons(".*256.*" "256x256") + copy_icons(".*512.*" "256x256@2x") + copy_icons(".*512.*" "512x512") + copy_icons(".*1024.*" "512x512@2x") + if (_icons) + # generate .icns icon file + add_custom_command(OUTPUT ${_outfilename}.icns + COMMAND ${ICONUTIL_EXECUTABLE} --convert icns + --output ${_outfilename}.icns ${_outfilename}.iconset + DEPENDS ${_icons} + ) + # This will register the icon into the bundle + set(MACOSX_BUNDLE_ICON_FILE ${appsources}.icns) + + # Append the icns file to the sources list so it will be a dependency to the + # main target + list(APPEND ${appsources} ${_outfilename}.icns) + + # Install the icon into the Resources dir in the bundle + set_source_files_properties(${_outfilename}.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + else(_icons) + message(STATUS "Unable to find an icon that matches pattern ${pattern} + for variable ${appsources} - application will not have an + application icon! + ") + endif(_icons) + else(ICONUTIL_EXECUTABLE) + message(STATUS "Unable to find the iconutil utility - application will not have an application icon!") + endif(ICONUTIL_EXECUTABLE) + endif(Q_WS_MAC) +endfunction() -- 1.8.4.5
_______________________________________________ Kde-buildsystem mailing list Kde-buildsystem@kde.org https://mail.kde.org/mailman/listinfo/kde-buildsystem