File: Make-qt6-wayland-optional.patch

package info (click to toggle)
libkscreen 4%3A6.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,436 kB
  • sloc: cpp: 12,115; xml: 83; makefile: 10; sh: 1
file content (233 lines) | stat: -rw-r--r-- 8,085 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
Author: Aurélien COUDERC <coucouf@debian.org>
Forwarded: not-needed
Last-update: 2024-07-23
Description: Make Wayland optional
 .
 This allows to build libkscreen on architectures without qt6-wayland and wayland support

---
 CMakeLists.txt             |   21 ++++++++++++---------
 b/autotests/CMakeLists.txt |   62 +++++++++++++++++++++++++++++++++++++-------------------------
 backends/CMakeLists.txt    |    4 +++-
 tests/CMakeLists.txt       |    4 +++-
 4 files changed, 55 insertions(+), 36 deletions(-)

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,21 +29,26 @@
 include(KDEGitCommitHooks)
 include(ECMDeprecationSettings)
 
-find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED Core DBus Gui Test WaylandClient)
+find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED Core DBus Gui Test)
 
 if (Qt6Gui_VERSION VERSION_GREATER_EQUAL "6.10.0")
     find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE)
 endif()
 
-find_package(WaylandScanner)
-
-find_package(PlasmaWaylandProtocols 1.19 CONFIG)
-set_package_properties(PlasmaWaylandProtocols PROPERTIES TYPE REQUIRED)
-
-find_package(Wayland 1.15 COMPONENTS Client)
-set_package_properties(Wayland PROPERTIES
-                       TYPE REQUIRED
-                      )
+find_package(Qt6WaylandClient ${QT_MIN_VERSION} CONFIG)
+set(HAVE_WAYLAND ${Qt6WaylandClient_FOUND})
+message(STATUS "HAVE_WAYLAND: ${HAVE_WAYLAND}")
+if(${HAVE_WAYLAND})
+    find_package(WaylandScanner)
+
+    find_package(PlasmaWaylandProtocols 1.19 CONFIG)
+    set_package_properties(PlasmaWaylandProtocols PROPERTIES TYPE REQUIRED)
+
+    find_package(Wayland 1.15 COMPONENTS Client)
+    set_package_properties(Wayland PROPERTIES
+                           TYPE REQUIRED
+                          )
+endif()
 
 # xrandr backend
 
--- a/backends/CMakeLists.txt
+++ b/backends/CMakeLists.txt
@@ -1,5 +1,7 @@
 add_subdirectory(fake)
-add_subdirectory(kwayland)
+if(${HAVE_WAYLAND})
+    add_subdirectory(kwayland)
+endif()
 
 if(${XCB_RANDR_FOUND})
     message(STATUS "Will build xrandr backend.")
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,4 +1,6 @@
 add_executable(printconfig testplugandplay.cpp testpnp.cpp testpnp.h)
 target_link_libraries(printconfig Qt::Gui KF6::Screen)
 
-add_subdirectory(kwayland)
+if(${HAVE_WAYLAND})
+    add_subdirectory(kwayland)
+endif()
--- a/autotests/CMakeLists.txt
+++ b/autotests/CMakeLists.txt
@@ -1,13 +1,23 @@
 add_definitions(-DTEST_DATA="${CMAKE_CURRENT_SOURCE_DIR}/configs/")
 
-include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/tests/kwayland/)
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+if(${HAVE_WAYLAND)
+    include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/tests/kwayland/)
+endif()
 
 macro(KSCREEN_ADD_TEST)
     foreach(_testname ${ARGN})
