Skip to content

Commit 606aebb

Browse files
committed
Build Metrics into DLL
Signed-off-by: Harish Shan <140232061+perhapsmaple@users.noreply.github.com>
1 parent a177289 commit 606aebb

File tree

3 files changed

+41
-13
lines changed

3 files changed

+41
-13
lines changed
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Copyright The OpenTelemetry Authors
22
# SPDX-License-Identifier: Apache-2.0
33

4+
if(DEFINED OPENTELEMETRY_BUILD_DLL)
5+
add_definitions(-DOPENTELEMETRY_BUILD_IMPORT_DLL)
6+
endif()
7+
48
add_library(common_metrics_foo_library foo_library.h foo_library.cc)
59
set_target_version(common_metrics_foo_library)
6-
target_link_libraries(common_metrics_foo_library PUBLIC opentelemetry_api)
10+
11+
target_link_libraries(common_metrics_foo_library PUBLIC ${CMAKE_THREAD_LIBS_INIT}
12+
opentelemetry_api)
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
# Copyright The OpenTelemetry Authors
22
# SPDX-License-Identifier: Apache-2.0
33

4+
if(DEFINED OPENTELEMETRY_BUILD_DLL)
5+
add_definitions(-DOPENTELEMETRY_BUILD_IMPORT_DLL)
6+
endif()
7+
48
include_directories(${CMAKE_SOURCE_DIR}/exporters/ostream/include)
9+
510
add_executable(metrics_ostream_example metrics_ostream.cc)
6-
target_link_libraries(
7-
metrics_ostream_example ${CMAKE_THREAD_LIBS_INIT} opentelemetry_metrics
8-
opentelemetry_exporter_ostream_metrics opentelemetry_resources
9-
common_metrics_foo_library)
11+
target_link_libraries(metrics_ostream_example ${CMAKE_THREAD_LIBS_INIT}
12+
common_metrics_foo_library)
13+
14+
if(DEFINED OPENTELEMETRY_BUILD_DLL)
15+
target_link_libraries(metrics_ostream_example opentelemetry_cpp)
16+
else()
17+
target_link_libraries(metrics_ostream_example opentelemetry_metrics
18+
opentelemetry_exporter_ostream_metrics opentelemetry_resources)
19+
endif()

examples/otlp/CMakeLists.txt

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@ if(WITH_OTLP_GRPC)
2828

2929
add_executable(example_otlp_grpc_metric grpc_metric_main.cc)
3030

31-
target_link_libraries(
32-
example_otlp_grpc_metric ${CMAKE_THREAD_LIBS_INIT}
33-
common_metrics_foo_library opentelemetry_metrics
34-
opentelemetry_exporter_otlp_grpc_metrics)
31+
target_link_libraries(example_otlp_grpc_metric ${CMAKE_THREAD_LIBS_INIT}
32+
common_metrics_foo_library)
33+
34+
if(DEFINED OPENTELEMETRY_BUILD_DLL)
35+
target_link_libraries(example_otlp_grpc_metric opentelemetry_cpp)
36+
else()
37+
target_link_libraries(example_otlp_grpc_metric opentelemetry_metrics
38+
opentelemetry_exporter_otlp_grpc_metrics)
39+
endif()
3540

3641
# LOG
3742

@@ -66,10 +71,17 @@ if(WITH_OTLP_HTTP)
6671
# METRIC
6772

6873
add_executable(example_otlp_http_metric http_metric_main.cc)
69-
target_link_libraries(
70-
example_otlp_http_metric ${CMAKE_THREAD_LIBS_INIT}
71-
common_metrics_foo_library opentelemetry_metrics
72-
opentelemetry_exporter_otlp_http_metric)
74+
target_link_libraries(example_otlp_http_metric ${CMAKE_THREAD_LIBS_INIT}
75+
common_metrics_foo_library)
76+
77+
if(DEFINED OPENTELEMETRY_BUILD_DLL)
78+
target_link_libraries(example_otlp_http_metric opentelemetry_cpp
79+
opentelemetry_common)
80+
else()
81+
target_link_libraries(
82+
example_otlp_http_metric common_metrics_foo_library opentelemetry_metrics
83+
opentelemetry_exporter_otlp_http_metric)
84+
endif()
7385

7486
# LOG
7587

0 commit comments

Comments
 (0)