From 49120610878bc453c57be01e8b7549d46ebbf974 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 17 May 2026 17:08:29 +0000 Subject: [PATCH] fix(testing_util): link opentelemetry-cpp SDK as PUBLIC The `opentelemetry_matchers.h` public header of `google_cloud_cpp_testing` includes and uses opentelemetry-cpp SDK symbols inline (e.g. `sdk::trace::SpanData::GetAttributes()`). Tests that link `google_cloud_cpp_testing` therefore reference these SDK symbols directly from their own translation units. However, the CMake build links `opentelemetry-cpp::in_memory_span_exporter` and `opentelemetry-cpp::trace` as PRIVATE, so they are not propagated to the test executables. When building with shared libraries this fails to link, e.g.: undefined reference to symbol '...sdk::trace::SpanData::GetAttributes[abi:cxx11]() const' libopentelemetry_trace.so: error adding symbols: DSO missing from command line The Bazel build already exposes these dependencies transitively (via `google_cloud_cpp_testing_private`), so making the CMake link PUBLIC also aligns the two build systems. --- google/cloud/testing_util/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/google/cloud/testing_util/CMakeLists.txt b/google/cloud/testing_util/CMakeLists.txt index 8028f70d70284..1a4d1cc1bb20f 100644 --- a/google/cloud/testing_util/CMakeLists.txt +++ b/google/cloud/testing_util/CMakeLists.txt @@ -57,9 +57,9 @@ add_library( timer.h) target_link_libraries( google_cloud_cpp_testing - PUBLIC absl::symbolize absl::failure_signal_handler google-cloud-cpp::common - GTest::gmock - PRIVATE opentelemetry-cpp::in_memory_span_exporter opentelemetry-cpp::trace) + PUBLIC absl::symbolize absl::failure_signal_handler + google-cloud-cpp::common GTest::gmock + opentelemetry-cpp::in_memory_span_exporter opentelemetry-cpp::trace) google_cloud_cpp_add_common_options(google_cloud_cpp_testing)