FindLibpci.cmake 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # cmake-format: off
  2. # * Try to find Libpci Once done this will define
  3. #
  4. # * LIBPCI_FOUND - system has Libpci
  5. # * LIBPCI_INCLUDE_DIRS - the Libpci include directory
  6. # * LIBPCI_LIBRARIES - the libraries needed to use Libpci
  7. # * LIBPCI_DEFINITIONS - Compiler switches required for using Libpci
  8. # Use pkg-config to get the directories and then use these values in the
  9. # find_path() and find_library() calls
  10. # cmake-format: on
  11. find_package(PkgConfig QUIET)
  12. if(PKG_CONFIG_FOUND)
  13. pkg_check_modules(_LIBPCI libpci)
  14. endif()
  15. find_path(
  16. LIBPCI_INCLUDE_DIR
  17. NAMES pci.h
  18. HINTS ${_LIBPCI_INCLUDE_DIRS}
  19. PATHS /usr/include /usr/local/include /opt/local/include
  20. PATH_SUFFIXES pci/)
  21. find_library(
  22. LIBPCI_LIB
  23. NAMES ${_LIBPCI_LIBRARIES} libpci
  24. HINTS ${_LIBPCI_LIBRARY_DIRS}
  25. PATHS /usr/lib /usr/local/lib /opt/local/lib)
  26. include(FindPackageHandleStandardArgs)
  27. find_package_handle_standard_args(Libpci REQUIRED_VARS LIBPCI_LIB LIBPCI_INCLUDE_DIR)
  28. mark_as_advanced(LIBPCI_INCLUDE_DIR LIBPCI_LIB)
  29. if(LIBPCI_FOUND)
  30. set(LIBPCI_INCLUDE_DIRS ${LIBPCI_INCLUDE_DIR})
  31. set(LIBPCI_LIBRARIES ${LIBPCI_LIB})
  32. if(NOT TARGET LIBPCI::LIBPCI)
  33. if(IS_ABSOLUTE "${LIBPCI_LIBRARIES}")
  34. add_library(LIBPCI::LIBPCI UNKNOWN IMPORTED)
  35. set_target_properties(LIBPCI::LIBPCI PROPERTIES IMPORTED_LOCATION "${LIBPCI_LIBRARIES}")
  36. else()
  37. add_library(LIBPCI::LIBPCI INTERFACE IMPORTED)
  38. set_target_properties(LIBPCI::LIBPCI PROPERTIES IMPORTED_LIBNAME "${LIBPCI_LIBRARIES}")
  39. endif()
  40. endif()
  41. endif()