chore: refine protobuf linking logic for Windows builds

- Enhanced CMake configuration to conditionally apply /WHOLEARCHIVE linking for protobuf targets, ensuring only library targets are included.
- Updated linking logic across multiple components including `yaze`, `yaze_emu`, `z3ed`, and test suites to improve compatibility and prevent linker errors.

Benefits:
- Increases build stability and clarity by ensuring only relevant targets are linked, reducing potential conflicts during the build process.
This commit is contained in:
scawful
2025-10-18 12:53:15 -04:00
parent df695b8f86
commit 283a21888e
6 changed files with 46 additions and 7 deletions

View File

@@ -46,7 +46,12 @@ if(YAZE_BUILD_TESTS)
# Link protobuf with /WHOLEARCHIVE on Windows (instead of via libraries)
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(${suite_name} PRIVATE /WHOLEARCHIVE:$<TARGET_FILE:${_yaze_proto_target}>)
if(TARGET ${_yaze_proto_target})
get_target_property(_target_type ${_yaze_proto_target} TYPE)
if(_target_type MATCHES ".*_LIBRARY")
target_link_options(${suite_name} PRIVATE /WHOLEARCHIVE:$<TARGET_FILE:${_yaze_proto_target}>)
endif()
endif()
endforeach()
endif()