FindProcstat.cmake 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # SPDX-FileCopyrightText: 2019 Tobias C. Berner <tcberner@FreeBSD.org>
  2. #
  3. # SPDX-License-Identifier: BSD-2-Clause
  4. #[=======================================================================[.rst:
  5. FindProcstat
  6. -------
  7. Finds the procstat library.
  8. Imported Targets
  9. ^^^^^^^^^^^^^^^^
  10. This module provides the following imported targets, if found:
  11. ``Procstat::Procstat``
  12. The procstat library
  13. Result Variables
  14. ^^^^^^^^^^^^^^^^
  15. This will define the following variables:
  16. ``Procstat_FOUND``
  17. True if the system has the libprocstat library.
  18. ``Procstat_INCLUDE_DIRS``
  19. Include directories needed to use procstat.
  20. ``Procstat_LIBRARIES``
  21. Libraries needed to link to libprocstat.
  22. #]=======================================================================]
  23. find_path(Procstat_INCLUDE_DIRS libprocstat.h)
  24. find_library(Procstat_LIBRARIES NAMES procstat)
  25. include(FindPackageHandleStandardArgs)
  26. find_package_handle_standard_args(Procstat DEFAULT_MSG Procstat_INCLUDE_DIRS Procstat_LIBRARIES)
  27. set_package_properties(Procstat PROPERTIES
  28. URL "https://github.com/freebsd/freebsd/tree/master/lib/libprocstat"
  29. DESCRIPTION "Library to access process information"
  30. )
  31. mark_as_advanced(Procstat_INCLUDE_DIRS Procstat_LIBRARIES)
  32. if(Procstat_FOUND AND NOT TARGET Procstat::Procstat)
  33. add_library(Procstat::Procstat UNKNOWN IMPORTED)
  34. set_target_properties(Procstat::Procstat PROPERTIES
  35. IMPORTED_LOCATION "${Procstat_LIBRARIES}"
  36. INTERFACE_INCLUDE_DIRECTORIES "${Procstat_INCLUDE_DIRS}"
  37. )
  38. endif()