FindX11_XCB.cmake 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # * Try to find libX11-xcb Once done this will define
  2. #
  3. # X11_XCB_FOUND - system has libX11-xcb X11_XCB_LIBRARIES - Link these to use
  4. # libX11-xcb X11_XCB_INCLUDE_DIR - the libX11-xcb include dir
  5. # X11_XCB_DEFINITIONS - compiler switches required for using libX11-xcb
  6. # Copyright (c) 2011 Fredrik Höglund <[email protected]> Copyright (c) 2008 Helio
  7. # Chissini de Castro, <[email protected]> Copyright (c) 2007 Matthias Kretz,
  8. # <[email protected]>
  9. #
  10. # Redistribution and use is allowed according to the terms of the BSD license.
  11. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  12. if(NOT WIN32)
  13. # use pkg-config to get the directories and then use these values in the
  14. # FIND_PATH() and FIND_LIBRARY() calls
  15. find_package(PkgConfig)
  16. pkg_check_modules(PKG_X11_XCB QUIET x11-xcb)
  17. set(X11_XCB_DEFINITIONS ${PKG_X11_XCB_CFLAGS})
  18. find_path(
  19. X11_XCB_INCLUDE_DIR
  20. NAMES X11/Xlib-xcb.h
  21. HINTS ${PKG_X11_XCB_INCLUDE_DIRS})
  22. find_library(
  23. X11_XCB_LIBRARIES
  24. NAMES X11-xcb
  25. HINTS ${PKG_X11_XCB_LIBRARY_DIRS})
  26. include(FindPackageHandleStandardArgs)
  27. find_package_handle_standard_args(X11_XCB DEFAULT_MSG X11_XCB_LIBRARIES
  28. X11_XCB_INCLUDE_DIR)
  29. mark_as_advanced(X11_XCB_INCLUDE_DIR X11_XCB_LIBRARIES)
  30. if(X11_XCB_FOUND AND NOT TARGET X11::X11_xcb)
  31. add_library(X11::X11_xcb UNKNOWN IMPORTED)
  32. set_target_properties(
  33. X11::X11_xcb
  34. PROPERTIES IMPORTED_LOCATION "${X11_XCB_LIBRARIES}"
  35. INTERFACE_INCLUDE_DIRECTORIES "${X11_XCB_INCLUDE_DIR}"
  36. INTERFACE_LINK_LIBRARIES "XCB::XCB;X11::X11")
  37. endif()
  38. endif()