From 12d3bee7aee8552365318eda6e0042d6ae77c795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Sun, 24 Mar 2024 03:09:06 +0100 Subject: [PATCH] 4. Instead of a shell script for generate png files and embedding use the CMake rules. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko --- client/CMakeLists.txt | 42 ++++++++++++++++++++++++++++++---- client/create-buttons.sh.cmake | 11 --------- 2 files changed, 37 insertions(+), 16 deletions(-) delete mode 100755 client/create-buttons.sh.cmake diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 903baf5..7e9d720 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -24,10 +24,42 @@ tde_import(twin) ### buttons.h ################################################################## -configure_file( create-buttons.sh.cmake create-buttons.sh @ONLY ) +file( + GLOB buttons_SOURCES + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/images + ${CMAKE_CURRENT_SOURCE_DIR}/images/*.svg +) +list( SORT buttons_SOURCES ) + +unset( buttons_IMAGES ) +file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/images ) +foreach( _image IN LISTS buttons_SOURCES ) + get_filename_component( _image_base ${_image} NAME_WE ) + add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/images/${_image_base}.png + COMMAND ${RSVG_COMMAND} + --width=32 --height=32 --format=png + --output=${CMAKE_CURRENT_BINARY_DIR}/images/${_image_base}.png + ${CMAKE_CURRENT_SOURCE_DIR}/images/${_image} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/images/${_image} + ) + list( APPEND buttons_IMAGES "images/${_image_base}.png" ) +endforeach() + +add_custom_target( buttons-prepare-images + COMMENT "Prepare images for embed into buttons" + DEPENDS ${buttons_IMAGES} +) -add_custom_target( buttons.h - COMMAND ${CMAKE_COMMAND} -E env ${CMAKE_CURRENT_BINARY_DIR}/create-buttons.sh +add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/buttons.h + COMMAND ${UIC_EXECUTABLE} -obuttons.h.in -embed buttons ${buttons_IMAGES} + COMMAND sed "s/factory/bfactory/" < buttons.h.in > buttons.h + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Embed images for buttons" + DEPENDS buttons-prepare-images +) +add_custom_target( buttons-embed-images + COMMENT "Generate embed images for buttons" + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/buttons.h ) @@ -46,9 +78,9 @@ tde_add_kpart( twin_polyester AUTOMOC tdecorations-shared DESTINATION ${PLUGIN_INSTALL_DIR} -) -add_dependencies( twin_polyester-module buttons.h ) + DEPENDENCIES buttons-embed-images +) ### other data ################################################################# diff --git a/client/create-buttons.sh.cmake b/client/create-buttons.sh.cmake deleted file mode 100755 index 36cb38c..0000000 --- a/client/create-buttons.sh.cmake +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -mkdir -p @CMAKE_CURRENT_BINARY_DIR@/images -for f in `ls @CMAKE_CURRENT_SOURCE_DIR@/images/*.svg` -do - @RSVG_COMMAND@ --width=32 --height=32 --output=images/`basename $f .svg`.png --format=png $f -done - -tquic -o buttons.h -embed buttons images/circle.png images/circle2.png images/close.png images/help.png images/keep_above.png images/keep_above_lit.png images/keep_below.png images/keep_below_lit.png images/maximize.png images/minimize.png images/restore.png images/splat.png images/unsplat.png images/window_background.png images/window_foreground.png - -sed -i -e "s/factory/bfactory/" buttons.h