aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDominik Schmidt <kde@dominik-schmidt.de>2018-06-23 15:26:35 +0200
committerDominik Schmidt <kde@dominik-schmidt.de>2018-07-08 20:00:34 +0200
commit2c2bb8f4766fec5e391839dbc093b638acee3a22 (patch)
tree6e9f761f5aa2a5ae5ddca834b4c17e8d7e5f9dd9 /tests
parentd6cc583f32a4ca0f05ccad8e30cf84b74e9e9561 (diff)
downloadextra-cmake-modules-2c2bb8f4766fec5e391839dbc093b638acee3a22.tar.gz
extra-cmake-modules-2c2bb8f4766fec5e391839dbc093b638acee3a22.tar.bz2
Improve ECMAddAppIconMacro.
Summary: - Add support for SIDEBAR_ICONS on macOS - Allow specifying a basename for the icon file via OUTFILE_BASENAME - Add support for HiRes icons on Windows via icotool I'm sorry this went all into one big change. I see that it's not optimal, but it's really hard to rip it apart... Also to me the whole code with support for two flavors of png2ico and icotool seems very spaghetti-ish. IMHO there's no good reason to keep supporting all three, icotool is the only maintained project and the only one supporting more than 128px wide icons. That's why I would suggest to simplify the whole code by only supporting icotool in one of the next releases. Test Plan: We use this version of ECMAddAppIconMacro in ownCloud client and it works... I tested icotool natively and while cross-compiling on linux. SIDEBAR_ICONS are also working... If you want to test this with the ownCloud client, it's best to use https://github.com/dschmidt/owncloud-client/tree/fix-app-icon-macro because that contains a small fix I just PR'ed and which is not in master yet. (We maintain a fork of the module there, so compiling it for Windows or macOS will automatically use the version of the module that I'm submitting) Reviewers: vonreth, vpinon, apol, alexmerry, cgiboudeaux Reviewed By: cgiboudeaux Subscribers: cgiboudeaux, kde-frameworks-devel, kde-buildsystem Tags: #frameworks, #build_system Differential Revision: https://phabricator.kde.org/D13698
Diffstat (limited to 'tests')
-rw-r--r--tests/ECMAddAppIconTest/128-category-name-sidebar.pngbin0 -> 4111 bytes
-rw-r--r--tests/ECMAddAppIconTest/16-category-name-sidebar.pngbin0 -> 423 bytes
-rw-r--r--tests/ECMAddAppIconTest/CMakeLists.txt51
-rw-r--r--tests/ECMAddAppIconTest/check_files.cmake.in2
4 files changed, 46 insertions, 7 deletions
diff --git a/tests/ECMAddAppIconTest/128-category-name-sidebar.png b/tests/ECMAddAppIconTest/128-category-name-sidebar.png
new file mode 100644
index 00000000..fa32c2a5
--- /dev/null
+++ b/tests/ECMAddAppIconTest/128-category-name-sidebar.png
Binary files differ
diff --git a/tests/ECMAddAppIconTest/16-category-name-sidebar.png b/tests/ECMAddAppIconTest/16-category-name-sidebar.png
new file mode 100644
index 00000000..4d7b7ddb
--- /dev/null
+++ b/tests/ECMAddAppIconTest/16-category-name-sidebar.png
Binary files differ
diff --git a/tests/ECMAddAppIconTest/CMakeLists.txt b/tests/ECMAddAppIconTest/CMakeLists.txt
index dc556c1d..93dfd562 100644
--- a/tests/ECMAddAppIconTest/CMakeLists.txt
+++ b/tests/ECMAddAppIconTest/CMakeLists.txt
@@ -8,18 +8,57 @@ set(CMAKE_MODULE_PATH
include(ECMAddAppIcon)
-set(ICONS 16-category-name.png 128-category-name.png)
+if(WIN32)
+ set(icon_extension_to_test "rc")
+elseif(APPLE)
+ set(icon_extension_to_test "icns")
+endif()
+
+#### Test 1: ecm_add_app_icon with only regular icons and no OUTFILE_BASENAME ####
+set(ICONS_1 16-category-name.png 128-category-name.png)
+ecm_add_app_icon(OUT_1 ICONS ${ICONS_1})
+
+if(WIN32 OR APPLE)
+ list(LENGTH OUT_1 out_count)
+ if(out_count EQUAL 0)
+ message(FATAL_ERROR "ecm_add_app_icon() hasn't produced anything")
+ endif()
+
+
+ if(NOT OUT_1 MATCHES "OUT_1.${icon_extension_to_test}")
+ message(FATAL_ERROR "ecm_add_app_icon() did not fall back to target name for icon name: ${OUT_1}")
+ endif()
+endif()
+
+add_custom_target(t_1 ALL DEPENDS ${OUT_1})
+list(APPEND OUT "${OUT_1}")
+
+#### Test 2: ecm_add_app_icon with regular and sidebar icons and OUTFILE_BASENAME set ####
+set(ICONS_2 16-category-name.png 128-category-name.png)
+set(SIDEBAR_ICONS_2 16-category-name-sidebar.png 128-category-name-sidebar.png)
-ecm_add_app_icon(OUT ICONS ${ICONS})
+ecm_add_app_icon(OUT_2 ICONS ${ICONS_2} SIDEBAR_ICONS ${SIDEBAR_ICONS_2} OUTFILE_BASENAME "SuperBasename")
if(WIN32 OR APPLE)
- list(LENGTH OUT out_count)
+ list(LENGTH OUT_2 out_count)
if(out_count EQUAL 0)
- message(FATAL_ERROR "ecm_add_app_icon() haven't produced anything")
+ message(FATAL_ERROR "ecm_add_app_icon() hasn't produced anything")
endif()
+
+ if(NOT OUT_2 MATCHES "SuperBasename.${icon_extension_to_test}")
+ message(FATAL_ERROR "ecm_add_app_icon() did not respect OUTFILE_BASENAME: ${OUT_2}")
+ endif()
+endif()
+
+if(APPLE)
+ list(APPEND expected_icons "icon_16x16.png" "icon_128x128.png" "sidebar_16x16.png" "sidebar_32x32.png")
+ foreach(expected_icon ${expected_icons})
+ list(APPEND OUT_2 "${CMAKE_CURRENT_BINARY_DIR}/SuperBasename.iconset/${expected_icon}")
+ endforeach()
endif()
-add_custom_target(t ALL DEPENDS ${OUT})
+add_custom_target(t_2 ALL DEPENDS ${OUT_2})
+list(APPEND OUT "${OUT_2}")
-# this will be run by CTest
+#### this will be run by CTest ####
configure_file(check_files.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/check_files.cmake" @ONLY)
diff --git a/tests/ECMAddAppIconTest/check_files.cmake.in b/tests/ECMAddAppIconTest/check_files.cmake.in
index e7beb272..09f98315 100644
--- a/tests/ECMAddAppIconTest/check_files.cmake.in
+++ b/tests/ECMAddAppIconTest/check_files.cmake.in
@@ -6,4 +6,4 @@ foreach(f ${FILES})
message(SEND_ERROR "${f} was not found")
endif()
endforeach()
-endif() \ No newline at end of file
+endif()