Skip to content

Commit 02e6ad2

Browse files
authored
[BUILD] Do not link prometheus-cpp::util when it doesn't exist (open-telemetry#2606)
1 parent 9500c12 commit 02e6ad2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

exporters/prometheus/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ endif()
3030
if(TARGET util)
3131
list(APPEND PROMETHEUS_EXPORTER_TARGETS util)
3232
endif()
33-
target_link_libraries(
34-
opentelemetry_exporter_prometheus
35-
PUBLIC opentelemetry_metrics prometheus-cpp::pull prometheus-cpp::core
36-
prometheus-cpp::util)
33+
set(PROMETHEUS_CPP_TARGETS prometheus-cpp::pull prometheus-cpp::core)
34+
if(TARGET prometheus-cpp::util)
35+
list(APPEND PROMETHEUS_CPP_TARGETS prometheus-cpp::util)
36+
endif()
37+
target_link_libraries(opentelemetry_exporter_prometheus
38+
PUBLIC opentelemetry_metrics ${PROMETHEUS_CPP_TARGETS})
3739

3840
if(OPENTELEMETRY_INSTALL)
3941
install(

0 commit comments

Comments
 (0)