Skip to content

Commit

Permalink
Build Metrics into DLL
Browse files Browse the repository at this point in the history
Signed-off-by: Harish Shan <140232061+perhapsmaple@users.noreply.github.com>
  • Loading branch information
perhapsmaple committed Oct 7, 2023
1 parent a177289 commit 606aebb
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
8 changes: 7 additions & 1 deletion examples/common/metrics_foo_library/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

if(DEFINED OPENTELEMETRY_BUILD_DLL)
add_definitions(-DOPENTELEMETRY_BUILD_IMPORT_DLL)
endif()

add_library(common_metrics_foo_library foo_library.h foo_library.cc)
set_target_version(common_metrics_foo_library)
target_link_libraries(common_metrics_foo_library PUBLIC opentelemetry_api)

target_link_libraries(common_metrics_foo_library PUBLIC ${CMAKE_THREAD_LIBS_INIT}
opentelemetry_api)
18 changes: 14 additions & 4 deletions examples/metrics_simple/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

if(DEFINED OPENTELEMETRY_BUILD_DLL)
add_definitions(-DOPENTELEMETRY_BUILD_IMPORT_DLL)
endif()

include_directories(${CMAKE_SOURCE_DIR}/exporters/ostream/include)

add_executable(metrics_ostream_example metrics_ostream.cc)
target_link_libraries(
metrics_ostream_example ${CMAKE_THREAD_LIBS_INIT} opentelemetry_metrics
opentelemetry_exporter_ostream_metrics opentelemetry_resources
common_metrics_foo_library)
target_link_libraries(metrics_ostream_example ${CMAKE_THREAD_LIBS_INIT}
common_metrics_foo_library)

if(DEFINED OPENTELEMETRY_BUILD_DLL)
target_link_libraries(metrics_ostream_example opentelemetry_cpp)
else()
target_link_libraries(metrics_ostream_example opentelemetry_metrics
opentelemetry_exporter_ostream_metrics opentelemetry_resources)
endif()
28 changes: 20 additions & 8 deletions examples/otlp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ if(WITH_OTLP_GRPC)

add_executable(example_otlp_grpc_metric grpc_metric_main.cc)

target_link_libraries(
example_otlp_grpc_metric ${CMAKE_THREAD_LIBS_INIT}
common_metrics_foo_library opentelemetry_metrics
opentelemetry_exporter_otlp_grpc_metrics)
target_link_libraries(example_otlp_grpc_metric ${CMAKE_THREAD_LIBS_INIT}
common_metrics_foo_library)

if(DEFINED OPENTELEMETRY_BUILD_DLL)
target_link_libraries(example_otlp_grpc_metric opentelemetry_cpp)
else()
target_link_libraries(example_otlp_grpc_metric opentelemetry_metrics
opentelemetry_exporter_otlp_grpc_metrics)
endif()

# LOG

Expand Down Expand Up @@ -66,10 +71,17 @@ if(WITH_OTLP_HTTP)
# METRIC

add_executable(example_otlp_http_metric http_metric_main.cc)
target_link_libraries(
example_otlp_http_metric ${CMAKE_THREAD_LIBS_INIT}
common_metrics_foo_library opentelemetry_metrics
opentelemetry_exporter_otlp_http_metric)
target_link_libraries(example_otlp_http_metric ${CMAKE_THREAD_LIBS_INIT}
common_metrics_foo_library)

if(DEFINED OPENTELEMETRY_BUILD_DLL)
target_link_libraries(example_otlp_http_metric opentelemetry_cpp
opentelemetry_common)
else()
target_link_libraries(
example_otlp_http_metric common_metrics_foo_library opentelemetry_metrics
opentelemetry_exporter_otlp_http_metric)
endif()

# LOG

Expand Down

0 comments on commit 606aebb

Please sign in to comment.