FindPrometheus.cmake 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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, promhttp, 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_promhttp QUIET promhttp)
  18. pkg_check_modules(PC_microhttd QUIET microhttpd)
  19. find_path(microhttpd_include_dir
  20. NAMES microhttpd.h
  21. HINTS ${Prometheus_DIR} ${Prometheus_ROOT} ${PC_microhttd_INCLUDE_DIRS} /usr
  22. PATHS $ENV{Prometheus_DIR} $ENV{Prometheus_ROOT}
  23. PATH_SUFFIXES include
  24. )
  25. find_library(
  26. microhttpd_libs
  27. NAMES microhttpd
  28. HINTS ${Prometheus_DIR} ${Prometheus_ROOT} ${PC_microhttd_LIBRARY_DIRS}
  29. PATHS $ENV{Prometheus_DIR} $ENV{Prometheus_ROOT}
  30. PATH_SUFFIXES lib ${CMAKE_INSTALL_LIBDIR})
  31. find_path(prom_INCLUDE_DIR
  32. NAMES prom.h
  33. HINTS ${Prometheus_DIR} ${Prometheus_ROOT} ${PC_prom_INCLUDE_DIRS} /usr
  34. PATHS $ENV{Prometheus_DIR} $ENV{Prometheus_ROOT}
  35. PATH_SUFFIXES include
  36. )
  37. find_library(
  38. prom_libs
  39. NAMES prom
  40. HINTS ${Prometheus_DIR} ${Prometheus_ROOT} ${PC_prom_LIBRARY_DIRS}
  41. PATHS $ENV{Prometheus_DIR} $ENV{Prometheus_ROOT}
  42. PATH_SUFFIXES lib ${CMAKE_INSTALL_LIBDIR})
  43. find_path(promhttp_INCLUDE_DIR
  44. NAMES promhttp.h
  45. HINTS ${Prometheus_DIR} ${Prometheus_ROOT} ${PC_promhttp_INCLUDE_DIRS} /usr
  46. PATHS $ENV{Prometheus_DIR} $ENV{Prometheus_ROOT}
  47. PATH_SUFFIXES include
  48. )
  49. find_library(
  50. promhttp_libs
  51. NAMES promhttp
  52. HINTS ${Prometheus_DIR} ${Prometheus_ROOT} ${PC_promhttp_LIBRARY_DIRS}
  53. PATHS $ENV{Prometheus_DIR} $ENV{Prometheus_ROOT}
  54. PATH_SUFFIXES lib ${CMAKE_INSTALL_LIBDIR})
  55. find_package_handle_standard_args(Prometheus
  56. REQUIRED_VARS prom_libs prom_INCLUDE_DIR
  57. promhttp_libs promhttp_INCLUDE_DIR
  58. microhttpd_include_dir microhttpd_libs
  59. )
  60. set(Prometheus_INCLUDE_DIRS
  61. ${prom_INCLUDE_DIR}
  62. ${promhttp_INCLUDE_DIR}
  63. ${microhttpd_include_dir})
  64. set(Prometheus_LIBRARIES ${prom_libs} ${promhttp_libs} ${microhttpd_libs})