forked from open-telemetry/opentelemetry-cpp
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CMake gRPC support when OTLP is enabled (open-telemetry#431)
- Loading branch information
1 parent
68e510c
commit ec6b6c7
Showing
6 changed files
with
138 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,137 @@ | ||
set(PROTO_PATH "${CMAKE_SOURCE_DIR}/third_party/opentelemetry-proto") | ||
|
||
set(COMMON_PROTO "${PROTO_PATH}/opentelemetry/proto/common/v1/common.proto") | ||
set(RESOURCE_PROTO "${PROTO_PATH}/opentelemetry/proto/resource/v1/resource.proto") | ||
set(RESOURCE_PROTO | ||
"${PROTO_PATH}/opentelemetry/proto/resource/v1/resource.proto") | ||
set(TRACE_PROTO "${PROTO_PATH}/opentelemetry/proto/trace/v1/trace.proto") | ||
set(LOGS_PROTO "${PROTO_PATH}/opentelemetry/proto/logs/v1/logs.proto") | ||
set(METRICS_PROTO "${PROTO_PATH}/opentelemetry/proto/metrics/v1/metrics.proto") | ||
|
||
set(GENERATED_PROTOBUF_PATH "${CMAKE_BINARY_DIR}/generated/third_party/opentelemetry-proto") | ||
set(TRACE_SERVICE_PROTO | ||
"${PROTO_PATH}/opentelemetry/proto/collector/trace/v1/trace_service.proto") | ||
set(LOGS_SERVICE_PROTO | ||
"${PROTO_PATH}/opentelemetry/proto/collector/logs/v1/logs_service.proto") | ||
set(METRICS_SERVICE_PROTO | ||
"${PROTO_PATH}/opentelemetry/proto/collector/metrics/v1/metrics_service.proto" | ||
) | ||
|
||
set(GENERATED_PROTOBUF_PATH | ||
"${CMAKE_BINARY_DIR}/generated/third_party/opentelemetry-proto") | ||
|
||
file(MAKE_DIRECTORY "${GENERATED_PROTOBUF_PATH}") | ||
|
||
set(COMMON_PB_CPP_FILE "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/common/v1/common.pb.cc") | ||
set(COMMON_PB_H_FILE "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/common/v1/common.pb.h") | ||
set(RESOURCE_PB_CPP_FILE "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/resource/v1/resource.pb.cc") | ||
set(RESOURCE_PB_H_FILE "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/resource/v1/resource.pb.h") | ||
set(TRACE_PB_CPP_FILE "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/trace/v1/trace.pb.cc") | ||
set(TRACE_PB_H_FILE "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/trace/v1/trace.pb.h") | ||
set(COMMON_PB_CPP_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/common/v1/common.pb.cc") | ||
set(COMMON_PB_H_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/common/v1/common.pb.h") | ||
set(RESOURCE_PB_CPP_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/resource/v1/resource.pb.cc") | ||
set(RESOURCE_PB_H_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/resource/v1/resource.pb.h") | ||
set(TRACE_PB_CPP_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/trace/v1/trace.pb.cc") | ||
set(TRACE_PB_H_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/trace/v1/trace.pb.h") | ||
set(LOGS_PB_CPP_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/logs/v1/logs.pb.cc") | ||
set(LOGS_PB_H_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/logs/v1/logs.pb.h") | ||
set(METRICS_PB_CPP_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/metrics/v1/metrics.pb.cc") | ||
set(METRICS_PB_H_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/metrics/v1/metrics.pb.h") | ||
|
||
set(TRACE_SERVICE_PB_CPP_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/trace/v1/trace_service.pb.cc" | ||
) | ||
set(TRACE_SERVICE_PB_H_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/trace/v1/trace_service.pb.h" | ||
) | ||
set(TRACE_SERVICE_GRPC_PB_CPP_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.cc" | ||
) | ||
set(TRACE_SERVICE_GRPC_PB_H_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.h" | ||
) | ||
set(LOGS_SERVICE_PB_CPP_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/logs/v1/logs_service.pb.cc" | ||
) | ||
set(LOGS_SERVICE_PB_H_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/logs/v1/logs_service.pb.h" | ||
) | ||
set(LOGS_SERVICE_GRPC_PB_CPP_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/logs/v1/logs_service.grpc.pb.cc" | ||
) | ||
set(LOGS_SERVICE_GRPC_PB_H_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/logs/v1/logs_service.grpc.pb.h" | ||
) | ||
set(METRICS_SERVICE_PB_CPP_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/metrics/v1/metrics_service.pb.cc" | ||
) | ||
set(METRICS_SERVICE_PB_H_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/metrics/v1/metrics_service.pb.h" | ||
) | ||
set(METRICS_SERVICE_GRPC_PB_CPP_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.cc" | ||
) | ||
set(METRICS_SERVICE_GRPC_PB_H_FILE | ||
"${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.h" | ||
) | ||
|
||
foreach(IMPORT_DIR ${PROTOBUF_IMPORT_DIRS}) | ||
list(APPEND PROTOBUF_INCLUDE_FLAGS "-I${IMPORT_DIR}") | ||
endforeach() | ||
|
||
get_target_property(gRPC_CPP_PLUGIN_EXECUTABLE gRPC::grpc_cpp_plugin | ||
IMPORTED_LOCATION_RELEASE) | ||
|
||
add_custom_command( | ||
OUTPUT | ||
${COMMON_PB_H_FILE} | ||
${COMMON_PB_CPP_FILE} | ||
${RESOURCE_PB_H_FILE} | ||
${RESOURCE_PB_CPP_FILE} | ||
${TRACE_PB_H_FILE} | ||
${TRACE_PB_CPP_FILE} | ||
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} | ||
ARGS | ||
"--proto_path=${PROTO_PATH}" | ||
${PROTOBUF_INCLUDE_FLAGS} | ||
"--cpp_out=${GENERATED_PROTOBUF_PATH}" | ||
${COMMON_PROTO} | ||
${RESOURCE_PROTO} | ||
${TRACE_PROTO} | ||
) | ||
OUTPUT ${COMMON_PB_H_FILE} | ||
${COMMON_PB_CPP_FILE} | ||
${RESOURCE_PB_H_FILE} | ||
${RESOURCE_PB_CPP_FILE} | ||
${TRACE_PB_H_FILE} | ||
${TRACE_PB_CPP_FILE} | ||
${LOGS_PB_H_FILE} | ||
${LOGS_PB_CPP_FILE} | ||
${METRICS_PB_H_FILE} | ||
${METRICS_PB_CPP_FILE} | ||
${TRACE_SERVICE_PB_H_FILE} | ||
${TRACE_SERVICE_PB_CPP_FILE} | ||
${TRACE_SERVICE_GRPC_PB_H_FILE} | ||
${TRACE_SERVICE_GRPC_PB_CPP_FILE} | ||
${LOGS_SERVICE_PB_H_FILE} | ||
${LOGS_SERVICE_PB_CPP_FILE} | ||
${LOGS_SERVICE_GRPC_PB_H_FILE} | ||
${LOGS_SERVICE_GRPC_PB_CPP_FILE} | ||
${METRICS_SERVICE_PB_H_FILE} | ||
${METRICS_SERVICE_PB_CPP_FILE} | ||
${METRICS_SERVICE_GRPC_PB_H_FILE} | ||
${METRICS_SERVICE_GRPC_PB_CPP_FILE} | ||
COMMAND | ||
${PROTOBUF_PROTOC_EXECUTABLE} ARGS "--proto_path=${PROTO_PATH}" | ||
${PROTOBUF_INCLUDE_FLAGS} "--cpp_out=${GENERATED_PROTOBUF_PATH}" | ||
"--grpc_out=${GENERATED_PROTOBUF_PATH}" | ||
--plugin=protoc-gen-grpc="${gRPC_CPP_PLUGIN_EXECUTABLE}" ${COMMON_PROTO} | ||
${RESOURCE_PROTO} ${TRACE_PROTO} ${LOGS_PROTO} ${METRICS_PROTO} | ||
${TRACE_SERVICE_PROTO} ${LOGS_SERVICE_PROTO} ${METRICS_SERVICE_PROTO}) | ||
|
||
include_directories("${GENERATED_PROTOBUF_PATH}") | ||
|
||
add_library(opentelemetry_proto OBJECT | ||
${COMMON_PB_CPP_FILE} | ||
${RESOURCE_PB_CPP_FILE} | ||
${TRACE_PB_CPP_FILE}) | ||
if (BUILD_SHARED_LIBS) | ||
add_library( | ||
opentelemetry_proto OBJECT | ||
${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_GRPCPB_CPP_FILE} | ||
${METRICS_SERVICE_PB_CPP_FILE} | ||
${METRICS_SERVICE_GRPC_PB_CPP_FILE}) | ||
|
||
if(BUILD_SHARED_LIBS) | ||
set_property(TARGET opentelemetry_proto PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters