CMakeLists.txt 13.5 KB
Newer Older
1
cmake_minimum_required(VERSION 3.16)
2

3
set(PROJECT_VERSION "5.21.80") # Handled by release scripts
4
project(KWin VERSION ${PROJECT_VERSION})
5

6
set(QT_MIN_VERSION "5.15.0")
7
set(KF5_MIN_VERSION "5.78")
8

9
find_package(ECM 5.38 REQUIRED NO_MODULE)
10
11
12

include(FeatureSummary)
include(WriteBasicConfigVersionFile)
13
include(GenerateExportHeader)
14
15

# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
16
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH})
17
18
19
20
21
22

find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
    Concurrent
    Core
    DBus
    Quick
23
    QuickWidgets
24
25
26
27
    UiTools
    Widgets
    X11Extras
)
28
29
30

find_package(Qt5Test ${QT_MIN_VERSION} CONFIG QUIET)
set_package_properties(Qt5Test PROPERTIES
31
32
33
    PURPOSE "Required for tests"
    TYPE OPTIONAL
)
34
35
36
37
38
39
40
add_feature_info("Qt5Test" Qt5Test_FOUND "Required for building tests")
if (NOT Qt5Test_FOUND)
    set(BUILD_TESTING OFF CACHE BOOL "Build the testing tree.")
endif()

include(KDEInstallDirs)
include(KDECMakeSettings)
41
include(KDECompilerSettings NO_POLICY_SCOPE)
David Edmundson's avatar
David Edmundson committed
42
include(KDEClangFormat)
43
44

include(ECMInstallIcons)
45
include(ECMOptionalAddSubdirectory)
46
include(ECMConfiguredInstall)
47
include(ECMQtDeclareLoggingCategory)
48

49
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0 -DQT_USE_QSTRINGBUILDER -DQT_NO_URL_CAST_FROM_STRING -DQT_NO_CAST_TO_ASCII)
50

51
52
53
54
55
# Prevent EGL headers from including platform headers, in particular Xlib.h.
add_definitions(-DMESA_EGL_NO_X11_HEADERS)
add_definitions(-DEGL_NO_X11)
add_definitions(-DEGL_NO_PLATFORM_SPECIFIC_TYPES)

56
set(CMAKE_CXX_STANDARD 17)
Martin Flöser's avatar
Martin Flöser committed
57
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Martin Flöser's avatar
Martin Flöser committed
58

59
# required frameworks by Core
60
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
61
62
63
64
65
66
    Config
    ConfigWidgets
    CoreAddons
    Crash
    GlobalAccel
    I18n
67
68
    IconThemes
    IdleTime
69
    Notifications
70
    Package
71
    Plasma
72
    Wayland
73
74
75
76
    WidgetsAddons
    WindowSystem
)
# required frameworks by config modules
77
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
78
    Completion
79
    Declarative
80
81
82
    KCMUtils
    KIO
    NewStuff
83
    Service
84
    TextWidgets
85
86
87
    XmlGui
)

88
89
find_package(Threads)
set_package_properties(Threads PROPERTIES
90
91
92
    PURPOSE "Needed for VirtualTerminal support in KWin Wayland"
    TYPE REQUIRED
)
93

94
# optional frameworks
95
find_package(KF5Activities ${KF5_MIN_VERSION} CONFIG)
96
set_package_properties(KF5Activities PROPERTIES
97
98
99
    PURPOSE "Enable building of KWin with kactivities support"
    TYPE OPTIONAL
)
100
101
add_feature_info("KF5Activities" KF5Activities_FOUND "Enable building of KWin with kactivities support")

102
find_package(KF5DocTools ${KF5_MIN_VERSION} CONFIG)
103
set_package_properties(KF5DocTools PROPERTIES
104
105
106
    PURPOSE "Enable building documentation"
    TYPE OPTIONAL
)
107
add_feature_info("KF5DocTools" KF5DocTools_FOUND "Enable building documentation")
108

Benjamin Port's avatar
Benjamin Port committed
109
110
111
112
113
114
115
find_package(KF5Runner ${KF5_MIN_VERSION} CONFIG)
set_package_properties(KF5Runner PROPERTIES
    PURPOSE "Enable building of KWin with krunner support"
    TYPE OPTIONAL
    )
