@@ -321,8 +321,13 @@ target_include_directories(
321321 "$<INSTALL_INTERFACE:include>" )
322322
323323# Disable include-what-you-use and clang-tidy on generated code.
324- set_target_properties (opentelemetry_proto PROPERTIES CXX_INCLUDE_WHAT_YOU_USE ""
325- CXX_CLANG_TIDY "" )
324+ set_target_properties (
325+ opentelemetry_proto
326+ PROPERTIES CXX_INCLUDE_WHAT_YOU_USE ""
327+ CXX_CLANG_TIDY ""
328+ C_VISIBILITY_PRESET "hidden"
329+ CXX_VISIBILITY_PRESET "hidden"
330+ VISIBILITY_INLINES_HIDDEN OFF )
326331if (NOT Protobuf_INCLUDE_DIRS AND TARGET protobuf::libprotobuf)
327332 get_target_property (Protobuf_INCLUDE_DIRS protobuf::libprotobuf
328333 INTERFACE_INCLUDE_DIRECTORIES )
@@ -342,6 +347,9 @@ if(WITH_OTLP_GRPC)
342347
343348 if (OTELCPP_PROTO_LIB_TYPE STREQUAL "SHARED_LIBRARY" )
344349 if (CMAKE_SYSTEM_NAME MATCHES "Windows|MinGW|WindowsStore" )
350+ # The codes generated by gRPC plugin do not support dll export/import
351+ # declarations. To work around this, we enable WINDOWS_EXPORT_ALL_SYMBOLS
352+ # property to export all symbols when building a shared library.
345353 set_target_properties (opentelemetry_proto_grpc
346354 PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
347355 endif ()
@@ -353,7 +361,8 @@ if(WITH_OTLP_GRPC)
353361 PROPERTIES CXX_INCLUDE_WHAT_YOU_USE ""
354362 CXX_CLANG_TIDY ""
355363 C_VISIBILITY_PRESET "default"
356- CXX_VISIBILITY_PRESET "default" )
364+ CXX_VISIBILITY_PRESET "default"
365+ VISIBILITY_INLINES_HIDDEN OFF )
357366
358367 list (APPEND OPENTELEMETRY_PROTO_TARGETS opentelemetry_proto_grpc)
359368 target_link_libraries (opentelemetry_proto_grpc PUBLIC opentelemetry_proto)
@@ -365,7 +374,8 @@ if(WITH_OTLP_GRPC)
365374 # opentelemetry_exporter_otlp_grpc_client as a static library.
366375 get_target_property (grpc_lib_type gRPC::grpc++ TYPE )
367376
368- if (grpc_lib_type STREQUAL "SHARED_LIBRARY" )
377+ if (grpc_lib_type STREQUAL "SHARED_LIBRARY" OR OTELCPP_PROTO_LIB_TYPE STREQUAL
378+ "SHARED_LIBRARY" )
369379 target_link_libraries (opentelemetry_proto_grpc PUBLIC gRPC::grpc++)
370380 endif ()
371381 set_target_properties (opentelemetry_proto_grpc PROPERTIES EXPORT_NAME
0 commit comments