FindX11-xcb.cmake 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #[=======================================================================[.rst
  2. FindX11-xcb
  3. -----------
  4. FindModule for x11-xcb and associated libraries
  5. .. versionchanged:: 3.0
  6. Updated FindModule to CMake standards
  7. Imported Targets
  8. ^^^^^^^^^^^^^^^^
  9. .. versionadded:: 2.0
  10. This module defines the :prop_tgt:`IMPORTED` target ``X11::x11-xcb``.
  11. Result Variables
  12. ^^^^^^^^^^^^^^^^
  13. This module sets the following variables:
  14. ``X11-xcb_FOUND``
  15. True, if all required components and the core library were found.
  16. ``X11-xcb_VERSION``
  17. Detected version of found x11-xcb libraries.
  18. Cache variables
  19. ^^^^^^^^^^^^^^^
  20. The following cache variables may also be set:
  21. ``X11-xcb_LIBRARY``
  22. Path to the library component of x11-xcb.
  23. ``X11-xcb_INCLUDE_DIR``
  24. Directory containing ``Xlib-xcb.h``.
  25. #]=======================================================================]
  26. # cmake-format: off
  27. # cmake-lint: disable=C0103
  28. # cmake-lint: disable=C0301
  29. # cmake-format: on
  30. include(FindPackageHandleStandardArgs)
  31. find_package(PkgConfig QUIET)
  32. if(PKG_CONFIG_FOUND)
  33. pkg_search_module(PC_X11-xcb QUIET x11-xcb)
  34. endif()
  35. find_path(
  36. X11-xcb_INCLUDE_DIR
  37. NAMES X11/Xlib-xcb.h
  38. HINTS ${PC_X11-xcb_INCLUDE_DIRS}
  39. PATHS /usr/include /usr/local/include
  40. DOC "X11-xcb include directory")
  41. find_library(
  42. X11-xcb_LIBRARY
  43. NAMES X11-xcb
  44. HINTS ${PC_x11-xcb-LIBRARY_DIRS}
  45. PATHS /usr/lib /usr/local/lib
  46. DOC "X11-xcb location")
  47. if(PC_X11-xcb_VERSION VERSION_GREATER 0)
  48. set(X11-xcb_VERSION ${PC_X11-xcb_VERSION})
  49. else()
  50. if(NOT X11-xcb_FIND_QUIETLY)
  51. message(AUTHOR_WARNING "Failed to find X11-xcb version.")
  52. endif()
  53. set(X11-xcb_VERSION 0.0.0)
  54. endif()
  55. find_package_handle_standard_args(
  56. X11-xcb
  57. REQUIRED_VARS X11-xcb_LIBRARY X11-xcb_INCLUDE_DIR
  58. VERSION_VAR X11-xcb_VERSION REASON_FAILURE_MESSAGE "Ensure that X11-xcb is installed on the system.")
  59. mark_as_advanced(X11-xcb_INCLUDE_DIR X11-xcb_LIBRARY)
  60. if(X11-xcb_FOUND)
  61. if(NOT TARGET X11::x11-xcb)
  62. if(IS_ABSOLUTE "${X11-xcb_LIBRARY}")
  63. add_library(X11::x11-xcb UNKNOWN IMPORTED)
  64. set_property(TARGET X11::x11-xcb PROPERTY IMPORTED_LOCATION "${X11-xcb_LIBRARY}")
  65. else()
  66. add_library(X11::x11-xcb INTERFACE IMPORTED)
  67. set_property(TARGET X11::x11-xcb PROPERTY IMPORTED_LIBNAME "${X11-xcb_LIBRARY}")
  68. endif()
  69. set_target_properties(
  70. X11::x11-xcb
  71. PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_X11-xcb_CFLAGS_OTHER}"
  72. INTERFACE_INCLUDE_DIRECTORIES "${X11-xcb_INCLUDE_DIR}"
  73. VERSION ${X11-xcb_VERSION})
  74. endif()
  75. endif()
  76. include(FeatureSummary)
  77. set_package_properties(
  78. X11-xcb PROPERTIES
  79. URL "https://www.X.org"
  80. DESCRIPTION
  81. "Provides functions needed by clients which take advantage of Xlib/XCB to mix calls to both Xlib and XCB over the same X connection."
  82. )