FindLibpci.cmake 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # * Try to find Libpci Once done this will define
  2. #
  3. # * LIBPCI_FOUND - system has Libpci
  4. # * LIBPCI_INCLUDE_DIRS - the Libpci include directory
  5. # * LIBPCI_LIBRARIES - the libraries needed to use Libpci
  6. # * LIBPCI_DEFINITIONS - Compiler switches required for using Libpci
  7. # Use pkg-config to get the directories and then use these values in the
  8. # find_path() and find_library() calls
  9. find_package(PkgConfig QUIET)
  10. if(PKG_CONFIG_FOUND)
  11. pkg_check_modules(_LIBPCI libpci)
  12. endif()
  13. find_path(
  14. LIBPCI_INCLUDE_DIR
  15. NAMES pci.h
  16. HINTS ${_LIBPCI_INCLUDE_DIRS}
  17. PATHS /usr/include /usr/local/include /opt/local/include
  18. PATH_SUFFIXES pci/)
  19. find_library(
  20. LIBPCI_LIB
  21. NAMES ${_LIBPCI_LIBRARIES} libpci
  22. HINTS ${_LIBPCI_LIBRARY_DIRS}
  23. PATHS /usr/lib /usr/local/lib /opt/local/lib)
  24. include(FindPackageHandleStandardArgs)
  25. find_package_handle_standard_args(Libpci REQUIRED_VARS LIBPCI_LIB
  26. 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()