CMakeLists.txt 23.8 KB
Newer Older
1
2
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)

3
project(KWin)
4
set(PROJECT_VERSION "5.19.80")
5
set(PROJECT_VERSION_MAJOR 5)
6

Jonathan Riddell's avatar
Jonathan Riddell committed
7
set(QT_MIN_VERSION "5.14.0")
8
set(KF5_MIN_VERSION "5.73.0")
9

10
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
11

12
find_package(ECM 5.38 REQUIRED NO_MODULE)
13
14
15

include(FeatureSummary)
include(WriteBasicConfigVersionFile)
16
include(GenerateExportHeader)
17
18
19
20
21
22
23
24
25

# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})

find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
    Concurrent
    Core
    DBus
    Quick
26
    QuickWidgets
27
    Script
28
    Sensors
29
30
31
32
    UiTools
    Widgets
    X11Extras
)
33
34
35

find_package(Qt5Test ${QT_MIN_VERSION} CONFIG QUIET)
set_package_properties(Qt5Test PROPERTIES
36
37
38
    PURPOSE "Required for tests"
    TYPE OPTIONAL
)
39
40
41
42
43
44
45
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)
46
include(KDECompilerSettings NO_POLICY_SCOPE)
David Edmundson's avatar
David Edmundson committed
47
include(KDEClangFormat)
48
49

include(ECMInstallIcons)
50
include(ECMOptionalAddSubdirectory)
51
include(ECMConfiguredInstall)
52

53
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0 -DQT_USE_QSTRINGBUILDER -DQT_NO_URL_CAST_FROM_STRING)
54

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

58
59
find_package(Qt5Multimedia QUIET)
set_package_properties(Qt5Multimedia PROPERTIES
60
61
62
    PURPOSE "Runtime-only dependency for effect video playback"
    TYPE RUNTIME
)
63
64

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

93
94
find_package(Threads)
set_package_properties(Threads PROPERTIES
95
96
97
    PURPOSE "Needed for VirtualTerminal support in KWin Wayland"
    TYPE REQUIRED
)
98

99
# optional frameworks
100
find_package(KF5Activities ${KF5_MIN_VERSION} CONFIG)
101
set_package_properties(KF5Activities PROPERTIES
102
103
104
    PURPOSE "Enable building of KWin with kactivities support"
    TYPE OPTIONAL
)
105
106
add_feature_info("KF5Activities" KF5Activities_FOUND "Enable building of KWin with kactivities support")

107
find_package(KF5DocTools ${KF5_MIN_VERSION} CONFIG)
108
set_package_properties(KF5DocTools PROPERTIES
109
110
111
    PURPOSE "Enable building documentation"
    TYPE OPTIONAL
)
112
add_feature_info("KF5DocTools" KF5DocTools_FOUND "Enable building documentation")
113

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

Heiko Becker's avatar
Heiko Becker committed
121
find_package(KDecoration2 5.18.0 CONFIG REQUIRED)
122

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

129
130
131
132
133
134
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
135
find_package(Breeze 5.9.0 CONFIG)
136
set_package_properties(Breeze PROPERTIES
137
138
139
140
141
    TYPE OPTIONAL
    PURPOSE "For setting the default window decoration plugin"
)
if (${Breeze_FOUND})
    if (${BREEZE_WITH_KDECORATION})
142
143
144
145
146
147
148
149
150
        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")

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

Fredrik Höglund's avatar
Fredrik Höglund committed
157
find_package(epoxy)
158
159
160
161
162
163
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
164

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

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

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

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

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

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

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

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

220
221
find_package(libhybris)
set_package_properties(libhybris PROPERTIES TYPE OPTIONAL PURPOSE "Required for libhybris backend")
Martin Flöser's avatar
Martin Flöser committed
222
set(HAVE_LIBHYBRIS ${libhybris_FOUND})
223

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

# All the required XCB components
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
find_package(XCB 1.10 REQUIRED COMPONENTS
    COMPOSITE
    CURSOR
    DAMAGE
    GLX
    ICCCM
    IMAGE
    KEYSYMS
    RANDR
    RENDER
    SHAPE
    SHM
    SYNC
    XCB
    XFIXES
249
250
251
252
)
set_package_properties(XCB PROPERTIES TYPE REQUIRED)

