FindX11_XCB.cmake 1.6 KB

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