From f8b15bab6b2a8dd8309cdef3dc49ae3377cb997d Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 13 Apr 2021 18:14:54 +0100 Subject: [PATCH] icons.cmake: explicitly search for Perl. This allows the icons build to automatically disable itself if Perl can't be found at all (and print a warning explaining that that's why). It also means that if Perl exists on the system but is somewhere other than /usr/bin (where our #! lines expect it), the icons build can still run. --- icons/icons.cmake | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/icons/icons.cmake b/icons/icons.cmake index b5ee02e..0834166 100644 --- a/icons/icons.cmake +++ b/icons/icons.cmake @@ -4,6 +4,13 @@ if(NOT build_icons) return() endif() +include(FindPerl) +if(NOT PERL_EXECUTABLE) + message(WARNING "Puzzle icons cannot be rebuilt (did not find Perl)") + set(build_icons FALSE) + return() +endif() + find_program(CONVERT convert) find_program(IDENTIFY identify) if(NOT CONVERT OR NOT IDENTIFY) @@ -118,7 +125,7 @@ function(build_icon name) # trimming boring border parts of the original image in the # process. Done by square.pl. add_custom_command(OUTPUT ${icon_bindir}/${name}-web.png - COMMAND ${icon_srcdir}/square.pl + COMMAND ${PERL_EXECUTABLE} ${icon_srcdir}/square.pl ${CONVERT} 150 5 ${icon_bindir}/${name}-base.png ${icon_bindir}/${name}-web.png @@ -159,7 +166,7 @@ function(build_icon name) # Make a 24-bit icon image at each size, by shrinking the base # icon image. add_custom_command(OUTPUT ${icon_bindir}/${name}-${size}d24.png - COMMAND ${icon_srcdir}/square.pl + COMMAND ${PERL_EXECUTABLE} ${icon_srcdir}/square.pl ${CONVERT} ${size} ${border_${size}} ${icon_bindir}/${name}-ibase.png ${icon_bindir}/${name}-${size}d24.png @@ -183,7 +190,7 @@ function(build_icon name) # 4-bit icons are only needed for Windows. We make each one by # first shrinking the large 4-bit image we made above ... add_custom_command(OUTPUT ${icon_bindir}/${name}-${size}d4pre.png - COMMAND ${icon_srcdir}/square.pl + COMMAND ${PERL_EXECUTABLE} ${icon_srcdir}/square.pl ${CONVERT} ${size} ${border_${size}} ${icon_bindir}/${name}-ibase4.png ${icon_bindir}/${name}-${size}d4pre.png @@ -217,7 +224,7 @@ function(build_icon name) endforeach() endforeach() add_custom_command(OUTPUT ${icon_bindir}/${name}.ico - COMMAND ${icon_srcdir}/icon.pl + COMMAND ${PERL_EXECUTABLE} ${icon_srcdir}/icon.pl --convert=${CONVERT} ${icon_pl_args} > ${icon_bindir}/${name}.ico DEPENDS @@ -231,7 +238,7 @@ function(build_icon name) list(APPEND cicon_pl_infiles ${icon_bindir}/${name}-${size}d24.png) endforeach() add_custom_command(OUTPUT ${icon_bindir}/${name}-icon.c - COMMAND ${icon_srcdir}/cicon.pl + COMMAND ${PERL_EXECUTABLE} ${icon_srcdir}/cicon.pl ${CONVERT} ${cicon_pl_infiles} > ${icon_bindir}/${name}-icon.c DEPENDS ${icon_srcdir}/cicon.pl