# and the optional XCB dependencies
253
254
255
if (XCB_ICCCM_VERSION VERSION_LESS "0.4")
    set(XCB_ICCCM_FOUND FALSE)
endif()
256
257
add_feature_info("XCB-ICCCM" XCB_ICCCM_FOUND "Required for building test applications for KWin")

258
259
find_package(X11_XCB)
set_package_properties(X11_XCB PROPERTIES
260
261
262
    PURPOSE "Required for building X11 windowed backend of kwin_wayland"
    TYPE OPTIONAL
)
263

264
# dependencies for QPA plugin
Martin Flöser's avatar
Martin Flöser committed
265
266
267
find_package(Qt5FontDatabaseSupport REQUIRED)
find_package(Qt5ThemeSupport REQUIRED)
find_package(Qt5EventDispatcherSupport REQUIRED)
268

269
find_package(Freetype REQUIRED)
270
271
272
273
274
275
set_package_properties(Freetype PROPERTIES
    DESCRIPTION "A font rendering engine"
    URL "https://www.freetype.org"
    TYPE REQUIRED
    PURPOSE "Needed for KWin's QPA plugin."
)
276
find_package(Fontconfig REQUIRED)
277
set_package_properties(Fontconfig PROPERTIES
278
279
280
    TYPE REQUIRED
    PURPOSE "Needed for KWin's QPA plugin."
)
281

282
283
find_package(Xwayland)
set_package_properties(Xwayland PROPERTIES
Volker Krause's avatar
Volker Krause committed
284
    URL "https://x.org"
285
286
287
    DESCRIPTION "Xwayland X server"
    TYPE RUNTIME
    PURPOSE "Needed for running kwin_wayland"
288
)
289

290
291
292
293
294
295
296
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})

297
298
299
300
301
302
303
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"
)

304
305
306
307
308
309
310
311
312
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 C. Berner's avatar
Tobias C. Berner committed
313
314
315
316
317
318
319
320
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()

321
322
323
324
325
326
327
328
329
330
331
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.VirtualKeyboard 2.1)
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)

332
########### configure tests ###############
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
333
334
335
336
337
338
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)
339
cmake_dependent_option(KWIN_BUILD_ACTIVITIES "Enable building of KWin with kactivities support" ON "KF5Activities_FOUND" OFF)
340

341
342
# Binary name of KWin
set(KWIN_NAME "kwin")
Hrvoje Senjan's avatar
Hrvoje Senjan committed
343
344
set(KWIN_INTERNAL_NAME_X11 "kwin_x11")
set(KWIN_INTERNAL_NAME_WAYLAND "kwin_wayland")
345

346
# KWIN_HAVE_XRENDER_COMPOSITING - whether XRender-based compositing support is available: may be disabled
347
348
if (KWIN_BUILD_XRENDER_COMPOSITING)
    set(KWIN_HAVE_XRENDER_COMPOSITING 1)
Martin Flöser's avatar
Martin Flöser committed
349
endif()
350

351
include_directories(${XKB_INCLUDE_DIR})
352

353
include_directories(${epoxy_INCLUDE_DIR})
354
set(HAVE_EPOXY_GLX ${epoxy_HAS_GLX})
355

356
# for things that are also used by kwin libraries
357
configure_file(libkwineffects/kwinconfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/libkwineffects/kwinconfig.h )
358
# for kwin internal things
359
set(HAVE_X11_XCB ${X11_XCB_FOUND})
360

361
include(CheckIncludeFile)
362
include(CheckIncludeFiles)
363
include(CheckSymbolExists)
364
365
check_include_files(unistd.h HAVE_UNISTD_H)
check_include_files(malloc.h HAVE_MALLOC_H)
366
367
368

check_include_file("sys/prctl.h" HAVE_SYS_PRCTL_H)
check_symbol_exists(PR_SET_DUMPABLE "sys/prctl.h" HAVE_PR_SET_DUMPABLE)
369
check_symbol_exists(PR_SET_PDEATHSIG "sys/prctl.h" HAVE_PR_SET_PDEATHSIG)
370
371
372
373
374
375
376
377
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")
378

