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:
@@ -127,9 +127,10 @@ if(YAZE_WITH_GRPC)
|
||||
grpc++
|
||||
grpc++_reflection
|
||||
)
|
||||
if(YAZE_PROTOBUF_TARGETS)
|
||||
# NOTE: Do NOT link protobuf at library level on Windows - causes LNK1241
|
||||
# Executables will link it with /WHOLEARCHIVE to include internal symbols
|
||||
if(NOT WIN32 AND YAZE_PROTOBUF_TARGETS)
|
||||
target_link_libraries(yaze_app_core_lib PUBLIC ${YAZE_PROTOBUF_TARGETS})
|
||||
# NOTE: Removed /WHOLEARCHIVE for protobuf - causes duplicate version.res in dependency chain
|
||||
endif()
|
||||
|
||||
message(STATUS " - gRPC ROM service + canvas automation enabled")
|
||||
@@ -202,13 +203,14 @@ target_link_libraries(yaze PRIVATE
|
||||
absl::flags_parse
|
||||
)
|
||||
if(YAZE_WITH_GRPC AND YAZE_PROTOBUF_TARGETS)
|
||||
target_link_libraries(yaze PRIVATE ${YAZE_PROTOBUF_TARGETS})
|
||||
# Apply /WHOLEARCHIVE only at executable level to avoid duplicate version.res
|
||||
# This ensures protobuf internal symbols are included while preventing resource duplication
|
||||
# On Windows: Use /WHOLEARCHIVE instead of normal linking to include internal symbols
|
||||
# On Unix: Use normal linking (symbols resolve correctly without whole-archive)
|
||||
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()
|
||||
else()
|
||||
target_link_libraries(yaze PRIVATE ${YAZE_PROTOBUF_TARGETS})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -167,9 +167,10 @@ if(YAZE_WITH_GRPC)
|
||||
grpc++
|
||||
grpc++_reflection
|
||||
)
|
||||
if(YAZE_PROTOBUF_TARGETS)
|
||||
# NOTE: Do NOT link protobuf at library level on Windows - causes LNK1241
|
||||
# Executables will link it with /WHOLEARCHIVE to include internal symbols
|
||||
if(NOT WIN32 AND YAZE_PROTOBUF_TARGETS)
|
||||
target_link_libraries(yaze_editor PRIVATE ${YAZE_PROTOBUF_TARGETS})
|
||||
# NOTE: Removed /WHOLEARCHIVE for protobuf - causes duplicate version.res in dependency chain
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -154,9 +154,7 @@ void OverworldEditor::Initialize() {
|
||||
entity_renderer_ = std::make_unique<OverworldEntityRenderer>(
|
||||
&overworld_, &ow_map_canvas_, &sprite_previews_);
|
||||
|
||||
// Setup Canvas Automation API callbacks (Phase 4)
|
||||
SetupCanvasAutomation();
|
||||
|
||||
}
|
||||
|
||||
absl::Status OverworldEditor::Load() {
|
||||
|
||||
@@ -34,11 +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)
|
||||
# Windows: Link protobuf with /WHOLEARCHIVE (not via libraries 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(yaze_emu PRIVATE /WHOLEARCHIVE:$<TARGET_FILE:${_yaze_proto_target}>)
|
||||
endforeach()
|
||||
elseif(YAZE_WITH_GRPC AND YAZE_PROTOBUF_TARGETS)
|
||||
target_link_libraries(yaze_emu PRIVATE ${YAZE_PROTOBUF_TARGETS})
|
||||
endif()
|
||||
|
||||
# Test engine is always available when tests are built
|
||||
@@ -61,11 +63,13 @@ if(YAZE_BUILD_EMU AND NOT YAZE_MINIMAL_BUILD)
|
||||
absl::str_format
|
||||
)
|
||||
|
||||
# Apply /WHOLEARCHIVE for protobuf at executable level (Windows)
|
||||
# Windows: Link protobuf with /WHOLEARCHIVE (not via libraries 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(yaze_emu_test PRIVATE /WHOLEARCHIVE:$<TARGET_FILE:${_yaze_proto_target}>)
|
||||
endforeach()
|
||||
elseif(YAZE_WITH_GRPC AND YAZE_PROTOBUF_TARGETS)
|
||||
target_link_libraries(yaze_emu_test PRIVATE ${YAZE_PROTOBUF_TARGETS})
|
||||
endif()
|
||||
|
||||
message(STATUS "✓ yaze_emu_test: Headless emulator test harness configured")
|
||||
|
||||
@@ -84,9 +84,10 @@ if(YAZE_WITH_GRPC)
|
||||
grpc++
|
||||
grpc++_reflection
|
||||
)
|
||||
if(YAZE_PROTOBUF_TARGETS)
|
||||
# NOTE: Do NOT link protobuf at library level on Windows - causes LNK1241
|
||||
# Executables will link it with /WHOLEARCHIVE to include internal symbols
|
||||
if(NOT WIN32 AND YAZE_PROTOBUF_TARGETS)
|
||||
target_link_libraries(yaze_net PUBLIC ${YAZE_PROTOBUF_TARGETS})
|
||||
# NOTE: Removed /WHOLEARCHIVE for protobuf - causes duplicate version.res in dependency chain
|
||||
endif()
|
||||
|
||||
message(STATUS " - gRPC ROM service enabled")
|
||||
|
||||
Reference in New Issue
Block a user