Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions cmake/AddIcon.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# SPDX-FileCopyrightText: Team OpenVPI
# SPDX-License-Identifier: Apache-2.0

# Icons written at build time by qiconmaker (https://github.com/stdware/qiconmaker) from images,
# so that the repository keeps the images rather than the icon files. The package qiconmaker is
# found before this file is included.

# Qt Core for the directory of its DLLs, which qiconmaker loads on Windows
qm_find_qt(Core)

# add_icon(<output> <directory>)
#
# Writes the icon <output>, an .ico of Windows or an .icns of macOS by its suffix, from the images
# <directory>/<size>x<size>.png in a custom command. The image of 1024 px is the master image. A
# size of the format that has an image of its own takes that image, and qiconmaker reduces the
# master image to every other size. A target of the same directory that lists <output> as a source
# builds the icon first, and qm_add_win_rc_enhanced() and qm_add_mac_bundle() of qmsetup accept it.
function(add_icon _output _directory)
set(_master "${_directory}/1024x1024.png")
set(_arguments "${_output}" "${_master}")
set(_depends "${_master}")

# The sizes that qiconmaker writes for each format by default
if(_output MATCHES "\\.icns$")
set(_sizes 16 32 64 128 256 512)
else()
set(_sizes 16 20 24 30 32 36 40 48 60 64 72 80 96 256)
endif()

foreach(_size IN LISTS _sizes)
set(_file "${_directory}/${_size}x${_size}.png")
if(EXISTS "${_file}")
list(APPEND _arguments "${_size}=${_file}")
list(APPEND _depends "${_file}")
endif()
endforeach()

# The program loads the DLLs of Qt, which Windows finds through PATH. On the other systems the
# program holds the run path to the libraries of Qt.
set(_command $<TARGET_FILE:qiconmaker::qiconmaker>)
if(WIN32)
set(_command ${CMAKE_COMMAND} -E env "PATH=$<TARGET_FILE_DIR:Qt6::Core>" ${_command})
endif()
add_custom_command(OUTPUT "${_output}"
COMMAND ${_command} ${_arguments}
DEPENDS ${_depends}
COMMENT "Writing ${_output}"
VERBATIM
)
endfunction()
6 changes: 5 additions & 1 deletion scripts/vcpkg-manifest/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@
},
"xxhash",
"signalsmith-dsp",
"rubberband"
"rubberband",
{
"name": "qiconmaker",
"platform": "windows | osx"
}
],
"vcpkg-configuration": {
"overlay-ports": [
Expand Down
63 changes: 34 additions & 29 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@
# SPDX-FileCopyrightText: Team OpenVPI
# SPDX-License-Identifier: Apache-2.0

add_subdirectory(icons)

# The icons of the application and of the project files, written at build time from the images in
# icons/<name>. The installer of Windows takes the icon of the project files from the resources of
# the executable, and the bundle of macOS from its resources. Linux uses the images directly.
set(_ico_args)
set(_icns_args)
set(_icons)

if(WIN32)
list(APPEND _ico_path
${CMAKE_CURRENT_BINARY_DIR}/icons/app.ico
${CMAKE_CURRENT_BINARY_DIR}/icons/dspx.ico
)
set(_filtered_ico_path "")
foreach(_file IN LISTS _ico_path)
if(EXISTS ${_file})
list(APPEND _filtered_ico_path ${_file})
endif()
endforeach()
set(_ico_args ICO ${_filtered_ico_path})
endif()
if(WIN32 OR APPLE)
find_package(qiconmaker CONFIG REQUIRED)
include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/AddIcon.cmake)

if(APPLE)
set(_icns_path ${CMAKE_CURRENT_BINARY_DIR}/icons/app.icns)
if(EXISTS ${_icns_path})
set(_icns_args ICNS ${_icns_path})
if(WIN32)
set(_suffix .ico)
else()
set(_suffix .icns)
endif()
endif()

foreach(_name IN ITEMS app dspx)
set(_icon ${CMAKE_CURRENT_BINARY_DIR}/icons/${_name}${_suffix})
add_icon(${_icon} ${CMAKE_CURRENT_SOURCE_DIR}/icons/${_name})
list(APPEND _icons ${_icon})
endforeach()

if(WIN32)
set(_ico_args ICO ${_icons})
else()
set(_icns_args ICNS ${CMAKE_CURRENT_BINARY_DIR}/icons/app.icns)
endif()
endif()

ck_configure_application(
${_ico_args}
${_icns_args}
INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/info.plist.in
)

if(_icons)
target_sources(${PROJECT_NAME} PRIVATE ${_icons})
endif()

if(APPLE)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/icons/dspx.icns PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
endif()

qm_configure_target(${PROJECT_NAME}
SOURCES main.cpp
QT_LINKS_PRIVATE
Expand Down Expand Up @@ -75,19 +87,12 @@ ck_add_shared_files(
# SRC conf/${CK_PLATFORM_LOWER}/qtmediate.json DEST ${CK_BUILD_QT_CONF_DIR} # qtmediate.json
)

if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/icons/dspx.icns)
ck_add_shared_files(
SRC ${CMAKE_CURRENT_BINARY_DIR}/icons/dspx.icns DEST ${CK_BUILD_DATA_DIR}
)
endif()

file(GLOB _icons icons/*)
list(FILTER _icons EXCLUDE REGEX CMakeLists.txt)
file(GLOB _icon_images icons/*)

qt_add_resources(${PROJECT_NAME} icons
PREFIX /diffscope/icons
BASE icons
FILES ${_icons}
FILES ${_icon_images}
)

if(LINUX)
Expand Down
129 changes: 0 additions & 129 deletions src/app/icons/CMakeLists.txt

This file was deleted.

Loading