fix: adjust gRPC and testing dependencies in CMake configuration

- Updated the CMake configuration to load testing dependencies before gRPC when both are enabled, preventing export errors related to gmock.
- Ensured that testing dependencies are loaded after gRPC if tests are enabled but gRPC is not, maintaining proper dependency order.
- Added logic to guard CMake's package lookup for gRPC, ensuring consistent toolchain usage and preventing conflicts with system-installed versions.
- Implemented checks for target availability and improved error handling for missing gRPC components, enhancing build reliability.
This commit is contained in:
scawful
2025-11-05 21:10:33 -05:00
parent e8d4f9a41f
commit 43fff327d8
2 changed files with 174 additions and 5 deletions

View File

@@ -43,6 +43,14 @@ if(YAZE_ENABLE_JSON)
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_JSON_TARGETS})
endif()
# CRITICAL: Load testing dependencies BEFORE gRPC when both are enabled
# This ensures gmock is available before Abseil (bundled with gRPC) tries to export test_allocator
# which depends on gmock. This prevents CMake export errors.
if(YAZE_BUILD_TESTS AND YAZE_ENABLE_GRPC)
include(cmake/dependencies/testing.cmake)
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_TESTING_TARGETS})
endif()
if(YAZE_ENABLE_GRPC)
include(cmake/dependencies/grpc.cmake)
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_GRPC_TARGETS})
@@ -53,7 +61,8 @@ if(YAZE_BUILD_CLI)
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_FTXUI_TARGETS})
endif()
if(YAZE_BUILD_TESTS)
# Load testing dependencies after gRPC if tests are enabled but gRPC is not
if(YAZE_BUILD_TESTS AND NOT YAZE_ENABLE_GRPC)
include(cmake/dependencies/testing.cmake)
list(APPEND YAZE_ALL_DEPENDENCIES ${YAZE_TESTING_TARGETS})
endif()