Skip to content

Commit e664863

Browse files
authored
add versioned libraries (#275)
1 parent c281184 commit e664863

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

exporters/geneva/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
99
project(opentelemetry-geneva-metrics)
1010
set(MAIN_PROJECT ON)
1111
endif()
12+
option(OTELCPP_VERSIONED_LIBS "Whether to generate the versioned shared libs"
13+
OFF)
14+
if(OTELCPP_VERSIONED_LIBS AND NOT BUILD_SHARED_LIBS)
15+
message(FATAL_ERROR "OTELCPP_VERSIONED_LIBS=ON requires BUILD_SHARED_LIBS=ON")
16+
endif()
17+
1218

1319
if(NOT WIN32)
1420
find_package(CURL REQUIRED)
@@ -21,6 +27,17 @@ endif()
2127

2228
include_directories(include)
2329

30+
set(OTEL_GENEVA_EXPORTER_VERSION 1.0.0)
31+
set(OTEL_GENEVA_EXPORTER_MAJOR_VERSION 1)
32+
33+
function(set_target_version target_name)
34+
if(OTELCPP_VERSIONED_LIBS)
35+
set_target_properties(
36+
${target_name} PROPERTIES VERSION ${OTEL_GENEVA_EXPORTER_VERSION}
37+
SOVERSION ${OTEL_GENEVA_EXPORTER_MAJOR_VERSION})
38+
endif()
39+
endfunction()
40+
2441
# create geneva metrics exporter
2542
if(WIN32)
2643
add_library(
@@ -44,6 +61,8 @@ endif()
4461

4562
set_target_properties(opentelemetry_exporter_geneva_metrics
4663
PROPERTIES EXPORT_NAME metrics)
64+
set_target_version(opentelemetry_exporter_geneva_metrics)
65+
4766
if(BUILD_TESTING)
4867
if(EXISTS ${CMAKE_BINARY_DIR}/lib/libgtest.a)
4968
# Prefer GTest from build tree. GTest is not always working with

0 commit comments

Comments
 (0)