379
check_include_file("sys/sysmacros.h" HAVE_SYS_SYSMACROS_H)
380

381
382
383
384
385
386
387
388
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")
389

390
391
392
393
394
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")

395
396
397
398

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

399
configure_file(config-kwin.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kwin.h)
400

401
########### global ###############
402
set(kwin_effects_dbus_xml ${CMAKE_CURRENT_SOURCE_DIR}/org.kde.kwin.Effects.xml)
403
qt5_add_dbus_interface(effects_interface_SRCS ${kwin_effects_dbus_xml} kwineffects_interface)
404
add_library(KWinEffectsInterface STATIC ${effects_interface_SRCS})
405
target_link_libraries(KWinEffectsInterface Qt5::DBus)
406

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

416
417
418
add_subdirectory(libkwineffects)
if (KWIN_BUILD_KCMS)
    add_subdirectory(kcmkwin)
Martin Flöser's avatar
Martin Flöser committed
419
endif()
420

421
add_subdirectory(data)
422

423
424
425
add_subdirectory(effects)
add_subdirectory(scripts)
add_subdirectory(tabbox)
426
add_subdirectory(scripting)
427
add_subdirectory(helpers)
428

429
430
########### next target ###############

David Edmundson's avatar
David Edmundson committed
431
set(kwin_SRCS
432
    3rdparty/xcursor.c
433
434
    abstract_client.cpp
    abstract_opengl_context_attribute_builder.cpp
Roman Gilg's avatar
Roman Gilg committed
435
    abstract_output.cpp
436
    abstract_wayland_output.cpp
437
    activation.cpp
Kai Uwe Broulik's avatar
Kai Uwe Broulik committed
438
    appmenu.cpp
439
440
    atoms.cpp
    client_machine.cpp
441
442
    colorcorrection/clockskewnotifier.cpp
    colorcorrection/clockskewnotifierengine.cpp
443
    colorcorrection/colorcorrectdbusinterface.cpp
444
    colorcorrection/manager.cpp
445
    colorcorrection/suncalc.cpp
446
447
448
449
450
451
452
453
454
455
456
    composite.cpp
    cursor.cpp
    dbusinterface.cpp
    debug_console.cpp
    decorations/decoratedclient.cpp
    decorations/decorationbridge.cpp
    decorations/decorationpalette.cpp
    decorations/decorationrenderer.cpp
    decorations/decorations_logging.cpp
    decorations/settings.cpp
    deleted.cpp
457
    dmabuftexture.cpp
458
459
    effectloader.cpp
    effects.cpp
460
    egl_context_attribute_builder.cpp
461
462
463
464
465
466
    events.cpp
    focuschain.cpp
    geometrytip.cpp
    gestures.cpp
    globalshortcuts.cpp
    group.cpp
467
    idle_inhibition.cpp
468
469
470
    input.cpp
    input_event.cpp
    input_event_spy.cpp
471
    inputpanelv1client.cpp
472
473
474
475
476
477
478
    internal_client.cpp
    keyboard_input.cpp
    keyboard_layout.cpp
    keyboard_layout_switching.cpp
    keyboard_repeat.cpp
    killwindow.cpp
    layers.cpp
Martin Flöser's avatar
Martin Flöser committed
479
    libinput/connection.cpp
480
    libinput/context.cpp
Martin Flöser's avatar
Martin Flöser committed
481
482
483
    libinput/device.cpp
    libinput/events.cpp
    libinput/libinput_logging.cpp
Roman Gilg's avatar
Roman Gilg committed
484
    linux_dmabuf.cpp
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
    logind.cpp
    main.cpp
    modifier_only_shortcuts.cpp
    moving_client_x11_filter.cpp
    netinfo.cpp
    onscreennotification.cpp
    options.cpp
    osd.cpp
    outline.cpp
    outputscreens.cpp
    overlaywindow.cpp
    placement.cpp
    platform.cpp
    pointer_input.cpp
    popup_input_filter.cpp
    rootinfo_filter.cpp
Henri Chain's avatar
Henri Chain committed
501
    rulebooksettings.cpp
502
    rules.cpp
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
    scene.cpp
    screenedge.cpp
    screenlockerwatcher.cpp
    screens.cpp
    scripting/dbuscall.cpp
    scripting/meta.cpp
    scripting/screenedgeitem.cpp
    scripting/scriptedeffect.cpp
    scripting/scripting.cpp
    scripting/scripting_logging.cpp
    scripting/scripting_model.cpp
    scripting/scriptingutils.cpp
    scripting/timer.cpp
    scripting/workspace_wrapper.cpp
    shadow.cpp
    sm.cpp
519
    subsurfacemonitor.cpp
520
    syncalarmx11filter.cpp
521
    tablet_input.cpp
522
523
    thumbnailitem.cpp
    toplevel.cpp
524
    touch_hide_cursor_spy.cpp
525
526
527
528
529
530
531
532
533
534
535
    touch_input.cpp
    udev.cpp
    unmanaged.cpp
    useractions.cpp
    utils.cpp
    virtualdesktops.cpp
    virtualdesktopsdbustypes.cpp
    virtualkeyboard.cpp
    virtualkeyboard_dbus.cpp
    was_user_interaction_x11_filter.cpp
    wayland_server.cpp
536
    waylandclient.cpp
537
538
    waylandshellintegration.cpp
    waylandxdgshellintegration.cpp
539
540
    window_property_notify_x11_filter.cpp
    workspace.cpp
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
541
    x11client.cpp
542
543
    x11eventfilter.cpp
    xcbutils.cpp
544
    xcursortheme.cpp
545
    xdgshellclient.cpp
546
    xkb.cpp
547
    xwaylandclient.cpp
548
    xwl/xwayland_interface.cpp
549
)
550

