chore: update protobuf linking strategy for Windows

- Adjusted CMake files to conditionally link protobuf using /WHOLEARCHIVE on Windows to include internal symbols while avoiding LNK1241 errors.
- Updated linking logic for `yaze`, `yaze_editor`, `yaze_emu`, `z3ed`, and test suites to ensure compatibility across platforms.

Benefits:
- Improves build stability and compatibility for Windows users by ensuring proper symbol inclusion without resource duplication issues.
This commit is contained in:
scawful
2025-10-18 12:01:12 -04:00
parent 5894809aaf
commit 51cf1681e5
10 changed files with 44 additions and 32 deletions

View File

@@ -47,15 +47,18 @@ set(HELPER_TOOLS
)
foreach(TOOL ${HELPER_TOOLS})
# Windows: Link protobuf with /WHOLEARCHIVE (not via yaze_core to avoid LNK1241)
if(WIN32 AND MSVC AND YAZE_WITH_GRPC AND YAZE_PROTOBUF_WHOLEARCHIVE_TARGETS)
foreach(_yaze_proto_target IN LISTS YAZE_PROTOBUF_WHOLEARCHIVE_TARGETS)
target_link_options(${TOOL} PRIVATE /WHOLEARCHIVE:$<TARGET_FILE:${_yaze_proto_target}>)
endforeach()
elseif(YAZE_WITH_GRPC AND YAZE_PROTOBUF_TARGETS)
target_link_libraries(${TOOL} PRIVATE ${YAZE_PROTOBUF_TARGETS})
endif()
if(WIN32)
if(MSVC)
target_link_options(${TOOL} PRIVATE /STACK:16777216)
# Apply /WHOLEARCHIVE for protobuf at executable level
if(YAZE_WITH_GRPC AND YAZE_PROTOBUF_WHOLEARCHIVE_TARGETS)
foreach(_yaze_proto_target IN LISTS YAZE_PROTOBUF_WHOLEARCHIVE_TARGETS)
target_link_options(${TOOL} PRIVATE /WHOLEARCHIVE:$<TARGET_FILE:${_yaze_proto_target}>)
endforeach()
endif()
elseif(MINGW OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_options(${TOOL} PRIVATE -Wl,--stack,16777216)
else()