add_feature_info("KF5Runner" KF5Runner_FOUND "Enable building of KWin with krunner support")

116
117
118
find_package(KF5Kirigami2 ${KF5_MIN_VERSION} CONFIG)
set_package_properties(KF5Kirigami2 PROPERTIES
    DESCRIPTION "A QtQuick based components set"
119
    PURPOSE "Required at runtime for Virtual desktop KCM"
120
121
122
    TYPE RUNTIME
)

Heiko Becker's avatar
Heiko Becker committed
123
find_package(KDecoration2 5.18.0 CONFIG REQUIRED)
124

125
126
find_package(KScreenLocker CONFIG REQUIRED)
set_package_properties(KScreenLocker PROPERTIES
127
128
129
    TYPE REQUIRED
    PURPOSE "For screenlocker integration in kwin_wayland"
)
130

131
132
133
134
135
136
find_package(KWaylandServer CONFIG REQUIRED)
set_package_properties(KWaylandServer PROPERTIES
    TYPE REQUIRED
    PURPOSE "For Wayland integration"
)

Martin Flöser's avatar
Martin Flöser committed
137
find_package(Breeze 5.9.0 CONFIG)
138
set_package_properties(Breeze PROPERTIES
139
140
141
142
143
    TYPE OPTIONAL
    PURPOSE "For setting the default window decoration plugin"
)
if (${Breeze_FOUND})
    if (${BREEZE_WITH_KDECORATION})
144
145
146
147
148
149
150
151
152
        set(HAVE_BREEZE_DECO true)
    else()
        set(HAVE_BREEZE_DECO FALSE)
    endif()
else()
    set(HAVE_BREEZE_DECO FALSE)
endif()
add_feature_info("Breeze-Decoration" HAVE_BREEZE_DECO "Default decoration plugin Breeze")

153
154
find_package(EGL)
set_package_properties(EGL PROPERTIES
155
156
157
    TYPE RUNTIME
    PURPOSE "Required to build KWin with EGL support"
)
158

Fredrik Höglund's avatar
Fredrik Höglund committed
159
find_package(epoxy)
160
161
162
163
164
165
set_package_properties(epoxy PROPERTIES
    DESCRIPTION "libepoxy"
    URL "https://github.com/anholt/libepoxy"
    TYPE REQUIRED
    PURPOSE "OpenGL dispatch library"
)
Fredrik Höglund's avatar
Fredrik Höglund committed
166

167
set(HAVE_DL_LIBRARY FALSE)
168
if (epoxy_HAS_GLX)
169
    find_library(DL_LIBRARY dl)
170
    if (DL_LIBRARY)
171
172
173
174
        set(HAVE_DL_LIBRARY TRUE)
    endif()
endif()

175
find_package(Wayland 1.2 OPTIONAL_COMPONENTS Egl)
176
set_package_properties(Wayland PROPERTIES
177
178
179
    TYPE REQUIRED
    PURPOSE "Required for building KWin with Wayland support"
)
180
add_feature_info("Wayland::EGL" Wayland_Egl_FOUND "Enable building of Wayland backend.")
181
set(HAVE_WAYLAND_EGL FALSE)
182
if (Wayland_Egl_FOUND)
183
184
    set(HAVE_WAYLAND_EGL TRUE)
endif()
185

186
find_package(XKB 0.7.0)
187
set_package_properties(XKB PROPERTIES
188
189
190
    TYPE REQUIRED
    PURPOSE "Required for building KWin with Wayland support"
)
191

Martin Flöser's avatar
Martin Flöser committed
192
find_package(Libinput 1.9)
Martin Flöser's avatar
Martin Flöser committed
193
set_package_properties(Libinput PROPERTIES TYPE REQUIRED PURPOSE "Required for input handling on Wayland.")
Martin Flöser's avatar
Martin Flöser committed
194
195

find_package(UDev)
196
set_package_properties(UDev PROPERTIES
197
    URL "https://www.freedesktop.org/wiki/Software/systemd/"
198
199
200
201
    DESCRIPTION "Linux device library."
    TYPE REQUIRED
    PURPOSE "Required for input handling on Wayland."
)
Martin Flöser's avatar
Martin Flöser committed
202

