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.
This commit is contained in:
Simon Tatham
2021-04-13 18:14:54 +01:00
parent 69b5e7513a
commit f8b15bab6b

View File

@ -4,6 +4,13 @@ if(NOT build_icons)
return() return()
endif() 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(CONVERT convert)
find_program(IDENTIFY identify) find_program(IDENTIFY identify)
if(NOT CONVERT OR NOT 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 # trimming boring border parts of the original image in the
# process. Done by square.pl. # process. Done by square.pl.
add_custom_command(OUTPUT ${icon_bindir}/${name}-web.png add_custom_command(OUTPUT ${icon_bindir}/${name}-web.png
COMMAND ${icon_srcdir}/square.pl COMMAND ${PERL_EXECUTABLE} ${icon_srcdir}/square.pl
${CONVERT} 150 5 ${CONVERT} 150 5
${icon_bindir}/${name}-base.png ${icon_bindir}/${name}-base.png
${icon_bindir}/${name}-web.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 # Make a 24-bit icon image at each size, by shrinking the base
# icon image. # icon image.
add_custom_command(OUTPUT ${icon_bindir}/${name}-${size}d24.png 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}} ${CONVERT} ${size} ${border_${size}}
${icon_bindir}/${name}-ibase.png ${icon_bindir}/${name}-ibase.png
${icon_bindir}/${name}-${size}d24.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 # 4-bit icons are only needed for Windows. We make each one by
# first shrinking the large 4-bit image we made above ... # first shrinking the large 4-bit image we made above ...
add_custom_command(OUTPUT ${icon_bindir}/${name}-${size}d4pre.png 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}} ${CONVERT} ${size} ${border_${size}}
${icon_bindir}/${name}-ibase4.png ${icon_bindir}/${name}-ibase4.png
${icon_bindir}/${name}-${size}d4pre.png ${icon_bindir}/${name}-${size}d4pre.png
@ -217,7 +224,7 @@ function(build_icon name)
endforeach() endforeach()
endforeach() endforeach()
add_custom_command(OUTPUT ${icon_bindir}/${name}.ico add_custom_command(OUTPUT ${icon_bindir}/${name}.ico
COMMAND ${icon_srcdir}/icon.pl COMMAND ${PERL_EXECUTABLE} ${icon_srcdir}/icon.pl
--convert=${CONVERT} --convert=${CONVERT}
${icon_pl_args} > ${icon_bindir}/${name}.ico ${icon_pl_args} > ${icon_bindir}/${name}.ico
DEPENDS DEPENDS
@ -231,7 +238,7 @@ function(build_icon name)
list(APPEND cicon_pl_infiles ${icon_bindir}/${name}-${size}d24.png) list(APPEND cicon_pl_infiles ${icon_bindir}/${name}-${size}d24.png)
endforeach() endforeach()
add_custom_command(OUTPUT ${icon_bindir}/${name}-icon.c 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 ${CONVERT} ${cicon_pl_infiles} > ${icon_bindir}/${name}-icon.c
DEPENDS DEPENDS
${icon_srcdir}/cicon.pl ${icon_srcdir}/cicon.pl