Skip to content

Commit

Permalink
Add Windows ico support
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed Feb 7, 2025
1 parent 5be209f commit 973cbc7
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 271 deletions.
19 changes: 2 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,8 @@ SET(LMMS_SOURCE_DIR ${CMAKE_SOURCE_DIR})
# Import of windows.h breaks min()/max()
ADD_DEFINITIONS(-DNOMINMAX)

file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/branding")
file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/lmms.iconset")

include(SvgRecolor)
set(svg_green "#27ab5f;#249a56;#34d07b;opacity=\".1\" fill=\"#fff\"")
set(svg_blue "#3992cb;#2b6fc5;#62a8d4;opacity=\".1\" fill=\"#fff\"")
set(svg_purple "#5547bd;#493ba1;#7871c5;opacity=\".05\" fill=\"#fff\"")

svg_recolor(svg_green svg_purple "${CMAKE_SOURCE_DIR}/cmake/linux/icons/scalable/apps/lmms.svg" svg_recolored)

include(SvgConvert)
svg_convert("16;16@2;32;32@2;48;48@2" "${svg_recolored}" "${CMAKE_CURRENT_BINARY_DIR}/branding/%size%x%size%@%mult%/%name%.png")

include(IcnsConvert)
icns_convert("${svg_recolored}" "${CMAKE_CURRENT_BINARY_DIR}/lmms.icns")

message(FATAL_ERROR "Done")
### FIXME: REMOVE!
add_subdirectory(cmake/branding)

# CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES is not set correctly for MinGW until
# CMake 3.14.1, so avoid specifying system include directories on affected
Expand Down
9 changes: 7 additions & 2 deletions cmake/apple/MacDeployQt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@ list(REVERSE mime_parts)
list(JOIN mime_parts "." MACOS_MIMETYPE_ID)
configure_file("${CPACK_CURRENT_SOURCE_DIR}/lmms.plist.in" "${APP}/Contents/Info.plist" @ONLY)
file(COPY "${CPACK_CURRENT_SOURCE_DIR}/project.icns" DESTINATION "${APP}/Contents/Resources")
file(COPY "${CPACK_CURRENT_SOURCE_DIR}/icon.icns" DESTINATION "${APP}/Contents/Resources")
file(RENAME "${APP}/Contents/Resources/icon.icns" "${APP}/Contents/Resources/${lmms}.icns")

# Branding override
if(EXISTS "${CPACK_CURRENT_BINARY_DIR}/${lmms}.icns")
file(COPY "${CPACK_CURRENT_BINARY_DIR}/${lmms}.icns" DESTINATION "${APP}/Contents/Resources")
else()
file(COPY "${CPACK_CURRENT_SOURCE_DIR}/${lmms}.icns" DESTINATION "${APP}/Contents/Resources")
endif()

# Copy Suil modules
if(CPACK_SUIL_MODULES)
Expand Down
File renamed without changes.
37 changes: 37 additions & 0 deletions cmake/branding/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Initial branding cmake file
# Just used for testing currently

# TODO: Unused
set(branding_files
# installed
data/themes/default/splash.png
data/themes/default/icon.png
# apple
cmake/apple/lmms.icns
# windows
cmake/nsis/lmms.ico
)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/branding/modules" ${CMAKE_MODULE_PATH})
#file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/branding")
file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/lmms.iconset")

include(SvgRecolor)
set(svg_green "#27ab5f;#249a56;#34d07b;opacity=\".1\" fill=\"#fff\"")
set(svg_blue "#3992cb;#2b6fc5;#62a8d4;opacity=\".1\" fill=\"#fff\"")
set(svg_purple "#5547bd;#493ba1;#7871c5;opacity=\".05\" fill=\"#fff\"")

svg_recolor(svg_green svg_purple "${CMAKE_SOURCE_DIR}/cmake/linux/icons/scalable/apps/lmms.svg" svg_recolored)

#include(SvgConvert)
#svg_convert("16;16@2;32;32@2;48;48@2" "${svg_recolored}" "${CMAKE_CURRENT_BINARY_DIR}/%size%x%size%@%mult%/%name%.png")

# Windows
include(IcoConvert)
ico_convert("${svg_recolored}" "${CMAKE_CURRENT_BINARY_DIR}/lmms.ico")

# Mac
include(IcnsConvert)
icns_convert("${svg_recolored}" "${CMAKE_CURRENT_BINARY_DIR}/lmms.icns")

