shithub: puzzles

Download patch

ref: 595338fa43d40f356f04b8704f72f060651669e8
parent: cb8dcc34f7c656b8603a510617e35492a0d16b8c
author: Simon Tatham <anakin@pobox.com>
date: Sun Nov 19 10:03:40 EST 2023

Windows: leave puzzles.rc out of auxiliary GUI tools.

There's no reason to put the .rc file into developer tools like
galaxieseditor at all. Its current job is to add an icon, and those
tools don't have any. I'm about to add version information, and they
won't have that either (in particular, no description string like the
games do).

The CLI developer tools already don't include puzzles.rc, and GUI dev
tools are more like those than they are like puzzles.

puzzles.rc was being added to an aux GUI tool's source file list by
get_platform_puzzle_extra_source_files(), which is called for aux GUI
tools as well as for puzzles proper. However, it's not as simple as
just eliminating that call, because on Unix, we _do_ need to add the
same extra source files to GUI dev tools that we do for puzzles,
because gtk.c contains external references to either an array of the
puzzle's icons or an empty array indicating that there aren't any, so
_something_ has to provide that.

So instead, get_platform_puzzle_extra_source_files now takes an extra
argument saying whether the program is a real puzzle or an aux tool;
windows.cmake leaves out puzzles.rc in the latter case, but unix.cmake
puts the icon array in unconditionally.

--- a/cmake/platforms/emscripten.cmake
+++ b/cmake/platforms/emscripten.cmake
@@ -81,7 +81,7 @@
 set(build_cli_programs FALSE)
 set(build_gui_programs FALSE)
 
-function(get_platform_puzzle_extra_source_files OUTVAR NAME)
+function(get_platform_puzzle_extra_source_files OUTVAR NAME AUXILIARY)
   set(${OUTVAR} PARENT_SCOPE)
 endfunction()
 
--- a/cmake/platforms/nestedvm.cmake
+++ b/cmake/platforms/nestedvm.cmake
@@ -12,7 +12,7 @@
     ${CMAKE_SOURCE_DIR}/PuzzleApplet.java
   DEPENDS ${CMAKE_SOURCE_DIR}/PuzzleApplet.java)
 
-function(get_platform_puzzle_extra_source_files OUTVAR NAME)
+function(get_platform_puzzle_extra_source_files OUTVAR NAME AUXILIARY)
   set(${OUTVAR} PARENT_SCOPE)
 endfunction()
 
--- a/cmake/platforms/osx.cmake
+++ b/cmake/platforms/osx.cmake
@@ -10,7 +10,7 @@
 
 set(build_gui_programs FALSE) # they don't really fit in the OS X GUI model
 
-function(get_platform_puzzle_extra_source_files OUTVAR NAME)
+function(get_platform_puzzle_extra_source_files OUTVAR NAME AUXILIARY)
   set(${OUTVAR} PARENT_SCOPE)
 endfunction()
 
--- a/cmake/platforms/unix.cmake
+++ b/cmake/platforms/unix.cmake
@@ -63,7 +63,7 @@
 
 add_compile_definitions(HELP_DIR="${CMAKE_INSTALL_PREFIX}/share/sgt-puzzles/help")
 
-function(get_platform_puzzle_extra_source_files OUTVAR NAME)
+function(get_platform_puzzle_extra_source_files OUTVAR NAME AUXILIARY)
   if(build_icons AND EXISTS ${CMAKE_SOURCE_DIR}/icons/${NAME}.sav)
     # If we have the equipment to rebuild the puzzles' icon images
     # from scratch, do so. Then changes in the puzzle display code
--- a/cmake/platforms/windows.cmake
+++ b/cmake/platforms/windows.cmake
@@ -33,8 +33,10 @@
 /wd4244 /wd4267 /wd4018 /wd4146 /wd4305")
 endif()
 
-function(get_platform_puzzle_extra_source_files OUTVAR NAME)
-  set(${OUTVAR} ${CMAKE_SOURCE_DIR}/puzzles.rc PARENT_SCOPE)
+function(get_platform_puzzle_extra_source_files OUTVAR NAME AUXILIARY)
+  if(NOT AUXILIARY)
+    set(${OUTVAR} ${CMAKE_SOURCE_DIR}/puzzles.rc PARENT_SCOPE)
+  endif()
 endfunction()
 
 function(set_platform_gui_target_properties TARGET)
--- a/cmake/setup.cmake
+++ b/cmake/setup.cmake
@@ -128,7 +128,7 @@
     set(puzzle_sources ${puzzle_sources} ${CMAKE_CURRENT_SOURCE_DIR}/${NAME}.c PARENT_SCOPE)
   endif()
 
-  get_platform_puzzle_extra_source_files(extra_files ${NAME})
+  get_platform_puzzle_extra_source_files(extra_files ${NAME} FALSE)
 
   if (build_individual_puzzles)
     add_executable(${EXENAME} ${NAME}.c ${extra_files})
@@ -173,7 +173,7 @@
     "" "" "COMPILE_DEFINITIONS" ${ARGN})
 
   if(build_gui_programs)
-    get_platform_puzzle_extra_source_files(extra_files ${NAME})
+    get_platform_puzzle_extra_source_files(extra_files ${NAME} TRUE)
     add_executable(${NAME} ${OPT_UNPARSED_ARGUMENTS} ${extra_files})
     target_link_libraries(${NAME}
       common ${platform_gui_libs} ${platform_libs})