chore: reintroduce /WHOLEARCHIVE linking for protobuf at executable level
- Added /WHOLEARCHIVE linking for protobuf in various CMake files to ensure internal symbols are included while preventing resource duplication. - Updated linking options for `yaze`, `yaze_emu`, `z3ed`, and test suites to apply this option conditionally on Windows with MSVC. Benefits: - Ensures proper inclusion of protobuf symbols in executables, improving compatibility and functionality across platforms.
This commit is contained in:
@@ -203,7 +203,13 @@ target_link_libraries(yaze PRIVATE
|
||||
)
|
||||
if(YAZE_WITH_GRPC AND YAZE_PROTOBUF_TARGETS)
|
||||
target_link_libraries(yaze PRIVATE ${YAZE_PROTOBUF_TARGETS})
|
||||
# NOTE: Removed /WHOLEARCHIVE - already linked transitively from libraries
|
||||
# Apply /WHOLEARCHIVE only at executable level to avoid duplicate version.res
|
||||
# This ensures protobuf internal symbols are included while preventing resource duplication
|
||||
if(MSVC AND YAZE_PROTOBUF_WHOLEARCHIVE_TARGETS)
|
||||
foreach(_yaze_proto_target IN LISTS YAZE_PROTOBUF_WHOLEARCHIVE_TARGETS)
|
||||
target_link_options(yaze PRIVATE /WHOLEARCHIVE:$<TARGET_FILE:${_yaze_proto_target}>)
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Link test support library (yaze_editor needs TestManager)
|
||||
|
||||
@@ -34,6 +34,13 @@ if(YAZE_BUILD_EMU AND NOT YAZE_MINIMAL_BUILD)
|
||||
message(WARNING "yaze_emu needs yaze_test_support but TARGET not found")
|
||||
endif()
|
||||
|
||||
# Apply /WHOLEARCHIVE for protobuf at executable level (Windows)
|
||||
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(yaze_emu PRIVATE /WHOLEARCHIVE:$<TARGET_FILE:${_yaze_proto_target}>)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Test engine is always available when tests are built
|
||||
# No need for conditional definitions
|
||||
|
||||
@@ -53,6 +60,14 @@ if(YAZE_BUILD_EMU AND NOT YAZE_MINIMAL_BUILD)
|
||||
absl::strings
|
||||
absl::str_format
|
||||
)
|
||||
|
||||
# Apply /WHOLEARCHIVE for protobuf at executable level (Windows)
|
||||
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(yaze_emu_test PRIVATE /WHOLEARCHIVE:$<TARGET_FILE:${_yaze_proto_target}>)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
message(STATUS "✓ yaze_emu_test: Headless emulator test harness configured")
|
||||
message(STATUS "✓ yaze_emu: Standalone emulator executable configured")
|
||||
else()
|
||||
|
||||
@@ -42,6 +42,12 @@ if(YAZE_WITH_GRPC)
|
||||
target_link_libraries(z3ed PRIVATE grpc++ grpc++_reflection)
|
||||
if(YAZE_PROTOBUF_TARGETS)
|
||||
target_link_libraries(z3ed PRIVATE ${YAZE_PROTOBUF_TARGETS})
|
||||
# NOTE: Removed /WHOLEARCHIVE for protobuf - causes duplicate version.res in dependency chain
|
||||
# Apply /WHOLEARCHIVE only at executable level to avoid duplicate version.res
|
||||
# This ensures protobuf internal symbols are included while preventing resource duplication
|
||||
if(MSVC AND YAZE_PROTOBUF_WHOLEARCHIVE_TARGETS)
|
||||
foreach(_yaze_proto_target IN LISTS YAZE_PROTOBUF_WHOLEARCHIVE_TARGETS)
|
||||
target_link_options(z3ed PRIVATE /WHOLEARCHIVE:$<TARGET_FILE:${_yaze_proto_target}>)
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user