CMakeLists.txt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Copyright The OpenTelemetry Authors
  2. # SPDX-License-Identifier: Apache-2.0
  3. if(NOT TARGET prometheus-cpp::core)
  4. find_package(prometheus-cpp CONFIG REQUIRED)
  5. endif()
  6. add_library(
  7. opentelemetry_exporter_prometheus
  8. src/exporter.cc src/exporter_options.cc src/exporter_factory.cc
  9. src/collector.cc src/exporter_utils.cc)
  10. set_target_properties(opentelemetry_exporter_prometheus
  11. PROPERTIES EXPORT_NAME prometheus_exporter)
  12. set_target_version(opentelemetry_exporter_prometheus)
  13. target_include_directories(
  14. opentelemetry_exporter_prometheus
  15. PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
  16. "$<INSTALL_INTERFACE:include>")
  17. set(PROMETHEUS_EXPORTER_TARGETS opentelemetry_exporter_prometheus)
  18. if(TARGET pull)
  19. list(APPEND PROMETHEUS_EXPORTER_TARGETS pull)
  20. endif()
  21. if(TARGET core)
  22. list(APPEND PROMETHEUS_EXPORTER_TARGETS core)
  23. endif()
  24. if(TARGET util)
  25. list(APPEND PROMETHEUS_EXPORTER_TARGETS util)
  26. endif()
  27. set(PROMETHEUS_CPP_TARGETS prometheus-cpp::pull prometheus-cpp::core)
  28. if(TARGET prometheus-cpp::util)
  29. list(APPEND PROMETHEUS_CPP_TARGETS prometheus-cpp::util)
  30. endif()
  31. target_link_libraries(opentelemetry_exporter_prometheus
  32. PUBLIC opentelemetry_metrics ${PROMETHEUS_CPP_TARGETS})
  33. otel_add_component(
  34. COMPONENT
  35. exporters_prometheus
  36. TARGETS
  37. opentelemetry_exporter_prometheus
  38. FILES_DIRECTORY
  39. "include/opentelemetry/exporters/prometheus"
  40. FILES_DESTINATION
  41. "include/opentelemetry/exporters"
  42. FILES_MATCHING
  43. PATTERN
  44. "*.h")
  45. if(BUILD_TESTING)
  46. add_subdirectory(test)
  47. endif()