FindLibpci.cmake 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # * Try to find Libpci
  2. # 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. find_package(PkgConfig QUIET)
  11. if(PKG_CONFIG_FOUND)
  12. pkg_check_modules(_LIBPCI libpci)
  13. endif()
  14. find_path(
  15. LIBPCI_INCLUDE_DIR
  16. NAMES pci.h
  17. HINTS ${_LIBPCI_INCLUDE_DIRS}
  18. PATHS /usr/include /usr/local/include /opt/local/include
  19. PATH_SUFFIXES pci/)
  20. find_library(
  21. LIBPCI_LIB
  22. NAMES ${_LIBPCI_LIBRARIES} libpci
  23. HINTS ${_LIBPCI_LIBRARY_DIRS}
  24. PATHS /usr/lib /usr/local/lib /opt/local/lib)
  25. include(FindPackageHandleStandardArgs)
  26. find_package_handle_standard_args(Libpci REQUIRED_VARS LIBPCI_LIB LIBPCI_INCLUDE_DIR)
  27. mark_as_advanced(LIBPCI_INCLUDE_DIR LIBPCI_LIB)
  28. if(LIBPCI_FOUND)
  29. set(LIBPCI_INCLUDE_DIRS ${LIBPCI_INCLUDE_DIR})
  30. set(LIBPCI_LIBRARIES ${LIBPCI_LIB})
  31. if(NOT TARGET LIBPCI::LIBPCI)
  32. if(IS_ABSOLUTE "${LIBPCI_LIBRARIES}")
  33. add_library(LIBPCI::LIBPCI UNKNOWN IMPORTED)
  34. set_target_properties(LIBPCI::LIBPCI PROPERTIES IMPORTED_LOCATION
  35. "${LIBPCI_LIBRARIES}")
  36. else()
  37. add_library(LIBPCI::LIBPCI INTERFACE IMPORTED)
  38. set_target_properties(LIBPCI::LIBPCI PROPERTIES IMPORTED_LIBNAME
  39. "${LIBPCI_LIBRARIES}")
  40. endif()
  41. endif()
  42. endif()