Warning, /frameworks/extra-cmake-modules/tests/ECMAddAppIconTest/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 cmake_minimum_required(VERSION 3.5)
0002 project(ECMAddAppIconTest)
0003
0004 set(CMAKE_MODULE_PATH
0005 ${CMAKE_CURRENT_SOURCE_DIR}/../../modules
0006 ${CMAKE_CURRENT_SOURCE_DIR}/../../find-modules
0007 )
0008
0009 include(ECMAddAppIcon)
0010
0011 if(WIN32)
0012 set(icon_extension_to_test "rc")
0013 elseif(APPLE)
0014 set(icon_extension_to_test "icns")
0015 endif()
0016
0017 #### Test 1: ecm_add_app_icon with only regular icons and no OUTFILE_BASENAME, for sources var ####
0018 set(ICONS_1 16-category-name.png 128-category-name.png)
0019 ecm_add_app_icon(OUT_1 ICONS ${ICONS_1})
0020
0021 list(LENGTH OUT_1 out_count)
0022
0023 if(WIN32 OR APPLE)
0024 if(out_count EQUAL 0)
0025 message(FATAL_ERROR "ecm_add_app_icon() hasn't produced anything")
0026 endif()
0027
0028 if(NOT OUT_1 MATCHES "OUT_1.${icon_extension_to_test}")
0029 message(FATAL_ERROR "ecm_add_app_icon() did not fall back to target name for icon name: ${OUT_1}")
0030 endif()
0031 else()
0032 if(NOT out_count EQUAL 0)
0033 message(FATAL_ERROR "ecm_add_app_icon() produced something unexpectedly.")
0034 endif()
0035 endif()
0036
0037 add_custom_target(t_1 ALL DEPENDS ${OUT_1})
0038 list(APPEND OUT "${OUT_1}")
0039
0040 #### Test 2: ecm_add_app_icon with regular and sidebar icons and OUTFILE_BASENAME set, for sources var ####
0041 set(ICONS_2 16-category-name.png 128-category-name.png)
0042 set(SIDEBAR_ICONS_2 16-category-name-sidebar.png 128-category-name-sidebar.png)
0043
0044 ecm_add_app_icon(OUT_2 ICONS ${ICONS_2} SIDEBAR_ICONS ${SIDEBAR_ICONS_2} OUTFILE_BASENAME "SuperBasename")
0045
0046 list(LENGTH OUT_2 out_count)
0047
0048 if(WIN32 OR APPLE)
0049 if(out_count EQUAL 0)
0050 message(FATAL_ERROR "ecm_add_app_icon() hasn't produced anything")
0051 endif()
0052
0053 if(NOT OUT_2 MATCHES "SuperBasename.${icon_extension_to_test}")
0054 message(FATAL_ERROR "ecm_add_app_icon() did not respect OUTFILE_BASENAME: ${OUT_2}")
0055 endif()
0056 else()
0057 if(NOT out_count EQUAL 0)
0058 message(FATAL_ERROR "ecm_add_app_icon() produced something unexpectedly.")
0059 endif()
0060 endif()
0061
0062 if(APPLE)
0063 list(APPEND expected_icons "icon_16x16.png" "icon_128x128.png" "sidebar_16x16.png" "sidebar_32x32.png")
0064 foreach(expected_icon ${expected_icons})
0065 list(APPEND OUT_2 "${CMAKE_CURRENT_BINARY_DIR}/SuperBasename.iconset/${expected_icon}")
0066 endforeach()
0067 endif()
0068
0069 add_custom_target(t_2 ALL DEPENDS ${OUT_2})
0070 list(APPEND OUT "${OUT_2}")
0071
0072 #### Test 3: ecm_add_app_icon with only regular icons and no OUTFILE_BASENAME, for target ####
0073 set(ICONS_3 16-category-name.png 128-category-name.png)
0074
0075 add_executable(app_3)
0076 target_sources(app_3 PRIVATE main.cpp)
0077
0078 ecm_add_app_icon(app_3 ICONS ${ICONS_1})
0079
0080 get_target_property(OUT_3 app_3 SOURCES)
0081 list(REMOVE_ITEM OUT_3 main.cpp)
0082 list(LENGTH OUT_3 out_count)
0083
0084 if(WIN32 OR APPLE)
0085 if(out_count EQUAL 0)
0086 message(FATAL_ERROR "ecm_add_app_icon() hasn't produced anything")
0087 endif()
0088
0089 if(NOT OUT_3 MATCHES "app_3.${icon_extension_to_test}")
0090 message(FATAL_ERROR "ecm_add_app_icon() did not fall back to target name for icon name: ${OUT_1}")
0091 endif()
0092 else()
0093 if(NOT out_count EQUAL 0)
0094 message(FATAL_ERROR "ecm_add_app_icon() produced something unexpectedly.")
0095 endif()
0096 endif()
0097
0098 list(APPEND OUT "${OUT_3}")
0099
0100 #### Test 4: ecm_add_app_icon with regular and sidebar icons and OUTFILE_BASENAME set, for target ####
0101 set(ICONS_4 16-category-name.png 128-category-name.png)
0102 set(SIDEBAR_ICONS_4 16-category-name-sidebar.png 128-category-name-sidebar.png)
0103
0104 add_executable(app_4)
0105 target_sources(app_4 PRIVATE main.cpp)
0106
0107 ecm_add_app_icon(app_4 ICONS ${ICONS_4} SIDEBAR_ICONS ${SIDEBAR_ICONS_4} OUTFILE_BASENAME "SuperBasename4")
0108
0109 get_target_property(OUT_4 app_4 SOURCES)
0110 list(REMOVE_ITEM OUT_4 main.cpp)
0111 list(LENGTH OUT_4 out_count)
0112
0113 if(WIN32 OR APPLE)
0114 if(out_count EQUAL 0)
0115 message(FATAL_ERROR "ecm_add_app_icon() hasn't produced anything")
0116 endif()
0117
0118 if(NOT OUT_4 MATCHES "SuperBasename4.${icon_extension_to_test}")
0119 message(FATAL_ERROR "ecm_add_app_icon() did not respect OUTFILE_BASENAME: ${OUT_4}")
0120 endif()
0121 else()
0122 if(NOT out_count EQUAL 0)
0123 message(FATAL_ERROR "ecm_add_app_icon() produced something unexpectedly.")
0124 endif()
0125 endif()
0126
0127 if(APPLE)
0128 list(APPEND expected_icons "icon_16x16.png" "icon_128x128.png" "sidebar_16x16.png" "sidebar_32x32.png")
0129 foreach(expected_icon ${expected_icons})
0130 list(APPEND OUT_4 "${CMAKE_CURRENT_BINARY_DIR}/SuperBasename4.iconset/${expected_icon}")
0131 endforeach()
0132 endif()
0133
0134 list(APPEND OUT "${OUT_4}")
0135
0136 #### this will be run by CTest ####
0137 configure_file(check_files.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/check_files.cmake" @ONLY)