-
Notifications
You must be signed in to change notification settings - Fork 446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUILD] Allow shared opentelemetry_proto
on non-Windows platform.
#2097
Changes from 9 commits
67bf8c7
ea7d86c
c5ea45d
643fdfb
69860c8
fb1d6c1
d1185f6
57001c2
0a18f46
679b8cf
9ab0f59
3eaf4d7
bfbe345
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -229,31 +229,41 @@ endif() | |
|
||
include_directories("${GENERATED_PROTOBUF_PATH}") | ||
|
||
unset(OTELCPP_PROTO_TARGET_OPTIONS) | ||
if(CMAKE_SYSTEM_NAME MATCHES "Windows|MinGW|WindowsStore") | ||
list(APPEND OTELCPP_PROTO_TARGET_OPTIONS STATIC) | ||
elseif(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) | ||
list(APPEND OTELCPP_PROTO_TARGET_OPTIONS SHARED) | ||
else() | ||
list(APPEND OTELCPP_PROTO_TARGET_OPTIONS STATIC) | ||
endif() | ||
|
||
list(APPEND OTELCPP_PROTO_TARGET_OPTIONS) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if I am missing something, but how are we using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, it's a mistake after merging. |
||
|
||
set(OPENTELEMETRY_PROTO_TARGETS opentelemetry_proto) | ||
add_library( | ||
opentelemetry_proto | ||
${COMMON_PB_CPP_FILE} | ||
${RESOURCE_PB_CPP_FILE} | ||
${TRACE_PB_CPP_FILE} | ||
${LOGS_PB_CPP_FILE} | ||
${METRICS_PB_CPP_FILE} | ||
${TRACE_SERVICE_PB_CPP_FILE} | ||
${LOGS_SERVICE_PB_CPP_FILE} | ||
${METRICS_SERVICE_PB_CPP_FILE}) | ||
|
||
if(WITH_OTLP_GRPC) | ||
add_library( | ||
opentelemetry_proto STATIC | ||
${COMMON_PB_CPP_FILE} | ||
${RESOURCE_PB_CPP_FILE} | ||
${TRACE_PB_CPP_FILE} | ||
${LOGS_PB_CPP_FILE} | ||
${METRICS_PB_CPP_FILE} | ||
${TRACE_SERVICE_PB_CPP_FILE} | ||
${TRACE_SERVICE_GRPC_PB_CPP_FILE} | ||
${LOGS_SERVICE_PB_CPP_FILE} | ||
${LOGS_SERVICE_GRPC_PB_CPP_FILE} | ||
${METRICS_SERVICE_PB_CPP_FILE} | ||
opentelemetry_proto_grpc | ||
${TRACE_SERVICE_GRPC_PB_CPP_FILE} ${LOGS_SERVICE_GRPC_PB_CPP_FILE} | ||
${METRICS_SERVICE_GRPC_PB_CPP_FILE}) | ||
else() | ||
add_library( | ||
opentelemetry_proto STATIC | ||
${COMMON_PB_CPP_FILE} | ||
${RESOURCE_PB_CPP_FILE} | ||
${TRACE_PB_CPP_FILE} | ||
${LOGS_PB_CPP_FILE} | ||
${METRICS_PB_CPP_FILE} | ||
${TRACE_SERVICE_PB_CPP_FILE} | ||
${LOGS_SERVICE_PB_CPP_FILE} | ||
${METRICS_SERVICE_PB_CPP_FILE}) | ||
|
||
list(APPEND OPENTELEMETRY_PROTO_TARGETS opentelemetry_proto_grpc) | ||
target_link_libraries(opentelemetry_proto_grpc PUBLIC opentelemetry_proto) | ||
|
||
set_target_properties(opentelemetry_proto_grpc PROPERTIES EXPORT_NAME | ||
proto_grpc) | ||
patch_protobuf_targets(opentelemetry_proto_grpc) | ||
endif() | ||
|
||
if(needs_proto_download) | ||
|
@@ -264,7 +274,7 @@ patch_protobuf_targets(opentelemetry_proto) | |
|
||
if(OPENTELEMETRY_INSTALL) | ||
install( | ||
TARGETS opentelemetry_proto | ||
TARGETS ${OPENTELEMETRY_PROTO_TARGETS} | ||
EXPORT "${PROJECT_NAME}-target" | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
|
@@ -282,9 +292,21 @@ if(TARGET protobuf::libprotobuf) | |
else() # cmake 3.8 or lower | ||
target_include_directories(opentelemetry_proto | ||
PUBLIC ${Protobuf_INCLUDE_DIRS}) | ||
target_link_libraries(opentelemetry_proto INTERFACE ${Protobuf_LIBRARIES}) | ||
target_link_libraries(opentelemetry_proto PUBLIC ${Protobuf_LIBRARIES}) | ||
endif() | ||
|
||
if(WITH_OTLP_GRPC) | ||
if(WITH_ABSEIL) | ||
find_package(absl CONFIG) | ||
if(TARGET absl::synchronization) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the target There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious the motive of this change - was there any build error with WITH_ABSEIL? |
||
target_link_libraries(opentelemetry_proto_grpc | ||
PRIVATE absl::synchronization) | ||
endif() | ||
endif() | ||
endif() | ||
|
||
if(BUILD_SHARED_LIBS) | ||
set_property(TARGET opentelemetry_proto PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
foreach(proto_target ${OPENTELEMETRY_PROTO_TARGETS}) | ||
set_property(TARGET ${proto_target} PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
endforeach() | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should mentioned this PR potential breaking change here in changelog, as we have are introducing a new library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the related CI job is here https://github.com/open-telemetry/opentelemetry-cpp/actions/runs/4707416429/jobs/8349260349 .