Skip to content
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] shared libraries with version suffix, along with the symbolic link #2109

Merged
merged 7 commits into from
Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ option(OTELCPP_MAINTAINER_MODE "Build in maintainer mode (-Wall -Werror)" OFF)

option(WITH_OPENTRACING "Whether to include the Opentracing shim" OFF)

option(OTELCPP_VERSIONED_LIBS "Whether to generate the versioned shared libs"
OFF)

marcalff marked this conversation as resolved.
Show resolved Hide resolved
set(OTELCPP_PROTO_PATH
""
CACHE PATH "Path to opentelemetry-proto")
Expand Down Expand Up @@ -267,6 +270,14 @@ function(install_windows_deps)
PARENT_SCOPE)
endfunction()

function(set_target_version target_name)
if(OTELCPP_VERSIONED_LIBS)
set_target_properties(
${target_name} PROPERTIES VERSION ${OPENTELEMETRY_VERSION}
SOVERSION ${OPENTELEMETRY_ABI_VERSION_NO})
endif()
endfunction()

if(WITH_JAEGER)
if(WITH_NO_DEPRECATED_CODE)
message(FATAL_ERROR "Jaeger is DEPRECATED.")
Expand Down
2 changes: 2 additions & 0 deletions examples/common/foo_library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ if(DEFINED OPENTELEMETRY_BUILD_DLL)
endif()

add_library(common_foo_library foo_library.h foo_library.cc)
set_target_version(common_foo_library)

target_link_libraries(common_foo_library PUBLIC ${CMAKE_THREAD_LIBS_INIT}
opentelemetry_api)
2 changes: 2 additions & 0 deletions examples/common/logs_foo_library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ if(DEFINED OPENTELEMETRY_BUILD_DLL)
endif()

add_library(common_logs_foo_library foo_library.h foo_library.cc)
set_target_version(common_logs_foo_library)

