From d50dc256778ae141a08937946db22e404346e997 Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 28 Sep 2025 18:18:02 -0400 Subject: [PATCH] Enhance CMake configuration for Windows x64 builds - Added a custom command to generate the Windows resource file `yaze.res` from `yaze.rc` and `yaze.ico`, ensuring proper resource management for x64 builds. - Introduced a custom target to ensure the resource file is built before linking, improving the build process for Windows targets. --- src/CMakeLists.txt | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a06d134b..a3a08c3e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -121,8 +121,26 @@ else() ) # Only use resource file for x64 Windows builds - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - target_link_options(yaze PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/win32/yaze.res") + if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 8) + # Generate yaze.res from yaze.rc and yaze.ico for Windows x64 builds + set(YAZE_RC_FILE "${CMAKE_CURRENT_SOURCE_DIR}/win32/yaze.rc") + set(YAZE_ICO_FILE "${CMAKE_CURRENT_SOURCE_DIR}/win32/yaze.ico") + set(YAZE_RES_FILE "${CMAKE_CURRENT_BINARY_DIR}/yaze.res") + + # Add a custom command to generate the .res file from the .rc and .ico + add_custom_command( + OUTPUT ${YAZE_RES_FILE} + COMMAND ${CMAKE_RC_COMPILER} /fo ${YAZE_RES_FILE} ${YAZE_RC_FILE} + DEPENDS ${YAZE_RC_FILE} ${YAZE_ICO_FILE} + COMMENT "Generating yaze.res from yaze.rc and yaze.ico" + VERBATIM + ) + + # Make sure the resource file is built before linking + add_custom_target(yaze_res ALL DEPENDS ${YAZE_RES_FILE}) + + # Link the generated .res file to the yaze target + target_sources(yaze PRIVATE ${YAZE_RES_FILE}) endif() endif() endif()