203
find_package(Libdrm 2.4.62)
204
205
set_package_properties(Libdrm PROPERTIES TYPE OPTIONAL PURPOSE "Required for drm output on Wayland.")
set(HAVE_DRM FALSE)
206
if (Libdrm_FOUND)
207
208
209
    set(HAVE_DRM TRUE)
endif()

210
find_package(gbm)
Yuri Chornoivan's avatar
Yuri Chornoivan committed
211
set_package_properties(gbm PROPERTIES TYPE OPTIONAL PURPOSE "Required for egl output of drm backend.")
212
set(HAVE_GBM FALSE)
213
if (HAVE_DRM AND gbm_FOUND)
214
215
216
    set(HAVE_GBM TRUE)
endif()

217
option(KWIN_BUILD_EGL_STREAM_BACKEND "Enable building of EGLStream based DRM backend" ON)
218
if (HAVE_DRM AND KWIN_BUILD_EGL_STREAM_BACKEND)
219
220
221
    set(HAVE_EGL_STREAMS TRUE)
endif()

222
find_package(X11)
223
224
225
226
227
set_package_properties(X11 PROPERTIES
    DESCRIPTION "X11 libraries"
    URL "https://www.x.org"
    TYPE REQUIRED
)
228
add_feature_info("XInput" X11_Xi_FOUND "Required for poll-free mouse cursor updates")
229
set(HAVE_X11_XINPUT ${X11_Xinput_FOUND})
230

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
231
232
233
234
235
236
find_package(lcms2)
set_package_properties(lcms2 PROPERTIES
    DESCRIPTION "Small-footprint color management engine"
    URL "http://www.littlecms.com"
    TYPE OPTIONAL
)
237
add_feature_info("lcms2" lcms2_FOUND "Required for the color management system")
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
238

239
# All the required XCB components
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
find_package(XCB 1.10 REQUIRED COMPONENTS
    COMPOSITE
    CURSOR
    DAMAGE
    GLX
    ICCCM
    IMAGE
    KEYSYMS
    RANDR
    RENDER
    SHAPE
    SHM
    SYNC
    XCB
    XFIXES
255
256
257
258
)
set_package_properties(XCB PROPERTIES TYPE REQUIRED)

# and the optional XCB dependencies
259
260
261
if (XCB_ICCCM_VERSION VERSION_LESS "0.4")
    set(XCB_ICCCM_FOUND FALSE)
endif()
262
263
add_feature_info("XCB-ICCCM" XCB_ICCCM_FOUND "Required for building test applications for KWin")

264
265
find_package(X11_XCB)
set_package_properties(X11_XCB PROPERTIES
266
267
268
    PURPOSE "Required for building X11 windowed backend of kwin_wayland"
    TYPE OPTIONAL
)
269

270
# dependencies for QPA plugin
Martin Flöser's avatar
Martin Flöser committed
271
272
273
find_package(Qt5FontDatabaseSupport REQUIRED)
find_package(Qt5ThemeSupport REQUIRED)
find_package(Qt5EventDispatcherSupport REQUIRED)
274

275
find_package(Freetype REQUIRED)
276
277
278
279
280
281
set_package_properties(Freetype PROPERTIES
    DESCRIPTION "A font rendering engine"
    URL "https://www.freetype.org"
    TYPE REQUIRED
    PURPOSE "Needed for KWin's QPA plugin."
)
282
find_package(Fontconfig REQUIRED)
283
set_package_properties(Fontconfig PROPERTIES
284
285
286
    TYPE REQUIRED
    PURPOSE "Needed for KWin's QPA plugin."
)
287

288
289
find_package(Xwayland)
set_package_properties(Xwayland PROPERTIES
Volker Krause's avatar
Volker Krause committed
290
    URL "https://x.org"
291
292
293
    DESCRIPTION "Xwayland X server"
    TYPE RUNTIME
    PURPOSE "Needed for running kwin_wayland"
294
)
295
set(HAVE_XWAYLAND_LISTENFD ${Xwayland_HAVE_LISTENFD})
296