551
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
David Edmundson's avatar
David Edmundson committed
552
553
    set(kwin_SRCS
        ${kwin_SRCS}
554
555
556
557
        colorcorrection/clockskewnotifierengine_linux.cpp
    )
endif()

558
include(ECMQtDeclareLoggingCategory)
David Edmundson's avatar
David Edmundson committed
559
ecm_qt_declare_logging_category(kwin_SRCS
560
561
562
563
564
565
566
567
568
569
    HEADER
        colorcorrect_logging.h
    IDENTIFIER
        KWIN_COLORCORRECTION
    CATEGORY_NAME
        kwin_colorcorrection
    DEFAULT_SEVERITY
        Critical
)

570
if (KWIN_BUILD_TABBOX)
571
    include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
David Edmundson's avatar
David Edmundson committed
572
    set(kwin_SRCS ${kwin_SRCS}
573
        tabbox/clientmodel.cpp
574
        tabbox/desktopchain.cpp
575
        tabbox/desktopmodel.cpp
576
        tabbox/switcheritem.cpp
577
578
        tabbox/tabbox.cpp
        tabbox/tabbox_logging.cpp
579
580
        tabbox/tabboxconfig.cpp
        tabbox/tabboxhandler.cpp
581
        tabbox/x11_filter.cpp
582
    )
Martin Flöser's avatar
Martin Flöser committed
583
endif()
584

585
if (KWIN_BUILD_ACTIVITIES)
David Edmundson's avatar
David Edmundson committed
586
    set(kwin_SRCS ${kwin_SRCS}
587
588
589
590
        activities.cpp
    )
endif()

Martin Flöser's avatar
Martin Flöser committed
591
if (HAVE_LINUX_VT_H)
David Edmundson's avatar
David Edmundson committed
592
    set(kwin_SRCS ${kwin_SRCS}
593
594
        virtual_terminal.cpp
    )
595
    set(KWIN_TTY_PREFIX "/dev/tty")
Martin Flöser's avatar
Martin Flöser committed
596
597
endif()

Tobias C. Berner's avatar
Tobias C. Berner committed
598
599
600
601
602
if(CMAKE_SYSTEM MATCHES "FreeBSD")
    # We know it has epoll, so supports VT as well
    set(kwin_SRCS ${kwin_SRCS}
        virtual_terminal.cpp
    )
603
    set(KWIN_TTY_PREFIX "/dev/ttyv")
