Add patch to use convert to generate icon
authorAndre Heinecke <aheinecke@intevation.de>
Thu, 4 Feb 2016 10:40:26 +0000 (11:40 +0100)
committerAndre Heinecke <aheinecke@intevation.de>
Thu, 4 Feb 2016 10:40:26 +0000 (11:40 +0100)
* Makefile.am (EXTRA_DIST): Add patch.
* patches/extra-cmake-modules/
 0001-Add-convert-utility-support-for-Windows-icons.patch: New.

--
Convert is more readily available in most distributions
then png2ico. Convert also does not have the 128px size restriction.

Makefile.am
patches/extra-cmake-modules/0001-Add-convert-utility-support-for-Windows-icons.patch [new file with mode: 0755]

index e372e4f..1d68d5a 100644 (file)
@@ -45,7 +45,8 @@ EXTRA_DIST = autogen.sh README.GIT ONEWS \
         patches/kconfigwidgets/0001-Make-QDbus-optional.patch \
         patches/kconfigwidgets/0002-Crudely-remove-KF5Auth-depedency.patch \
         patches/kiconthemes/0001-Make-DBus-optional.patch \
-        patches/qtsvg/qtsvg-link-zlib.patch
+        patches/qtsvg/qtsvg-link-zlib.patch \
+        patches/extra-cmake-modules/0001-Add-convert-utility-support-for-Windows-icons.patch
 
 copy-news:
        cp NEWS doc/website/NEWS.last
diff --git a/patches/extra-cmake-modules/0001-Add-convert-utility-support-for-Windows-icons.patch b/patches/extra-cmake-modules/0001-Add-convert-utility-support-for-Windows-icons.patch
new file mode 100755 (executable)
index 0000000..27e8e1a
--- /dev/null
@@ -0,0 +1,143 @@
+#! /bin/sh
+patch -p1 -l -f $* < $0
+exit $?
+
+From 9032d5c41ada1c50eddf6ea5562887af7a941aa9 Mon Sep 17 00:00:00 2001
+From: Andre Heinecke <aheinecke@intevation.de>
+Date: Thu, 4 Feb 2016 11:00:31 +0100
+Subject: [PATCH] Add convert utility support for Windows icons
+
+---
+ find-modules/FindConvert.cmake | 66 ++++++++++++++++++++++++++++++++++++++++++
+ modules/ECMAddAppIcon.cmake    | 27 +++++++++++++----
+ 2 files changed, 88 insertions(+), 5 deletions(-)
+ create mode 100644 find-modules/FindConvert.cmake
+
+diff --git a/find-modules/FindConvert.cmake b/find-modules/FindConvert.cmake
+new file mode 100644
+index 0000000..a723c37
+--- /dev/null
++++ b/find-modules/FindConvert.cmake
+@@ -0,0 +1,66 @@
++#.rst:
++# FindConvert
++# -----------
++#
++# Try to find convert.
++#
++# If the convert executable is not in your PATH, you can provide
++# an alternative name or full path location with the ``Convert_EXECUTABLE``
++# variable.
++#
++#=============================================================================
++# Copyright 2016 Intevation GmbH <intevation@intevation.org>
++#
++# Redistribution and use in source and binary forms, with or without
++# modification, are permitted provided that the following conditions
++# are met:
++#
++# 1. Redistributions of source code must retain the copyright
++#    notice, this list of conditions and the following disclaimer.
++# 2. Redistributions in binary form must reproduce the copyright
++#    notice, this list of conditions and the following disclaimer in the
++#    documentation and/or other materials provided with the distribution.
++# 3. The name of the author may not be used to endorse or promote products
++#    derived from this software without specific prior written permission.
++#
++# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
++# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
++# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
++# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
++# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
++# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
++# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++
++include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
++
++ecm_find_package_version_check(Convert)
++
++find_program(Convert_EXECUTABLE NAMES convert)
++
++include(FindPackageHandleStandardArgs)
++find_package_handle_standard_args(Convert
++    FOUND_VAR
++        Convert_FOUND
++    REQUIRED_VARS
++        Convert_EXECUTABLE
++)
++
++mark_as_advanced(Convert_EXECUTABLE)
++
++if (Convert_FOUND)
++    if (NOT TARGET Convert::Convert)
++        add_executable(Convert::Convert IMPORTED)
++        set_target_properties(Convert::Convert PROPERTIES
++            IMPORTED_LOCATION "${Convert_EXECUTABLE}"
++        )
++    endif()
++endif()
++
++include(FeatureSummary)
++set_package_properties(Convert PROPERTIES
++    URL "http://www.imagemagick.org/"
++    DESCRIPTION "Generic image format conversion tool from imagemagick."
++)
+diff --git a/modules/ECMAddAppIcon.cmake b/modules/ECMAddAppIcon.cmake
+index 5233a5f..2b5dca1 100644
+--- a/modules/ECMAddAppIcon.cmake
++++ b/modules/ECMAddAppIcon.cmake
+@@ -128,10 +128,22 @@ function(ecm_add_app_icon appsources)
+     if (WIN32 AND windows_icons)
+         set(saved_CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}")
+         set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_FIND_MODULE_DIR})
+-        find_package(Png2Ico)
++        find_package(Convert)
++        if (NOT Convert_FOUND)
++            find_package(Png2Ico)
++        endif()
+         set(CMAKE_MODULE_PATH "${saved_CMAKE_MODULE_PATH}")
+
+-        if (Png2Ico_FOUND)
++        if (Convert_FOUND)
++            set(windows_icons ${windows_icons} ${icons_at_256px})
++            add_custom_command(
++                OUTPUT "${_outfilename}.ico"
++                COMMAND Convert::Convert
++                ARGS ${windows_icons} "${_outfilename}.ico"
++                DEPENDS ${windows_icons}
++                WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
++            )
++        elseif (Png2Ico_FOUND)
+             if (Png2Ico_HAS_RCFILE_ARGUMENT)
+                 add_custom_command(
+                     OUTPUT "${_outfilename}.rc" "${_outfilename}.ico"
+@@ -151,6 +163,14 @@ function(ecm_add_app_icon appsources)
+                     DEPENDS ${windows_icons}
+                     WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+                 )
++            endif()
++        else()
++            message(WARNING "Unable to find the png2ico or convert utility - application will not have an application icon!")
++        endif()
++
++        if (Convert_FOUND OR Png2Ico_FOUND)
++            set(${appsources} "${${appsources}};${_outfilename}.rc" PARENT_SCOPE)
++            if (NOT Png2Ico_HAS_RCFILE_ARGUMENT)
+                 # this bit's a little hacky to make the dependency stuff work
+                 file(WRITE "${_outfilename}.rc.in" "IDI_ICON1        ICON        DISCARDABLE    \"${_outfilename}.ico\"\n")
+                 add_custom_command(
+@@ -161,9 +181,6 @@ function(ecm_add_app_icon appsources)
+                     WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+                 )
+             endif()
+-            set(${appsources} "${${appsources}};${_outfilename}.rc" PARENT_SCOPE)
+-        else()
+-            message(WARNING "Unable to find the png2ico utility - application will not have an application icon!")
+         endif()
+     elseif (APPLE AND mac_icons)
+         # first generate .iconset directory structure, then convert to .icns format using the Mac OS X "iconutil" utility,
+--
+2.1.4