297
298
299
300
301
302
303
find_package(Libcap)
set_package_properties(Libcap PROPERTIES
    TYPE OPTIONAL
    PURPOSE "Needed for running kwin_wayland with real-time scheduling policy"
)
set(HAVE_LIBCAP ${Libcap_FOUND})

304
305
306
307
308
309
310
find_package(hwdata)
set_package_properties(hwdata PROPERTIES
    TYPE RUNTIME
    PURPOSE "Runtime-only dependency needed for mapping monitor hardware vendor IDs to full names"
    URL "https://github.com/vcrhonek/hwdata"
)

311
312
313
314
315
316
317
318
319
find_package(QAccessibilityClient CONFIG)
set_package_properties(QAccessibilityClient PROPERTIES
    URL "https://www.kde.org"
    DESCRIPTION "KDE client-side accessibility library"
    TYPE OPTIONAL
    PURPOSE "Required to enable accessibility features"
)
set(HAVE_ACCESSIBILITY ${QAccessibilityClient_FOUND})

Tobias Berner's avatar
Tobias Berner committed
320
321
322
323
324
325
326
327
if(CMAKE_SYSTEM MATCHES "FreeBSD")
    find_package(epoll)
    set_package_properties(epoll PROPERTIES DESCRIPTION "I/O event notification facility"
        TYPE REQUIRED
        PURPOSE "Needed for running kwin_wayland"
    )
endif()

328
329
330
331
332
333
334
335
336
337
include(ECMQMLModules)
ecm_find_qmlmodule(QtQuick 2.3)
ecm_find_qmlmodule(QtQuick.Controls 1.2)
ecm_find_qmlmodule(QtQuick.Layouts 1.3)
ecm_find_qmlmodule(QtQuick.Window 2.1)
ecm_find_qmlmodule(QtMultimedia 5.0)
ecm_find_qmlmodule(org.kde.kquickcontrolsaddons 2.0)
ecm_find_qmlmodule(org.kde.plasma.core 2.0)
ecm_find_qmlmodule(org.kde.plasma.components 2.0)

338
########### configure tests ###############
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
339
340
341
342
343
344
include(CMakeDependentOption)

option(KWIN_BUILD_DECORATIONS "Enable building of KWin decorations." ON)
option(KWIN_BUILD_KCMS "Enable building of KWin configuration modules." ON)
option(KWIN_BUILD_TABBOX "Enable building of KWin Tabbox functionality" ON)
option(KWIN_BUILD_XRENDER_COMPOSITING "Enable building of KWin with XRender Compositing support" ON)
345
cmake_dependent_option(KWIN_BUILD_ACTIVITIES "Enable building of KWin with kactivities support" ON "KF5Activities_FOUND" OFF)
Benjamin Port's avatar
Benjamin Port committed
346
cmake_dependent_option(KWIN_BUILD_RUNNERS "Enable building of KWin with krunner support" ON "KF5Runner_FOUND" OFF)
347
cmake_dependent_option(KWIN_BUILD_CMS "Enable building of KWin with CMS" ON "lcms2_FOUND" OFF)
348

349
350
# Binary name of KWin
set(KWIN_NAME "kwin")
Hrvoje Senjan's avatar
Hrvoje Senjan committed
351
352
set(KWIN_INTERNAL_NAME_X11 "kwin_x11")
set(KWIN_INTERNAL_NAME_WAYLAND "kwin_wayland")
353

354
# KWIN_HAVE_XRENDER_COMPOSITING - whether XRender-based compositing support is available: may be disabled
355
356
if (KWIN_BUILD_XRENDER_COMPOSITING)
    set(KWIN_HAVE_XRENDER_COMPOSITING 1)
Martin Flöser's avatar
Martin Flöser committed
357
endif()
358

359
360
include_directories(${XKB_INCLUDE_DIR})

361
set(HAVE_EPOXY_GLX ${epoxy_HAS_GLX})
362

363
# for kwin internal things
364
set(HAVE_X11_XCB ${X11_XCB_FOUND})
365

366
include(CheckIncludeFile)
367
include(CheckIncludeFiles)
368
include(CheckSymbolExists)
369
370
check_include_files(unistd.h HAVE_UNISTD_H)
check_include_files(malloc.h HAVE_MALLOC_H)
371
372
373