Tobias C. Berner's avatar
Tobias C. Berner committed
604
endif()
605
606
607
if(KWIN_TTY_PREFIX)
    set_source_files_properties(virtual_terminal.cpp PROPERTIES COMPILE_DEFINITIONS KWIN_TTY_PREFIX="${KWIN_TTY_PREFIX}")
endif()    
Tobias C. Berner's avatar
Tobias C. Berner committed
608

David Edmundson's avatar
David Edmundson committed
609
610
kconfig_add_kcfg_files(kwin_SRCS settings.kcfgc)
kconfig_add_kcfg_files(kwin_SRCS colorcorrection/colorcorrect_settings.kcfgc)
Henri Chain's avatar
Henri Chain committed
611
612
kconfig_add_kcfg_files(kwin_SRCS rulesettings.kcfgc)
kconfig_add_kcfg_files(kwin_SRCS rulebooksettingsbase.kcfgc)
613

David Edmundson's avatar
David Edmundson committed
614
615
616
617
618
619
qt5_add_dbus_adaptor(kwin_SRCS org.kde.KWin.xml dbusinterface.h KWin::DBusInterface)
qt5_add_dbus_adaptor(kwin_SRCS org.kde.kwin.Compositing.xml dbusinterface.h KWin::CompositorDBusInterface)
qt5_add_dbus_adaptor(kwin_SRCS org.kde.kwin.ColorCorrect.xml colorcorrection/colorcorrectdbusinterface.h KWin::ColorCorrect::ColorCorrectDBusInterface)
qt5_add_dbus_adaptor(kwin_SRCS ${kwin_effects_dbus_xml} effects.h KWin::EffectsHandlerImpl)
qt5_add_dbus_adaptor(kwin_SRCS org.kde.KWin.VirtualDesktopManager.xml dbusinterface.h KWin::VirtualDesktopManagerDBusInterface)
qt5_add_dbus_adaptor(kwin_SRCS org.kde.KWin.Session.xml sm.h KWin::SessionManager)
620

David Edmundson's avatar
David Edmundson committed
621
622
623
qt5_add_dbus_interface(kwin_SRCS ${KSCREENLOCKER_DBUS_INTERFACES_DIR}/kf5_org.freedesktop.ScreenSaver.xml screenlocker_interface)
qt5_add_dbus_interface(kwin_SRCS ${KSCREENLOCKER_DBUS_INTERFACES_DIR}/org.kde.screensaver.xml kscreenlocker_interface)
qt5_add_dbus_interface(kwin_SRCS org.kde.kappmenu.xml appmenu_interface)
Kai Uwe Broulik's avatar
Kai Uwe Broulik committed
624

David Edmundson's avatar
David Edmundson committed
625
ki18n_wrap_ui(kwin_SRCS
626
    debug_console.ui
627
628
629
    shortcutdialog.ui
)

630
631
632
########### target link libraries ###############

set(kwin_OWN_LIBS
633
    kwineffects
634
    kwin4_effect_builtins
635
636
637
)

set(kwin_QT_LIBS
Martin Flöser's avatar
Martin Flöser committed
638
    Qt5::Concurrent
Martin Flöser's avatar
Martin Flöser committed
639
    Qt5::DBus
640
    Qt5::Quick
641
    Qt5::Script
642
    Qt5::Sensors
643
644
645
)

set(kwin_KDE_LIBS
Martin Klapetek's avatar
Martin Klapetek committed
646
    KF5::ConfigCore
647
    KF5::ConfigWidgets
648
    KF5::CoreAddons
649
    KF5::GlobalAccel
650
    KF5::GlobalAccelPrivate
Martin Klapetek's avatar
Martin Klapetek committed
651
652
    KF5::I18n
    KF5::Notifications
653
    KF5::Package
654
    KF5::Plasma
David Edmundson's avatar
David Edmundson committed
655
    KF5::QuickAddons
656
    KF5::WindowSystem
657
658
659
660

    KDecoration2::KDecoration
    KDecoration2::KDecoration2Private

661
    PW::KScreenLocker
662
663
664
)

