From 7e95d536a95e70090963f29a36d74423d5d54a94 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Fri, 4 Jul 2025 11:43:45 -0400 Subject: [PATCH] build(windows): fix windows.rc line too long errors (#4048) --- cmake/compile_definitions/windows.cmake | 11 +++++-- cmake/targets/windows.cmake | 1 + .../windows/{windows.rc.in => windows.rc} | 30 ++++++++++--------- 3 files changed, 26 insertions(+), 16 deletions(-) rename src/platform/windows/{windows.rc.in => windows.rc} (51%) diff --git a/cmake/compile_definitions/windows.cmake b/cmake/compile_definitions/windows.cmake index a3009be0a..60ee905b7 100644 --- a/cmake/compile_definitions/windows.cmake +++ b/cmake/compile_definitions/windows.cmake @@ -38,10 +38,17 @@ if(NOT DEFINED SUNSHINE_ICON_PATH) set(SUNSHINE_ICON_PATH "${CMAKE_SOURCE_DIR}/sunshine.ico") endif() -configure_file("${CMAKE_SOURCE_DIR}/src/platform/windows/windows.rc.in" windows.rc @ONLY) +# Create a separate object library for the RC file with minimal includes +add_library(sunshine_rc_object OBJECT "${CMAKE_SOURCE_DIR}/src/platform/windows/windows.rc") + +# Set minimal properties for RC compilation - only what's needed for the resource file +# Otherwise compilation can fail due to "line too long" errors +set_target_properties(sunshine_rc_object PROPERTIES + COMPILE_DEFINITIONS "PROJECT_ICON_PATH=${SUNSHINE_ICON_PATH};PROJECT_NAME=${PROJECT_NAME};PROJECT_VENDOR=${SUNSHINE_PUBLISHER_NAME};PROJECT_VERSION=${PROJECT_VERSION};PROJECT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR};PROJECT_VERSION_MINOR=${PROJECT_VERSION_MINOR};PROJECT_VERSION_PATCH=${PROJECT_VERSION_PATCH}" # cmake-lint: disable=C0301 + INCLUDE_DIRECTORIES "" +) set(PLATFORM_TARGET_FILES - "${CMAKE_CURRENT_BINARY_DIR}/windows.rc" "${CMAKE_SOURCE_DIR}/src/platform/windows/publish.cpp" "${CMAKE_SOURCE_DIR}/src/platform/windows/misc.h" "${CMAKE_SOURCE_DIR}/src/platform/windows/misc.cpp" diff --git a/cmake/targets/windows.cmake b/cmake/targets/windows.cmake index b7f8fbcfe..33a67cfd4 100644 --- a/cmake/targets/windows.cmake +++ b/cmake/targets/windows.cmake @@ -3,5 +3,6 @@ set_target_properties(sunshine PROPERTIES LINK_SEARCH_START_STATIC 1) set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll") find_library(ZLIB ZLIB1) list(APPEND SUNSHINE_EXTERNAL_LIBRARIES + $ Windowsapp.lib Wtsapi32.lib) diff --git a/src/platform/windows/windows.rc.in b/src/platform/windows/windows.rc similarity index 51% rename from src/platform/windows/windows.rc.in rename to src/platform/windows/windows.rc index c7f8cebef..7de76b930 100644 --- a/src/platform/windows/windows.rc.in +++ b/src/platform/windows/windows.rc @@ -1,13 +1,15 @@ /** - * @file src/platform/windows/windows.rc.in - * @brief Windows resource file template. - * @note The final `windows.rc` is generated from this file during the CMake build. - * @todo Use CMake definitions directly, instead of configuring this file. + * @file src/platform/windows/windows.rc + * @brief Windows resource file. */ #include "winver.h" + +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + VS_VERSION_INFO VERSIONINFO -FILEVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,0 -PRODUCTVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,0 +FILEVERSION PROJECT_VERSION_MAJOR,PROJECT_VERSION_MINOR,PROJECT_VERSION_PATCH,0 +PRODUCTVERSION PROJECT_VERSION_MAJOR,PROJECT_VERSION_MINOR,PROJECT_VERSION_PATCH,0 FILEOS VOS__WINDOWS32 FILETYPE VFT_APP FILESUBTYPE VFT2_UNKNOWN @@ -16,13 +18,13 @@ BEGIN BEGIN BLOCK "040904E4" BEGIN - VALUE "CompanyName", "LizardByte\0" - VALUE "FileDescription", "Sunshine\0" - VALUE "FileVersion", "@PROJECT_VERSION@\0" - VALUE "InternalName", "Sunshine\0" - VALUE "LegalCopyright", "https://raw.githubusercontent.com/LizardByte/Sunshine/master/LICENSE\0" - VALUE "ProductName", "Sunshine\0" - VALUE "ProductVersion", "@PROJECT_VERSION@\0" + VALUE "CompanyName", TOSTRING(PROJECT_VENDOR) + VALUE "FileDescription", TOSTRING(PROJECT_NAME) + VALUE "FileVersion", TOSTRING(PROJECT_VERSION) + VALUE "InternalName", TOSTRING(PROJECT_NAME) + VALUE "ProductName", TOSTRING(PROJECT_NAME) + VALUE "ProductVersion", TOSTRING(PROJECT_VERSION) + VALUE "LegalCopyright", "https://raw.githubusercontent.com/LizardByte/Sunshine/master/LICENSE" END END @@ -39,4 +41,4 @@ BEGIN END END -SuperDuperAmazing ICON DISCARDABLE "@SUNSHINE_ICON_PATH@" +SuperDuperAmazing ICON DISCARDABLE PROJECT_ICON_PATH