0001-Wayland-Remove-extra-cmake-modules-dependency.patch 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. From 2747e47393cbca2d09db56223e735bd94b21e2eb Mon Sep 17 00:00:00 2001
  2. From: Joel Winarske <joel.winarske@gmail.com>
  3. Date: Mon, 28 Sep 2020 22:23:02 -0700
  4. Subject: [PATCH] Wayland: Remove extra-cmake-modules dependency
  5. Fixes #1774.
  6. [Retrieved (and backported) from:
  7. https://github.com/glfw/glfw/commit/2747e47393cbca2d09db56223e735bd94b21e2eb]
  8. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  9. ---
  10. .gitignore | 4 ---
  11. CMakeLists.txt | 16 ++++++------
  12. src/CMakeLists.txt | 62 ++++++++++++++++++++++++++++------------------
  13. 3 files changed, 45 insertions(+), 37 deletions(-)
  14. diff --git a/CMakeLists.txt b/CMakeLists.txt
  15. index 42bfa1806d..394827520b 100644
  16. --- a/CMakeLists.txt
  17. +++ b/CMakeLists.txt
  18. @@ -191,20 +191,18 @@ endif()
  19. # Use Wayland for window creation
  20. #--------------------------------------------------------------------
  21. if (_GLFW_WAYLAND)
  22. - find_package(ECM REQUIRED NO_MODULE)
  23. - list(APPEND CMAKE_MODULE_PATH "${ECM_MODULE_PATH}")
  24. - find_package(Wayland REQUIRED Client Cursor Egl)
  25. - find_package(WaylandScanner REQUIRED)
  26. - find_package(WaylandProtocols 1.15 REQUIRED)
  27. + include(FindPkgConfig)
  28. + pkg_check_modules(Wayland REQUIRED
  29. + wayland-client>=0.2.7
  30. + wayland-cursor>=0.2.7
  31. + wayland-egl>=0.2.7
  32. + xkbcommon)
  33. list(APPEND glfw_PKG_DEPS "wayland-client")
  34. list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}")
  35. - list(APPEND glfw_LIBRARIES "${Wayland_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT}")
  36. -
  37. - find_package(XKBCommon REQUIRED)
  38. - list(APPEND glfw_INCLUDE_DIRS "${XKBCOMMON_INCLUDE_DIRS}")
  39. + list(APPEND glfw_LIBRARIES "${Wayland_LINK_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT}")
  40. include(CheckIncludeFiles)
  41. include(CheckFunctionExists)
  42. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
  43. index 2f2bdd883d..e834506c6c 100644
  44. --- a/src/CMakeLists.txt
  45. +++ b/src/CMakeLists.txt
  46. @@ -45,30 +45,44 @@ if (_GLFW_X11 OR _GLFW_WAYLAND)
  47. posix_time.c posix_thread.c xkb_unicode.c
  48. egl_context.c osmesa_context.c)
  49. - ecm_add_wayland_client_protocol(glfw_SOURCES
  50. - PROTOCOL
  51. - "${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/xdg-shell/xdg-shell.xml"
  52. - BASENAME xdg-shell)
  53. - ecm_add_wayland_client_protocol(glfw_SOURCES
  54. - PROTOCOL
  55. - "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
  56. - BASENAME xdg-decoration)
  57. - ecm_add_wayland_client_protocol(glfw_SOURCES
  58. - PROTOCOL
  59. - "${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/viewporter/viewporter.xml"
  60. - BASENAME viewporter)
  61. - ecm_add_wayland_client_protocol(glfw_SOURCES
  62. - PROTOCOL
  63. - "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
  64. - BASENAME relative-pointer-unstable-v1)
  65. - ecm_add_wayland_client_protocol(glfw_SOURCES
  66. - PROTOCOL
  67. - "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"
  68. - BASENAME pointer-constraints-unstable-v1)
  69. - ecm_add_wayland_client_protocol(glfw_SOURCES
  70. - PROTOCOL
  71. - "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
  72. - BASENAME idle-inhibit-unstable-v1)
  73. + find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
  74. + pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.15)
  75. + pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir)
  76. +
  77. + macro(wayland_generate protocol_file output_file)
  78. + add_custom_command(OUTPUT ${output_file}.h
  79. + COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header
  80. + < ${protocol_file} > ${output_file}.h
  81. + DEPENDS ${protocol_file})
  82. + list(APPEND glfw_SOURCES ${output_file}.h)
  83. +
  84. + add_custom_command(OUTPUT ${output_file}.c
  85. + COMMAND ${WAYLAND_SCANNER_EXECUTABLE} private-code
  86. + < ${protocol_file} > ${output_file}.c
  87. + DEPENDS ${protocol_file})
  88. + list(APPEND glfw_SOURCES ${output_file}.c)
  89. + endmacro()
  90. +
  91. + set(GLFW_WAYLAND_PROTOCOL_SOURCES)
  92. + wayland_generate(
  93. + ${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml
  94. + ${CMAKE_BINARY_DIR}/src/wayland-xdg-shell-client-protocol)
  95. + wayland_generate(
  96. + ${WAYLAND_PROTOCOLS_BASE}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml
  97. + ${CMAKE_BINARY_DIR}/src/wayland-xdg-decoration-client-protocol)
  98. + wayland_generate(
  99. + ${WAYLAND_PROTOCOLS_BASE}/stable/viewporter/viewporter.xml
  100. + ${CMAKE_BINARY_DIR}/src/wayland-viewporter-client-protocol)
  101. + wayland_generate(
  102. + ${WAYLAND_PROTOCOLS_BASE}/unstable/relative-pointer/relative-pointer-unstable-v1.xml
  103. + ${CMAKE_BINARY_DIR}/src/wayland-relative-pointer-unstable-v1-client-protocol)
  104. + wayland_generate(
  105. + ${WAYLAND_PROTOCOLS_BASE}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml
  106. + ${CMAKE_BINARY_DIR}/src/wayland-pointer-constraints-unstable-v1-client-protocol)
  107. + wayland_generate(
  108. + ${WAYLAND_PROTOCOLS_BASE}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml
  109. + ${CMAKE_BINARY_DIR}/src/wayland-idle-inhibit-unstable-v1-client-protocol)
  110. +
  111. elseif (_GLFW_OSMESA)
  112. set(glfw_HEADERS ${common_HEADERS} null_platform.h null_joystick.h
  113. posix_time.h posix_thread.h osmesa_context.h)