FindPrometheus.cmake 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Author: Kang Lin ([email protected])
  2. #
  3. # Find Prometheus.
  4. #
  5. # Set this variable to any additional path you want the module to search:
  6. # Prometheus_DIR or Prometheus_ROOT
  7. #
  8. # Try to find prometheus
  9. # Once done, this will define:
  10. # Prometheus_FOUND - Prometheus (or all requested components of prom, microhttpd) was found.
  11. # Prometheus_INCLUDE_DIRS - Libevent include directories
  12. # Prometheus_LIBRARIES - libraries needed to use Prometheus
  13. #
  14. include(FindPackageHandleStandardArgs)
  15. find_package(PkgConfig)
  16. pkg_check_modules(PC_prom QUIET prom)
  17. pkg_check_modules(PC_microhttd QUIET microhttpd)
  18. find_path(microhttpd_include_dir
  19. NAMES microhttpd.h
  20. HINTS ${Prometheus_DIR} ${Prometheus_ROOT} ${PC_microhttd_INCLUDE_DIRS} /usr
  21. PATHS $ENV{Prometheus_DIR} $ENV{Prometheus_ROOT}
  22. PATH_SUFFIXES include
  23. )
  24. find_library(
  25. microhttpd_libs
  26. NAMES microhttpd
  27. HINTS ${Prometheus_DIR} ${Prometheus_ROOT} ${PC_microhttd_LIBRARY_DIRS}
  28. PATHS $ENV{Prometheus_DIR} $ENV{Prometheus_ROOT}
  29. PATH_SUFFIXES lib ${CMAKE_INSTALL_LIBDIR})
  30. find_path(prom_INCLUDE_DIR
  31. NAMES prom.h
  32. HINTS ${Prometheus_DIR} ${Prometheus_ROOT} ${PC_prom_INCLUDE_DIRS} /usr
  33. PATHS $ENV{Prometheus_DIR} $ENV{Prometheus_ROOT}
  34. PATH_SUFFIXES include
  35. )
  36. find_library(
  37. prom_libs
  38. NAMES prom
  39. HINTS ${Prometheus_DIR} ${Prometheus_ROOT} ${PC_prom_LIBRARY_DIRS}
  40. PATHS $ENV{Prometheus_DIR} $ENV{Prometheus_ROOT}
  41. PATH_SUFFIXES lib ${CMAKE_INSTALL_LIBDIR})
  42. find_package_handle_standard_args(Prometheus
  43. REQUIRED_VARS prom_libs prom_INCLUDE_DIR
  44. microhttpd_include_dir microhttpd_libs
  45. )
  46. set(Prometheus_INCLUDE_DIRS
  47. ${prom_INCLUDE_DIR}
  48. ${microhttpd_include_dir})
  49. set(Prometheus_LIBRARIES ${prom_libs} ${microhttpd_libs})