set(kwin_XLIB_LIBS
Martin Flöser's avatar
Martin Flöser committed
665
666
    ${X11_ICE_LIB}
    ${X11_SM_LIB}
667
    ${X11_X11_LIB}
668
669
)

670
set(kwin_XCB_LIBS
671
    XCB::COMPOSITE
672
    XCB::DAMAGE
673
    XCB::GLX
674
    XCB::ICCCM
675
676
677
678
679
680
681
682
    XCB::KEYSYMS
    XCB::RANDR
    XCB::RENDER
    XCB::SHAPE
    XCB::SHM
    XCB::SYNC
    XCB::XCB
    XCB::XFIXES
683
684
)

685
set(kwin_WAYLAND_LIBS
686
    KF5::WaylandClient
687
    Plasma::KWaylandServer
688
    XKB::XKB
689
    ${CMAKE_THREAD_LIBS_INIT}
690
691
)

692
if (KWIN_BUILD_ACTIVITIES)
693
    set(kwin_KDE_LIBS ${kwin_KDE_LIBS} KF5::Activities)
Martin Flöser's avatar
Martin Flöser committed
694
endif()
695

696
697
698
699
700
701
set(kwinLibs
    ${kwin_OWN_LIBS}
    ${kwin_QT_LIBS}
    ${kwin_KDE_LIBS}
    ${kwin_XLIB_LIBS}
    ${kwin_XCB_LIBS}
702
    ${kwin_WAYLAND_LIBS}
Martin Flöser's avatar
Martin Flöser committed
703
704
    ${UDEV_LIBS}
    Libinput::Libinput
705
706
)

David Edmundson's avatar
David Edmundson committed
707
add_library(kwin SHARED ${kwin_SRCS})
708
709
710
if (Libinput_VERSION_STRING VERSION_GREATER 1.14)
    target_compile_definitions(kwin PRIVATE -DLIBINPUT_HAS_TOTEM)
endif ()
711

712
set_target_properties(kwin PROPERTIES
713
714
   VERSION ${PROJECT_VERSION}
   SOVERSION ${PROJECT_VERSION_MAJOR}
715
)
716

717
target_link_libraries(kwin ${kwinLibs} kwinglutils ${epoxy_LIBRARY})
718

719
generate_export_header(kwin EXPORT_FILE_NAME kwin_export.h)
720

Tobias C. Berner's avatar
Tobias C. Berner committed
721
722
723
724
725
726
if(CMAKE_SYSTEM MATCHES "FreeBSD")
    # epoll is required, includes live under ${LOCALBASE}, separate library
    target_include_directories(kwin PUBLIC ${epoll_INCLUDE_DIRS})
    target_link_libraries(kwin ${kwinLibs} ${epoll_LIBRARIES}) 
endif()

David Edmundson's avatar
David Edmundson committed
727
728
add_executable(kwin_x11 main_x11.cpp)
target_link_libraries(kwin_x11 kwin KF5::Crash Qt5::X11Extras)
729

730
731
install(TARGETS kwin ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP)
install(TARGETS kwin_x11 ${INSTALL_TARGETS_DEFAULT_ARGS})
732

733
734
set(kwin_XWAYLAND_SRCS
   ${CMAKE_CURRENT_SOURCE_DIR}/xwl/clipboard.cpp
735
   ${CMAKE_CURRENT_SOURCE_DIR}/xwl/databridge.cpp
736
737
738
739
   ${CMAKE_CURRENT_SOURCE_DIR}/xwl/dnd.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/xwl/drag.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/xwl/drag_wl.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/xwl/drag_x.cpp
740
741
742
743
   ${CMAKE_CURRENT_SOURCE_DIR}/xwl/selection.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/xwl/selection_source.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/xwl/transfer.cpp
   ${CMAKE_CURRENT_SOURCE_DIR}/xwl/xwayland.cpp
744
)
745
746
747
748
749
750
751
752
753
include(ECMQtDeclareLoggingCategory)
ecm_qt_declare_logging_category(kwin_XWAYLAND_SRCS
    HEADER
        xwayland_logging.h
    IDENTIFIER
        KWIN_XWL
    CATEGORY_NAME
        kwin_xwl
    DEFAULT_SEVERITY
754
        Warning
755
756
)

