feat(cmake): enhance OpenSSL linking and whole-archive options for Windows

- Updated CMake configurations to conditionally link OpenSSL only when gRPC is not enabled, preventing duplicate symbol errors.
- Added support for whole-archive linking of protobuf on Windows across core, net, agent, and z3ed components to ensure all symbols are included.
- Improved status messages to reflect the use of gRPC's OpenSSL when applicable.

Benefits:
- Enhanced compatibility and stability of the build process across different platforms and configurations.
This commit is contained in:
scawful
2025-10-12 07:16:47 -04:00
parent 42197eb71f
commit d40ac3372f
4 changed files with 55 additions and 16 deletions

View File

@@ -151,6 +151,11 @@ if(YAZE_WITH_GRPC)
libprotobuf
)
# On Windows, force whole-archive linking for protobuf to ensure all symbols are included
if(MSVC)
target_link_options(yaze_core_lib PUBLIC /WHOLEARCHIVE:libprotobuf)
endif()
message(STATUS " - gRPC test harness + ROM service enabled")
endif()

View File

@@ -52,14 +52,21 @@ if(YAZE_WITH_JSON)
find_package(Threads REQUIRED)
target_link_libraries(yaze_net PUBLIC Threads::Threads)
# Add OpenSSL for HTTPS/WSS support (optional but recommended)
find_package(OpenSSL QUIET)
if(OpenSSL_FOUND)
target_link_libraries(yaze_net PUBLIC OpenSSL::SSL OpenSSL::Crypto)
target_compile_definitions(yaze_net PUBLIC CPPHTTPLIB_OPENSSL_SUPPORT)
message(STATUS " - WebSocket with SSL/TLS support enabled")
# Only link OpenSSL if gRPC is NOT enabled (to avoid duplicate symbol errors)
# When gRPC is enabled, it brings its own OpenSSL which we'll use instead
if(NOT YAZE_WITH_GRPC)
find_package(OpenSSL QUIET)
if(OpenSSL_FOUND)
target_link_libraries(yaze_net PUBLIC OpenSSL::SSL OpenSSL::Crypto)
target_compile_definitions(yaze_net PUBLIC CPPHTTPLIB_OPENSSL_SUPPORT)
message(STATUS " - WebSocket with SSL/TLS support enabled")
else()
message(STATUS " - WebSocket without SSL/TLS (OpenSSL not found)")
endif()
else()
message(STATUS " - WebSocket without SSL/TLS (OpenSSL not found)")
# When gRPC is enabled, still enable OpenSSL features but use gRPC's OpenSSL
target_compile_definitions(yaze_net PUBLIC CPPHTTPLIB_OPENSSL_SUPPORT)
message(STATUS " - WebSocket with SSL/TLS support enabled via gRPC's OpenSSL")
endif()
# Windows-specific socket library
@@ -79,6 +86,11 @@ if(YAZE_WITH_GRPC)
libprotobuf
)
# On Windows, force whole-archive linking for protobuf to ensure all symbols are included
if(MSVC)
target_link_options(yaze_net PUBLIC /WHOLEARCHIVE:libprotobuf)
endif()
message(STATUS " - gRPC ROM service enabled")
endif()