|
1 | 1 | # SPDX-FileCopyrightText: Team OpenVPI |
2 | 2 | # SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
4 | | -add_subdirectory(icons) |
5 | | - |
| 4 | +# The icons of the application and of the project files, written at build time from the images in |
| 5 | +# icons/<name>. The installer of Windows takes the icon of the project files from the resources of |
| 6 | +# the executable, and the bundle of macOS from its resources. Linux uses the images directly. |
6 | 7 | set(_ico_args) |
7 | 8 | set(_icns_args) |
| 9 | +set(_icons) |
8 | 10 |
|
9 | | -if(WIN32) |
10 | | - list(APPEND _ico_path |
11 | | - ${CMAKE_CURRENT_BINARY_DIR}/icons/app.ico |
12 | | - ${CMAKE_CURRENT_BINARY_DIR}/icons/dspx.ico |
13 | | - ) |
14 | | - set(_filtered_ico_path "") |
15 | | - foreach(_file IN LISTS _ico_path) |
16 | | - if(EXISTS ${_file}) |
17 | | - list(APPEND _filtered_ico_path ${_file}) |
18 | | - endif() |
19 | | - endforeach() |
20 | | - set(_ico_args ICO ${_filtered_ico_path}) |
21 | | -endif() |
| 11 | +if(WIN32 OR APPLE) |
| 12 | + find_package(qiconmaker CONFIG REQUIRED) |
| 13 | + include(AddIcon) |
22 | 14 |
|
23 | | -if(APPLE) |
24 | | - set(_icns_path ${CMAKE_CURRENT_BINARY_DIR}/icons/app.icns) |
25 | | - if(EXISTS ${_icns_path}) |
26 | | - set(_icns_args ICNS ${_icns_path}) |
| 15 | + if(WIN32) |
| 16 | + set(_suffix .ico) |
| 17 | + else() |
| 18 | + set(_suffix .icns) |
27 | 19 | endif() |
28 | | -endif() |
29 | 20 |
|
| 21 | + foreach(_name IN ITEMS app dspx) |
| 22 | + set(_icon ${CMAKE_CURRENT_BINARY_DIR}/icons/${_name}${_suffix}) |
| 23 | + add_icon(${_icon} ${CMAKE_CURRENT_SOURCE_DIR}/icons/${_name}) |
| 24 | + list(APPEND _icons ${_icon}) |
| 25 | + endforeach() |
30 | 26 |
|
| 27 | + if(WIN32) |
| 28 | + set(_ico_args ICO ${_icons}) |
| 29 | + else() |
| 30 | + set(_icns_args ICNS ${CMAKE_CURRENT_BINARY_DIR}/icons/app.icns) |
| 31 | + endif() |
| 32 | +endif() |
31 | 33 |
|
32 | 34 | ck_configure_application( |
33 | 35 | ${_ico_args} |
34 | 36 | ${_icns_args} |
35 | 37 | INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/info.plist.in |
36 | 38 | ) |
37 | 39 |
|
| 40 | +if(_icons) |
| 41 | + target_sources(${PROJECT_NAME} PRIVATE ${_icons}) |
| 42 | +endif() |
| 43 | + |
| 44 | +if(APPLE) |
| 45 | + set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/icons/dspx.icns PROPERTIES |
| 46 | + MACOSX_PACKAGE_LOCATION Resources |
| 47 | + ) |
| 48 | +endif() |
| 49 | + |
38 | 50 | qm_configure_target(${PROJECT_NAME} |
39 | 51 | SOURCES main.cpp |
40 | 52 | QT_LINKS_PRIVATE |
@@ -75,19 +87,12 @@ ck_add_shared_files( |
75 | 87 | # SRC conf/${CK_PLATFORM_LOWER}/qtmediate.json DEST ${CK_BUILD_QT_CONF_DIR} # qtmediate.json |
76 | 88 | ) |
77 | 89 |
|
78 | | -if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/icons/dspx.icns) |
79 | | - ck_add_shared_files( |
80 | | - SRC ${CMAKE_CURRENT_BINARY_DIR}/icons/dspx.icns DEST ${CK_BUILD_DATA_DIR} |
81 | | - ) |
82 | | -endif() |
83 | | - |
84 | | -file(GLOB _icons icons/*) |
85 | | -list(FILTER _icons EXCLUDE REGEX CMakeLists.txt) |
| 90 | +file(GLOB _icon_images icons/*) |
86 | 91 |
|
87 | 92 | qt_add_resources(${PROJECT_NAME} icons |
88 | 93 | PREFIX /diffscope/icons |
89 | 94 | BASE icons |
90 | | - FILES ${_icons} |
| 95 | + FILES ${_icon_images} |
91 | 96 | ) |
92 | 97 |
|
93 | 98 | if(LINUX) |
|
0 commit comments