1
1
# Copyright The OpenTelemetry Authors
2
2
# SPDX-License-Identifier: Apache-2.0
3
3
4
+ if (protobuf_lib_type STREQUAL "STATIC_LIBRARY" )
5
+ set (OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE STATIC )
6
+ else ()
7
+ set (OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE )
8
+ endif ()
9
+
4
10
add_library (
5
11
opentelemetry_otlp_recordable
6
- src/otlp_environment.cc src/otlp_log_recordable.cc src/otlp_recordable.cc
7
- src/otlp_populate_attribute_utils.cc src/otlp_recordable_utils.cc
12
+ ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE}
13
+ src/otlp_environment.cc
14
+ src/otlp_log_recordable.cc
15
+ src/otlp_recordable.cc
16
+ src/otlp_populate_attribute_utils.cc
17
+ src/otlp_recordable_utils.cc
8
18
src/otlp_metric_utils.cc )
9
19
set_target_properties (opentelemetry_otlp_recordable PROPERTIES EXPORT_NAME
10
20
otlp_recordable )
@@ -23,10 +33,20 @@ target_link_libraries(opentelemetry_otlp_recordable
23
33
24
34
if (WITH_OTLP_GRPC )
25
35
find_package (gRPC REQUIRED )
36
+ if (NOT DEFINED grpc_lib_type )
37
+ message (
38
+ FATAL_ERROR "cmake/opentelemetry-proto.cmake should be included first" )
39
+ endif ()
40
+ if (grpc_lib_type STREQUAL "STATIC_LIBRARY" OR protobuf_lib_type STREQUAL
41
+ "STATIC_LIBRARY" )
42
+ set (OPENTELEMETRY_OTLP_GRPC_CLIENT_LIB_TYPE STATIC )
43
+ else ()
44
+ set (OPENTELEMETRY_OTLP_GRPC_CLIENT_LIB_TYPE )
45
+ endif ()
26
46
add_library (
27
47
opentelemetry_exporter_otlp_grpc_client
28
- src/otlp_grpc_client.cc src/otlp_grpc_client_factory .cc
29
- src/otlp_grpc_utils.cc )
48
+ ${OPENTELEMETRY_OTLP_GRPC_CLIENT_LIB_TYPE} src/otlp_grpc_client .cc
49
+ src/otlp_grpc_client_factory.cc src/ otlp_grpc_utils.cc )
30
50
set_target_properties (opentelemetry_exporter_otlp_grpc_client
31
51
PROPERTIES EXPORT_NAME otlp_grpc_client )
32
52
set_target_version (opentelemetry_exporter_otlp_grpc_client )
@@ -40,8 +60,9 @@ if(WITH_OTLP_GRPC)
40
60
opentelemetry_exporter_otlp_grpc_client
41
61
PUBLIC opentelemetry_sdk opentelemetry_common
42
62
# gRPC::grpc++ must be linked before opentelemetry_proto_grpc.
43
- opentelemetry_proto_grpc
44
- PRIVATE gRPC::grpc++ opentelemetry_ext )
63
+ "$<BUILD_INTERFACE:opentelemetry_proto_grpc>"
64
+ PRIVATE "$<INSTALL_INTERFACE:opentelemetry_proto_grpc>" gRPC::grpc++
65
+ opentelemetry_ext )
45
66
46
67
get_target_property (GRPC_INCLUDE_DIRECTORY gRPC::grpc++
47
68
INTERFACE_INCLUDE_DIRECTORIES )
@@ -60,8 +81,8 @@ if(WITH_OTLP_GRPC)
60
81
61
82
add_library (
62
83
opentelemetry_exporter_otlp_grpc
63
- src/otlp_grpc_exporter.cc src/otlp_grpc_exporter_factory .cc
64
- src/otlp_grpc_exporter_options.cc )
84
+ ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_grpc_exporter .cc
85
+ src/otlp_grpc_exporter_factory.cc src/ otlp_grpc_exporter_options.cc )
65
86
66
87
set_target_properties (opentelemetry_exporter_otlp_grpc
67
88
PROPERTIES EXPORT_NAME otlp_grpc_exporter )
@@ -76,7 +97,7 @@ if(WITH_OTLP_GRPC)
76
97
77
98
add_library (
78
99
opentelemetry_exporter_otlp_grpc_log
79
- src/otlp_grpc_log_record_exporter.cc
100
+ ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_grpc_log_record_exporter.cc
80
101
src/otlp_grpc_log_record_exporter_factory.cc
81
102
src/otlp_grpc_log_record_exporter_options.cc )
82
103
@@ -94,7 +115,8 @@ if(WITH_OTLP_GRPC)
94
115
95
116
add_library (
96
117
opentelemetry_exporter_otlp_grpc_metrics
97
- src/otlp_grpc_metric_exporter.cc src/otlp_grpc_metric_exporter_factory.cc
118
+ ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_grpc_metric_exporter.cc
119
+ src/otlp_grpc_metric_exporter_factory.cc
98
120
src/otlp_grpc_metric_exporter_options.cc )
99
121
100
122
set_target_properties (opentelemetry_exporter_otlp_grpc_metrics
@@ -111,8 +133,10 @@ if(WITH_OTLP_GRPC)
111
133
endif ()
112
134
113
135
if (WITH_OTLP_HTTP )
114
- add_library (opentelemetry_exporter_otlp_http_client src/otlp_http.cc
115
- src/otlp_http_client.cc )
136
+ add_library (
137
+ opentelemetry_exporter_otlp_http_client
138
+ ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_http.cc
139
+ src/otlp_http_client.cc )
116
140
set_target_properties (opentelemetry_exporter_otlp_http_client
117
141
PROPERTIES EXPORT_NAME otlp_http_client )
118
142
set_target_version (opentelemetry_exporter_otlp_http_client )
@@ -141,8 +165,8 @@ if(WITH_OTLP_HTTP)
141
165
142
166
add_library (
143
167
opentelemetry_exporter_otlp_http
144
- src/otlp_http_exporter.cc src/otlp_http_exporter_factory .cc
145
- src/otlp_http_exporter_options.cc )
168
+ ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_http_exporter .cc
169
+ src/otlp_http_exporter_factory.cc src/ otlp_http_exporter_options.cc )
146
170
147
171
set_target_properties (opentelemetry_exporter_otlp_http
148
172
PROPERTIES EXPORT_NAME otlp_http_exporter )
@@ -157,7 +181,7 @@ if(WITH_OTLP_HTTP)
157
181
158
182
add_library (
159
183
opentelemetry_exporter_otlp_http_log
160
- src/otlp_http_log_record_exporter.cc
184
+ ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_http_log_record_exporter.cc
161
185
src/otlp_http_log_record_exporter_factory.cc
162
186
src/otlp_http_log_record_exporter_options.cc )
163
187
@@ -175,7 +199,8 @@ if(WITH_OTLP_HTTP)
175
199
176
200
add_library (
177
201
opentelemetry_exporter_otlp_http_metric
178
- src/otlp_http_metric_exporter.cc src/otlp_http_metric_exporter_factory.cc
202
+ ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_http_metric_exporter.cc
203
+ src/otlp_http_metric_exporter_factory.cc
179
204
src/otlp_http_metric_exporter_options.cc )
180
205
181
206
set_target_properties (opentelemetry_exporter_otlp_http_metric
@@ -192,7 +217,8 @@ if(WITH_OTLP_HTTP)
192
217
endif ()
193
218
194
219
if (WITH_OTLP_FILE )
195
- add_library (opentelemetry_exporter_otlp_file_client src/otlp_file_client.cc )
220
+ add_library (opentelemetry_exporter_otlp_file_client
221
+ ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_file_client.cc )
196
222
set_target_properties (opentelemetry_exporter_otlp_file_client
197
223
PROPERTIES EXPORT_NAME otlp_file_client )
198
224
set_target_version (opentelemetry_exporter_otlp_file_client )
@@ -216,8 +242,8 @@ if(WITH_OTLP_FILE)
216
242
217
243
add_library (
218
244
opentelemetry_exporter_otlp_file
219
- src/otlp_file_exporter.cc src/otlp_file_exporter_factory .cc
220
- src/otlp_file_exporter_options.cc )
245
+ ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_file_exporter .cc
246
+ src/otlp_file_exporter_factory.cc src/ otlp_file_exporter_options.cc )
221
247
222
248
set_target_properties (opentelemetry_exporter_otlp_file
223
249
PROPERTIES EXPORT_NAME otlp_file_exporter )
@@ -232,7 +258,7 @@ if(WITH_OTLP_FILE)
232
258
233
259
add_library (
234
260
opentelemetry_exporter_otlp_file_log
235
- src/otlp_file_log_record_exporter.cc
261
+ ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_file_log_record_exporter.cc
236
262
src/otlp_file_log_record_exporter_factory.cc
237
263
src/otlp_file_log_record_exporter_options.cc )
238
264
@@ -250,7 +276,8 @@ if(WITH_OTLP_FILE)
250
276
251
277
add_library (
252
278
opentelemetry_exporter_otlp_file_metric
253
- src/otlp_file_metric_exporter.cc src/otlp_file_metric_exporter_factory.cc
279
+ ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_file_metric_exporter.cc
280
+ src/otlp_file_metric_exporter_factory.cc
254
281
src/otlp_file_metric_exporter_options.cc )
255
282
256
283
set_target_properties (opentelemetry_exporter_otlp_file_metric
@@ -371,7 +398,7 @@ if(BUILD_TESTING)
371
398
add_executable (otlp_grpc_exporter_test test /otlp_grpc_exporter_test.cc )
372
399
target_link_libraries (
373
400
otlp_grpc_exporter_test ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}
374
- ${GMOCK_LIB} opentelemetry_exporter_otlp_grpc gRPC::grpc++ )
401
+ ${GMOCK_LIB} opentelemetry_exporter_otlp_grpc )
375
402
gtest_add_tests (
376
403
TARGET otlp_grpc_exporter_test
377
404
TEST_PREFIX exporter.otlp.
0 commit comments