target_link_libraries(common_logs_foo_library PUBLIC ${CMAKE_THREAD_LIBS_INIT}
opentelemetry_api)
1 change: 1 addition & 0 deletions examples/common/metrics_foo_library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
# SPDX-License-Identifier: Apache-2.0

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)
1 change: 1 addition & 0 deletions exporters/elasticsearch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ add_library(opentelemetry_exporter_elasticsearch_logs

set_target_properties(opentelemetry_exporter_elasticsearch_logs
PROPERTIES EXPORT_NAME elasticsearch_log_record_exporter)
set_target_version(opentelemetry_exporter_elasticsearch_logs)

target_include_directories(
opentelemetry_exporter_elasticsearch_logs
Expand Down
1 change: 1 addition & 0 deletions exporters/jaeger/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ add_library(opentelemetry_exporter_jaeger_trace ${JAEGER_EXPORTER_SOURCES}

set_target_properties(opentelemetry_exporter_jaeger_trace
PROPERTIES EXPORT_NAME jaeger_trace_exporter)
set_target_version(opentelemetry_exporter_jaeger_trace)

target_include_directories(
opentelemetry_exporter_jaeger_trace
Expand Down
1 change: 1 addition & 0 deletions exporters/memory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ target_include_directories(

set_target_properties(opentelemetry_exporter_in_memory
PROPERTIES EXPORT_NAME in_memory_span_exporter)
set_target_version(opentelemetry_exporter_in_memory)

target_link_libraries(opentelemetry_exporter_in_memory
PUBLIC opentelemetry_trace)
Expand Down
5 changes: 5 additions & 0 deletions exporters/ostream/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ add_library(opentelemetry_exporter_ostream_span src/span_exporter.cc

set_target_properties(opentelemetry_exporter_ostream_span
PROPERTIES EXPORT_NAME ostream_span_exporter)
set_target_version(opentelemetry_exporter_ostream_span)

target_include_directories(
opentelemetry_exporter_ostream_span
Expand Down Expand Up @@ -42,6 +43,8 @@ endif() # BUILD_TESTING
add_library(opentelemetry_exporter_ostream_metrics src/metric_exporter.cc)
set_target_properties(opentelemetry_exporter_ostream_metrics
PROPERTIES EXPORT_NAME ostream_metrics_exporter)
set_target_version(opentelemetry_exporter_ostream_metrics)

target_include_directories(
opentelemetry_exporter_ostream_metrics
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>")
Expand Down Expand Up @@ -76,6 +79,8 @@ if(WITH_LOGS_PREVIEW)
add_library(opentelemetry_exporter_ostream_logs src/log_record_exporter.cc)
set_target_properties(opentelemetry_exporter_ostream_logs
PROPERTIES EXPORT_NAME ostream_log_record_exporter)
set_target_version(opentelemetry_exporter_ostream_logs)

target_include_directories(
opentelemetry_exporter_ostream_logs
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>")
Expand Down
11 changes: 11 additions & 0 deletions exporters/otlp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ add_library(
src/otlp_metric_utils.cc)
set_target_properties(opentelemetry_otlp_recordable PROPERTIES EXPORT_NAME
otlp_recordable)
set_target_version(opentelemetry_otlp_recordable)

target_include_directories(
opentelemetry_otlp_recordable
Expand All @@ -31,6 +32,8 @@ if(WITH_OTLP_GRPC)
src/otlp_grpc_utils.cc)
set_target_properties(opentelemetry_exporter_otlp_grpc_client
PROPERTIES EXPORT_NAME otlp_grpc_client)
set_target_version(opentelemetry_exporter_otlp_grpc_client)

target_link_libraries(
opentelemetry_exporter_otlp_grpc_client
PUBLIC opentelemetry_sdk opentelemetry_ext opentelemetry_proto)
Expand All @@ -57,6 +60,7 @@ if(WITH_OTLP_GRPC)

set_target_properties(opentelemetry_exporter_otlp_grpc
PROPERTIES EXPORT_NAME otlp_grpc_exporter)
set_target_version(opentelemetry_exporter_otlp_grpc)

target_link_libraries(
opentelemetry_exporter_otlp_grpc
Expand All @@ -72,6 +76,7 @@ if(WITH_OTLP_GRPC)

set_target_properties(opentelemetry_exporter_otlp_grpc_log
PROPERTIES EXPORT_NAME otlp_grpc_log_record_exporter)
set_target_version(opentelemetry_exporter_otlp_grpc_log)

target_link_libraries(
opentelemetry_exporter_otlp_grpc_log
Expand All @@ -86,6 +91,7 @@ if(WITH_OTLP_GRPC)

set_target_properties(opentelemetry_exporter_otlp_grpc_metrics
PROPERTIES EXPORT_NAME otlp_grpc_metrics_exporter)
set_target_version(opentelemetry_exporter_otlp_grpc_metrics)

target_link_libraries(
opentelemetry_exporter_otlp_grpc_metrics
Expand All @@ -100,6 +106,8 @@ if(WITH_OTLP_HTTP)
add_library(opentelemetry_exporter_otlp_http_client src/otlp_http_client.cc)
set_target_properties(opentelemetry_exporter_otlp_http_client
PROPERTIES EXPORT_NAME otlp_http_client)
set_target_version(opentelemetry_exporter_otlp_http_client)

target_link_libraries(
opentelemetry_exporter_otlp_http_client
PUBLIC opentelemetry_sdk opentelemetry_proto opentelemetry_http_client_curl
Expand All @@ -121,6 +129,7 @@ if(WITH_OTLP_HTTP)

set_target_properties(opentelemetry_exporter_otlp_http
PROPERTIES EXPORT_NAME otlp_http_exporter)
set_target_version(opentelemetry_exporter_otlp_http)

target_link_libraries(
opentelemetry_exporter_otlp_http
Expand All @@ -137,6 +146,7 @@ if(WITH_OTLP_HTTP)

set_target_properties(opentelemetry_exporter_otlp_http_log
PROPERTIES EXPORT_NAME otlp_http_log_record_exporter)
set_target_version(opentelemetry_exporter_otlp_http_log)

target_link_libraries(
opentelemetry_exporter_otlp_http_log
Expand All @@ -152,6 +162,7 @@ if(WITH_OTLP_HTTP)

set_target_properties(opentelemetry_exporter_otlp_http_metric
PROPERTIES EXPORT_NAME otlp_http_metric_exporter)
set_target_version(opentelemetry_exporter_otlp_http_metric)

target_link_libraries(
opentelemetry_exporter_otlp_http_metric
Expand Down
2 changes: 2 additions & 0 deletions exporters/prometheus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ add_library(opentelemetry_exporter_prometheus src/exporter.cc src/collector.cc

set_target_properties(opentelemetry_exporter_prometheus
PROPERTIES EXPORT_NAME prometheus_exporter)
set_target_version(opentelemetry_exporter_prometheus)

target_include_directories(
opentelemetry_exporter_prometheus
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
Expand Down
2 changes: 2 additions & 0 deletions exporters/zipkin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ target_include_directories(
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:include>")

set_target_version(opentelemetry_exporter_zipkin_trace)

target_link_libraries(
opentelemetry_exporter_zipkin_trace
PUBLIC opentelemetry_trace opentelemetry_http_client_curl
Expand Down
1 change: 1 addition & 0 deletions ext/src/http/client/curl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ add_library(

set_target_properties(opentelemetry_http_client_curl
PROPERTIES EXPORT_NAME http_client_curl)
set_target_version(opentelemetry_http_client_curl)

if(TARGET CURL::libcurl)
target_link_libraries(
Expand Down
1 change: 1 addition & 0 deletions ext/src/zpages/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ add_library(
../../include/opentelemetry/ext/zpages/tracez_http_server.h)

set_target_properties(opentelemetry_zpages PROPERTIES EXPORT_NAME zpages)
set_target_version(opentelemetry_zpages)

target_link_libraries(opentelemetry_zpages PUBLIC opentelemetry_ext
opentelemetry_trace)
Expand Down
1 change: 1 addition & 0 deletions opentracing-shim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ add_library(${this_target} src/shim_utils.cc src/span_shim.cc
src/span_context_shim.cc src/tracer_shim.cc)

set_target_properties(${this_target} PROPERTIES EXPORT_NAME opentracing_shim)
set_target_version(${this_target})

target_include_directories(
${this_target} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
Expand Down
1 change: 1 addition & 0 deletions sdk/src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ endif()
add_library(opentelemetry_common ${COMMON_SRCS})

set_target_properties(opentelemetry_common PROPERTIES EXPORT_NAME common)
set_target_version(opentelemetry_common)

target_link_libraries(
opentelemetry_common PUBLIC opentelemetry_api opentelemetry_sdk
Expand Down
1 change: 1 addition & 0 deletions sdk/src/logs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ set_target_properties(opentelemetry_logs PROPERTIES EXPORT_NAME logs)

target_link_libraries(opentelemetry_logs PUBLIC opentelemetry_resources
opentelemetry_common)
set_target_version(opentelemetry_logs)

target_include_directories(
opentelemetry_logs
Expand Down
1 change: 1 addition & 0 deletions sdk/src/metrics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ add_library(
sync_instruments.cc)

set_target_properties(opentelemetry_metrics PROPERTIES EXPORT_NAME metrics)
set_target_version(opentelemetry_metrics)

target_link_libraries(opentelemetry_metrics PUBLIC opentelemetry_common)

Expand Down
1 change: 1 addition & 0 deletions sdk/src/resource/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
add_library(opentelemetry_resources resource.cc resource_detector.cc)

set_target_properties(opentelemetry_resources PROPERTIES EXPORT_NAME resources)
set_target_version(opentelemetry_resources)

target_link_libraries(opentelemetry_resources opentelemetry_common)

Expand Down
1 change: 1 addition & 0 deletions sdk/src/trace/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ add_library(
random_id_generator_factory.cc)

set_target_properties(opentelemetry_trace PROPERTIES EXPORT_NAME trace)
set_target_version(opentelemetry_trace)

target_link_libraries(opentelemetry_trace PUBLIC opentelemetry_common
opentelemetry_resources)
Expand Down
1 change: 1 addition & 0 deletions sdk/src/version/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
add_library(opentelemetry_version version.cc)

set_target_properties(opentelemetry_version PROPERTIES EXPORT_NAME version)
set_target_version(opentelemetry_version)

target_link_libraries(opentelemetry_version PUBLIC opentelemetry_api
opentelemetry_sdk)
Expand Down