message(FATAL_ERROR "Done")
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
function(icns_convert source_file destination_file)
function(ico_convert source_file destination_file)
include(SvgConvert)

if(CPACK_CURRENT_BINARY_DIR)
Expand All @@ -25,22 +25,33 @@ function(icns_convert source_file destination_file)

# First, create icons at the standard resolutions
get_filename_component(name "${source_file}" NAME_WLE)
file(REMOVE "${working_directory}/${name}.iconset")
file(REMOVE_RECURSE "${working_directory}/${name}.iconset")

set(sizes 16 20 24 30 32 36 40 48 60 64 72 80 96 128 256)
svg_convert("${sizes}" "${source_file}" "${working_directory}/%name%.iconset/icon_%size%x%size%.png")

set(sizes 16 16@2 32 32@2 64 64@2 128 128@2 256 256@2 512 512@2)
#svg_convert("16@2;32;48;64;128" "${svg_recolored}" "${CMAKE_CURRENT_BINARY_DIR}")
svg_convert("${sizes}" "${source_file}" "${working_directory}/%name%.iconset/icon_%size%x%size%@%mult%x.png")
# Collect all files for convert
foreach(size ${sizes})
list(APPEND files "${working_directory}/${name}.iconset/icon_${size}x${size}.png")
endforeach()

# Create the icns file
execute_process(COMMAND iconutil
--convert icns
"${working_directory}/${name}.iconset"
--output "${destination_file}"
# Create the ico file
execute_process(COMMAND magick
${files}
"${destination_file}"
WORKING_DIRECTORY "${working_directory}"
OUTPUT_QUIET
COMMAND_ECHO ${COMMAND_ECHO}
COMMAND_ERROR_IS_FATAL ANY)

file(REMOVE "${working_directory}/${name}.iconset")
message(STATUS " icns_convert: ${source_file} --> ${destination_file}")
endfunction()
message(STATUS " ico_convert: ${source_file} --> ${destination_file}")
endfunction()

#convert icon.svg -scale 16 tmp/16.png
#convert icon.svg -scale 32 tmp/32.png
#convert icon.svg -scale 48 tmp/48.png
#convert icon.svg -scale 128 tmp/128.png
#convert icon.svg -scale 256 tmp/256.png
#Afterwards, the multiple png files can be packed in the final icon.ico with:
#convert tmp/16.png tmp/32.png tmp/48.png tmp/128.png tmp/256.png icon.ico
201 changes: 0 additions & 201 deletions cmake/modules/SvgConvert.cmake

This file was deleted.

35 changes: 0 additions & 35 deletions cmake/modules/SvgRecolor.cmake

This file was deleted.

8 changes: 6 additions & 2 deletions cmake/nsis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ endif()

# the final slash needs to be flipped for CPACK_PACKAGE_ICON to work:
# https://cmake.org/pipermail/cmake/2008-June/022085.html
SET(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/cmake/nsis\\\\nsis_branding.bmp")
SET(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/cmake/nsis/icon.ico")
SET(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_BINARY_DIR}/cmake/nsis\\\\nsis_branding.bmp")
SET(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_BINARY_DIR}/cmake/nsis/lmms.ico")
SET(CPACK_NSIS_INSTALLED_ICON_NAME "${CMAKE_PROJECT_NAME}.exe" PARENT_SCOPE)
SET(CPACK_NSIS_DISPLAY_NAME "${PROJECT_NAME_UCASE} ${VERSION}" PARENT_SCOPE)
SET(CPACK_NSIS_HELP_LINK "${PROJECT_URL}" PARENT_SCOPE)
Expand Down Expand Up @@ -66,6 +66,10 @@ endif()
CONFIGURE_FILE("lmms.rc.in" "${CMAKE_BINARY_DIR}/lmms.rc")
CONFIGURE_FILE("zynaddsubfx.rc.in" "${CMAKE_BINARY_DIR}/plugins/ZynAddSubFx/zynaddsubfx.rc")

# Handle branding
file(COPY "nsis_branding.bmp" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY "lmms.ico" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")

INSTALL(FILES "lmms.exe.manifest" DESTINATION .)
INSTALL(FILES "lmms.VisualElementsManifest.xml" DESTINATION .)
INSTALL(DIRECTORY "assets" DESTINATION .)
File renamed without changes.
Loading

0 comments on commit 973cbc7

Please sign in to comment.