Skip to content

Commit c9e6d27

Browse files
committed
Set default visibility of opentelemetry_proto to hidden
1 parent df31777 commit c9e6d27

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

cmake/opentelemetry-proto.cmake

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
326331
if(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

cmake/tools.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ function(project_build_tools_set_import_declaration OUTPUT_VARNAME)
280280
""
281281
PARENT_SCOPE)
282282
endif()
283-
elseif(SunPro)
283+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
284284
set(${OUTPUT_VARNAME}
285285
"__global"
286286
PARENT_SCOPE)

0 commit comments

Comments
 (0)