check_include_file("sys/prctl.h" HAVE_SYS_PRCTL_H)
check_symbol_exists(PR_SET_DUMPABLE "sys/prctl.h" HAVE_PR_SET_DUMPABLE)
374
check_symbol_exists(PR_SET_PDEATHSIG "sys/prctl.h" HAVE_PR_SET_PDEATHSIG)
375
376
377
378
379
380
381
382
check_include_file("sys/procctl.h" HAVE_SYS_PROCCTL_H)
check_symbol_exists(PROC_TRACE_CTL "sys/procctl.h" HAVE_PROC_TRACE_CTL)
if (HAVE_PR_SET_DUMPABLE OR HAVE_PROC_TRACE_CTL)
    set(CAN_DISABLE_PTRACE TRUE)
endif()
add_feature_info("prctl/procctl tracing control"
                 CAN_DISABLE_PTRACE
                 "Required for disallowing ptrace on kwin_wayland process")
383

384
check_include_file("sys/sysmacros.h" HAVE_SYS_SYSMACROS_H)
385

386
387
388
389
390
391
392
393
check_include_file("linux/vt.h" HAVE_LINUX_VT_H)
add_feature_info("linux/vt.h"
                 HAVE_LINUX_VT_H
                 "Required for virtual terminal support under wayland")
check_include_file("linux/fb.h"    HAVE_LINUX_FB_H)
add_feature_info("linux/fb.h"
                 HAVE_LINUX_FB_H
                 "Required for the fbdev backend")
394

395
396
397
398
399
check_symbol_exists(SCHED_RESET_ON_FORK "sched.h" HAVE_SCHED_RESET_ON_FORK)
add_feature_info("SCHED_RESET_ON_FORK"
                 HAVE_SCHED_RESET_ON_FORK
                 "Required for running kwin_wayland with real-time scheduling")

400
401
402
403

pkg_check_modules(PipeWire IMPORTED_TARGET libpipewire-0.3)
add_feature_info(PipeWire PipeWire_FOUND "Required for Wayland screencasting")

404
########### global ###############
405

406
include_directories(BEFORE
407
408
409
410
411
412
    ${CMAKE_CURRENT_BINARY_DIR}/src/libkwineffects
    ${CMAKE_CURRENT_BINARY_DIR}/src
    ${CMAKE_CURRENT_SOURCE_DIR}/src/libkwineffects
    ${CMAKE_CURRENT_SOURCE_DIR}/src/effects
    ${CMAKE_CURRENT_SOURCE_DIR}/src/tabbox
    ${CMAKE_CURRENT_SOURCE_DIR}/src/platformsupport
413
)
414

415
416
if (KF5DocTools_FOUND)
    add_subdirectory(doc)
Martin Flöser's avatar
Martin Flöser committed
417
endif()
418

419
add_subdirectory(data)
420
421
add_subdirectory(kconf_update)
add_subdirectory(src)
422

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
423
if (BUILD_TESTING)
424
    find_package(WaylandProtocols 1.19 REQUIRED)
425
426
427
    find_package(QtWaylandScanner ${QT_MIN_VERSION} REQUIRED)
    find_package(Wayland REQUIRED COMPONENTS Client)

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
428
429
430
431
    add_subdirectory(autotests)
    add_subdirectory(tests)
endif()

432
433
434
435
# add clang-format target for all our real source files
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})

436
437
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)

438
include(CMakePackageConfigHelpers)
439
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KWinDBusInterface")
440
configure_package_config_file(KWinDBusInterfaceConfig.cmake.in
441
    "${CMAKE_CURRENT_BINARY_DIR}/KWinDBusInterfaceConfig.cmake"
442
    PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR
443
    INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR})
444
445
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/KWinDBusInterfaceConfig.cmake
    DESTINATION ${CMAKECONFIG_INSTALL_DIR})
446

David Edmundson's avatar
David Edmundson committed
447
448
449
450

# plasma-kwin_wayland.service.in is currently disabled as plasma-workspace currently launches
# kwin-wayland explicitly. Porting this is currently blocked on propogating DISPLAY
ecm_install_configured_files(INPUT plasma-kwin_x11.service.in @ONLY
451
            DESTINATION ${SYSTEMD_USER_UNIT_INSTALL_DIR})