757
758
set(kwin_WAYLAND_SRCS
   main_wayland.cpp
759
   tabletmodemanager.cpp
760
)
761
762
ecm_qt_declare_logging_category(kwin_WAYLAND_SRCS
    HEADER
763
        kwinscreencast_logging.h
764
    IDENTIFIER
765
        KWIN_SCREENCAST
766
    CATEGORY_NAME
767
        kwin_screencast
768
769
770
    DEFAULT_SEVERITY
        Warning
)
771

772
add_executable(kwin_wayland ${kwin_WAYLAND_SRCS} ${kwin_XWAYLAND_SRCS})
773
774
775
776
777
778
779
780
781
782
783


if (PipeWire_FOUND)
    target_sources(kwin_wayland
        PRIVATE
        screencast/screencastmanager.cpp
        screencast/pipewirecore.cpp
        screencast/pipewirestream.cpp)
    target_link_libraries(kwin_wayland PkgConfig::PipeWire)
endif()

784
785
786
787
target_link_libraries(kwin_wayland
                      kwin
                      KF5::Crash
)
788
789
790
if (HAVE_LIBCAP)
    target_link_libraries(kwin_wayland ${Libcap_LIBRARIES})
endif()
791

792
install(TARGETS kwin_wayland ${INSTALL_TARGETS_DEFAULT_ARGS})
793
794
795
796
797
798
if (HAVE_LIBCAP)
    install(
    CODE "execute_process(
            COMMAND
                ${SETCAP_EXECUTABLE}
                CAP_SYS_NICE=+ep
799
                \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/kwin_wayland)"
800
801
    )
endif()
802

803
add_subdirectory(platformsupport)
804
add_subdirectory(plugins)
805
806
807

########### install files ###############

808
809
810
install(FILES kwin.kcfg DESTINATION ${KCFG_INSTALL_DIR} RENAME ${KWIN_NAME}.kcfg)
install(FILES colorcorrection/colorcorrect_settings.kcfg DESTINATION ${KCFG_INSTALL_DIR} RENAME ${KWIN_NAME}_colorcorrect.kcfg)
install(FILES kwin.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR} RENAME ${KWIN_NAME}.notifyrc)
811
812
install(
    FILES
813
        org.kde.KWin.VirtualDesktopManager.xml
814
        org.kde.KWin.xml
815
        org.kde.kwin.ColorCorrect.xml
816
        org.kde.kwin.Compositing.xml
817
818
        org.kde.kwin.Effects.xml
    DESTINATION
819
        ${KDE_INSTALL_DBUSINTERFACEDIR}
820
)
821
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kwin_export.h DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
822

823
# Install the KWin/Script service type
824
install(FILES scripting/kwinscript.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
825

826
add_subdirectory(qml)
827

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
828
if (BUILD_TESTING)
829
830
831
832
    find_package(WaylandProtocols REQUIRED)
    find_package(QtWaylandScanner ${QT_MIN_VERSION} REQUIRED)
    find_package(Wayland REQUIRED COMPONENTS Client)

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
833
834
835
836
    add_subdirectory(autotests)
    add_subdirectory(tests)
endif()

837
838
839
if (KF5DocTools_FOUND)
    add_subdirectory(doc)
endif()
840

841
842
add_subdirectory(kconf_update)

843
844
845
846
# 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})

847
848
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)

849
include(CMakePackageConfigHelpers)
850
set(CMAKECONFIG_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/KWinDBusInterface")
851
configure_package_config_file(KWinDBusInterfaceConfig.cmake.in
852
    "${CMAKE_CURRENT_BINARY_DIR}/KWinDBusInterfaceConfig.cmake"
853
    PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR
854
    INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR})
855
856
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/KWinDBusInterfaceConfig.cmake
    DESTINATION ${CMAKECONFIG_INSTALL_DIR})
857
858
859

ecm_install_configured_files(INPUT plasma-kwin_x11.service.in plasma-kwin_wayland.service.in @ONLY
            DESTINATION ${SYSTEMD_USER_UNIT_INSTALL_DIR})