-        set(test_SRCS ${_testname}.cpp ${KSCREEN_WAYLAND_SRCS})
+        set(test_SRCS ${_testname}.cpp)
+        if(${HAVE_WAYLAND)
+            set(test_SRCS ${test_SRCS} ${KSCREEN_WAYLAND_SRCS})
+        endif()
         qt_add_dbus_interface(test_SRCS ${CMAKE_SOURCE_DIR}/interfaces/org.kde.KScreen.FakeBackend.xml fakebackendinterface)
         add_executable(${_testname} ${test_SRCS})
-        target_link_libraries(${_testname} Qt::Core Qt::Gui Qt::Test Qt::DBus KF6::Screen ${KSCREEN_WAYLAND_LIBS})
+        if(${HAVE_WAYLAND)
+            target_link_libraries(${_testname} Qt::Core Qt::Gui Qt::Test Qt::DBus KF6::Screen ${KSCREEN_WAYLAND_LIBS})
+        else()
+            target_link_libraries(${_testname} Qt::Core Qt::Gui Qt::Test Qt::DBus KF6::Screen)
+        endif()
         add_test(NAME kscreen-${_testname}
                  COMMAND dbus-launch $<TARGET_FILE:${_testname}>
         )
@@ -25,28 +35,30 @@
 kscreen_add_test(testmodelistchange)
 kscreen_add_test(testedid)
 
-# FIXME KWaylandServer is not a thing in KF6
-if (NOT TARGET KF6::WaylandServer)
-    message(WARNING "Skipping KF6::WaylandServer based unit tests!")
-    return()
-endif()
-
-set(KSCREEN_WAYLAND_LIBS
-    KF6::WaylandServer KF6::WaylandClient
-)
-
-# For WaylandConfigReader and TestServer
-set(KSCREEN_WAYLAND_SRCS
-    ${CMAKE_SOURCE_DIR}/tests/kwayland/waylandconfigreader.cpp
-    ${CMAKE_SOURCE_DIR}/tests/kwayland/waylandtestserver.cpp
-)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../backends/kwayland)
+if(${HAVE_WAYLAND)
+    # FIXME KWaylandServer is not a thing in KF6
+    if (NOT TARGET KF6::WaylandServer)
+        message(WARNING "Skipping KF6::WaylandServer based unit tests!")
+        return()
+    endif()
+
+    set(KSCREEN_WAYLAND_LIBS
+        KF6::WaylandServer KF6::WaylandClient
+    )
+
+    # For WaylandConfigReader and TestServer
+    set(KSCREEN_WAYLAND_SRCS
+        ${CMAKE_SOURCE_DIR}/tests/kwayland/waylandconfigreader.cpp
+        ${CMAKE_SOURCE_DIR}/tests/kwayland/waylandtestserver.cpp
+    )
+    include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../backends/kwayland)
 
-kscreen_add_test(testkwaylandbackend)
-kscreen_add_test(testkwaylandconfig)
+    kscreen_add_test(testkwaylandbackend)
+    kscreen_add_test(testkwaylandconfig)
 
-set(KSCREEN_WAYLAND_LIBS "")
-set(KSCREEN_WAYLAND_SRCS "")
+    set(KSCREEN_WAYLAND_LIBS "")
+    set(KSCREEN_WAYLAND_SRCS "")
+endif()
 
 
 if (ENABLE_XRANDR_TESTS)
--- a/src/libdpms/CMakeLists.txt
+++ b/src/libdpms/CMakeLists.txt
@@ -1,21 +1,31 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez <aleixpol@kde.org>
 
+configure_file(dpms-config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/dpms-config.h)
+
 add_library(KF6ScreenDpms SHARED)
-target_sources(KF6ScreenDpms PRIVATE dpms.cpp dpms.h abstractdpmshelper.cpp waylanddpmshelper.cpp xcbdpmshelper.cpp waylanddpmshelper.cpp)
-target_link_libraries(KF6ScreenDpms PUBLIC Qt::Gui
-                                    PRIVATE XCB::XCB XCB::DPMS XCB::RANDR
-                                            Qt::GuiPrivate Qt::WaylandClient Wayland::Client
-)
+if(${HAVE_WAYLAND})
+    target_sources(KF6ScreenDpms PRIVATE dpms.cpp dpms.h abstractdpmshelper.cpp waylanddpmshelper.cpp xcbdpmshelper.cpp waylanddpmshelper.cpp)
+    target_link_libraries(KF6ScreenDpms PUBLIC Qt::Gui
+                                        PRIVATE XCB::XCB XCB::DPMS XCB::RANDR
+                                                Qt::GuiPrivate Qt::WaylandClient Wayland::Client
+    )
 
-if (Qt6_VERSION VERSION_GREATER_EQUAL "6.8.0")
-    set(private_code_option  "PRIVATE_CODE")
-endif()
-qt6_generate_wayland_protocol_client_sources(KF6ScreenDpms
-    ${private_code_option}
-    FILES
-        ${PLASMA_WAYLAND_PROTOCOLS_DIR}/dpms.xml
-)
+    if (Qt6_VERSION VERSION_GREATER_EQUAL "6.8.0")
+        set(private_code_option  "PRIVATE_CODE")
+    endif()
+    qt6_generate_wayland_protocol_client_sources(KF6ScreenDpms
+        ${private_code_option}
+        FILES
+            ${PLASMA_WAYLAND_PROTOCOLS_DIR}/dpms.xml
+    )
+else()
+    target_sources(KF6ScreenDpms PRIVATE dpms.cpp abstractdpmshelper.cpp xcbdpmshelper.cpp)
+    target_link_libraries(KF6ScreenDpms PUBLIC Qt::Gui
+                                        PRIVATE XCB::XCB XCB::DPMS XCB::RANDR
+                                                Qt::GuiPrivate
+    )
+endif()
 
 set_target_properties(KF6ScreenDpms PROPERTIES
     VERSION "${KSCREEN_VERSION}"
--- /dev/null
+++ b/src/libdpms/dpms-config.h.cmake
@@ -0,0 +1 @@
+#cmakedefine01 HAVE_WAYLAND
--- a/src/libdpms/dpms.cpp
+++ b/src/libdpms/dpms.cpp
@@ -2,9 +2,14 @@
 //
 // SPDX-License-Identifier: LGPL-2.1-or-later
 
+#include "dpms-config.h"
 #include "dpms.h"
 #include "kscreendpms_debug.h"
+
+#if HAVE_WAYLAND
 #include "waylanddpmshelper_p.h"
+#endif
+
 #include "xcbdpmshelper_p.h"
 
 #include <QGuiApplication>
@@ -15,8 +20,10 @@
 {
     if (QX11Info::isPlatformX11()) {
         m_helper.reset(new XcbDpmsHelper);
+#if HAVE_WAYLAND
     } else if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
         m_helper.reset(new WaylandDpmsHelper);
+#endif
     } else {
         qCWarning(KSCREEN_DPMS) << "dpms unsupported on this system";
         return;