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

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

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

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

11
find_package(ECM 5.38 REQUIRED NO_MODULE)
12 13 14

include(FeatureSummary)
include(WriteBasicConfigVersionFile)
15
include(GenerateExportHeader)
16 17

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

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

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

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

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

54 55 56 57 58
# 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)

59
set(CMAKE_CXX_STANDARD 17)
Martin Flöser's avatar
Martin Flöser committed
60
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Martin Flöser's avatar
Martin Flöser committed
61

62 63
find_package(Qt5Multimedia QUIET)
set_package_properties(Qt5Multimedia PROPERTIES
64 65 66
    PURPOSE "Runtime-only dependency for effect video playback"
    TYPE RUNTIME
)
67 68

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

97 98
find_package(Threads)
set_package_properties(Threads PROPERTIES
99 100 101
    PURPOSE "Needed for VirtualTerminal support in KWin Wayland"
    TYPE REQUIRED
)
102

103
# optional frameworks
104
find_package(KF5Activities ${KF5_MIN_VERSION} CONFIG)
105
set_package_properties(KF5Activities PROPERTIES
106 107 108
    PURPOSE "Enable building of KWin with kactivities support"
    TYPE OPTIONAL
)
109 110
add_feature_info("KF5Activities" KF5Activities_FOUND "Enable building of KWin with kactivities support")

111
find_package(KF5DocTools ${KF5_MIN_VERSION} CONFIG)
112
set_package_properties(KF5DocTools PROPERTIES
113 114 115
    PURPOSE "Enable building documentation"
    TYPE OPTIONAL
)
116
add_feature_info("KF5DocTools" KF5DocTools_FOUND "Enable building documentation")
117

Benjamin Port's avatar
Benjamin Port committed
118 119 120 121 122 123 124
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")

125 126 127
find_package(KF5Kirigami2 ${KF5_MIN_VERSION} CONFIG)
set_package_properties(KF5Kirigami2 PROPERTIES
    DESCRIPTION "A QtQuick based components set"
128
    PURPOSE "Required at runtime for Virtual desktop KCM"
129 130 131
    TYPE RUNTIME
)

Heiko Becker's avatar
Heiko Becker committed
132
find_package(KDecoration2 5.18.0 CONFIG REQUIRED)
133

134 135
find_package(KScreenLocker CONFIG REQUIRED)
set_package_properties(KScreenLocker PROPERTIES
136 137 138
    TYPE REQUIRED
    PURPOSE "For screenlocker integration in kwin_wayland"
)
139

140 141 142 143 144 145
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
146
find_package(Breeze 5.9.0 CONFIG)
147
set_package_properties(Breeze PROPERTIES
148 149 150 151 152
    TYPE OPTIONAL
    PURPOSE "For setting the default window decoration plugin"
)
if (${Breeze_FOUND})
    if (${BREEZE_WITH_KDECORATION})
153 154 155 156 157 158 159 160 161
        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")

162 163
find_package(EGL)
set_package_properties(EGL PROPERTIES
164 165 166
    TYPE RUNTIME
    PURPOSE "Required to build KWin with EGL support"
)
167

Fredrik Höglund's avatar
Fredrik Höglund committed
168
find_package(epoxy)
169 170 171 172 173 174
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
175

176
set(HAVE_DL_LIBRARY FALSE)
177
if (epoxy_HAS_GLX)
178
    find_library(DL_LIBRARY dl)
179
    if (DL_LIBRARY)
180 181 182 183
        set(HAVE_DL_LIBRARY TRUE)
    endif()
endif()

184
find_package(Wayland 1.2 OPTIONAL_COMPONENTS Egl)
185
set_package_properties(Wayland PROPERTIES
186 187 188
    TYPE REQUIRED
    PURPOSE "Required for building KWin with Wayland support"
)
189
add_feature_info("Wayland::EGL" Wayland_Egl_FOUND "Enable building of Wayland backend.")
190
set(HAVE_WAYLAND_EGL FALSE)
191
if (Wayland_Egl_FOUND)
192 193
    set(HAVE_WAYLAND_EGL TRUE)
endif()
194

195
find_package(XKB 0.7.0)
196
set_package_properties(XKB PROPERTIES
197 198 199
    TYPE REQUIRED
    PURPOSE "Required for building KWin with Wayland support"
)
200

Martin Flöser's avatar
Martin Flöser committed
201
find_package(Libinput 1.9)
Martin Flöser's avatar
Martin Flöser committed
202
set_package_properties(Libinput PROPERTIES TYPE REQUIRED PURPOSE "Required for input handling on Wayland.")
Martin Flöser's avatar
Martin Flöser committed
203 204

find_package(UDev)
205
set_package_properties(UDev PROPERTIES
206
    URL "https://www.freedesktop.org/wiki/Software/systemd/"
207 208 209 210
    DESCRIPTION "Linux device library."
    TYPE REQUIRED
    PURPOSE "Required for input handling on Wayland."
)
Martin Flöser's avatar
Martin Flöser committed
211

212
find_package(Libdrm 2.4.62)
213 214
set_package_properties(Libdrm PROPERTIES TYPE OPTIONAL PURPOSE "Required for drm output on Wayland.")
set(HAVE_DRM FALSE)
215
if (Libdrm_FOUND)
216 217 218
    set(HAVE_DRM TRUE)
endif()

219
find_package(gbm)
Yuri Chornoivan's avatar
Yuri Chornoivan committed
220
set_package_properties(gbm PROPERTIES TYPE OPTIONAL PURPOSE "Required for egl output of drm backend.")
221
set(HAVE_GBM FALSE)
222
if (HAVE_DRM AND gbm_FOUND)
223 224 225
    set(HAVE_GBM TRUE)
endif()

226
option(KWIN_BUILD_EGL_STREAM_BACKEND "Enable building of EGLStream based DRM backend" ON)
227
if (HAVE_DRM AND KWIN_BUILD_EGL_STREAM_BACKEND)
228 229 230
    set(HAVE_EGL_STREAMS TRUE)
endif()

231 232
find_package(libhybris)
set_package_properties(libhybris PROPERTIES TYPE OPTIONAL PURPOSE "Required for libhybris backend")
Martin Flöser's avatar
Martin Flöser committed
233
set(HAVE_LIBHYBRIS ${libhybris_FOUND})
234

235
find_package(X11)
236 237 238 239 240
set_package_properties(X11 PROPERTIES
    DESCRIPTION "X11 libraries"
    URL "https://www.x.org"
    TYPE REQUIRED
)
241 242
add_feature_info("XInput" X11_Xinput_FOUND "Required for poll-free mouse cursor updates")
set(HAVE_X11_XINPUT ${X11_Xinput_FOUND})
243

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
244 245 246 247 248 249 250 251
find_package(lcms2)
set_package_properties(lcms2 PROPERTIES
    DESCRIPTION "Small-footprint color management engine"
    URL "http://www.littlecms.com"
    TYPE OPTIONAL
)
set(HAVE_LCMS2 ${lcms2_FOUND})

252
# All the required XCB components
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
find_package(XCB 1.10 REQUIRED COMPONENTS
    COMPOSITE
    CURSOR
    DAMAGE
    GLX
    ICCCM
    IMAGE
    KEYSYMS
    RANDR
    RENDER
    SHAPE
    SHM
    SYNC
    XCB
    XFIXES
268 269 270 271
)
set_package_properties(XCB PROPERTIES TYPE REQUIRED)

# and the optional XCB dependencies
272 273 274
if (XCB_ICCCM_VERSION VERSION_LESS "0.4")
    set(XCB_ICCCM_FOUND FALSE)
endif()
275 276
add_feature_info("XCB-ICCCM" XCB_ICCCM_FOUND "Required for building test applications for KWin")

277 278
find_package(X11_XCB)
set_package_properties(X11_XCB PROPERTIES
279 280 281
    PURPOSE "Required for building X11 windowed backend of kwin_wayland"
    TYPE OPTIONAL
)
282

283
# dependencies for QPA plugin
Martin Flöser's avatar
Martin Flöser committed
284 285 286
find_package(Qt5FontDatabaseSupport REQUIRED)
find_package(Qt5ThemeSupport REQUIRED)
find_package(Qt5EventDispatcherSupport REQUIRED)
287

288
find_package(Freetype REQUIRED)
289 290 291 292 293 294
set_package_properties(Freetype PROPERTIES
    DESCRIPTION "A font rendering engine"
    URL "https://www.freetype.org"
    TYPE REQUIRED
    PURPOSE "Needed for KWin's QPA plugin."
)
295
find_package(Fontconfig REQUIRED)
296
set_package_properties(Fontconfig PROPERTIES
297 298 299
    TYPE REQUIRED
    PURPOSE "Needed for KWin's QPA plugin."
)
300

301 302
find_package(Xwayland)
set_package_properties(Xwayland PROPERTIES
Volker Krause's avatar
Volker Krause committed
303
    URL "https://x.org"
304 305 306
    DESCRIPTION "Xwayland X server"
    TYPE RUNTIME
    PURPOSE "Needed for running kwin_wayland"
307
)
308

309 310 311 312 313 314 315
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})

316 317 318 319 320 321 322
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"
)

323 324 325 326 327 328 329 330 331
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
332 333 334 335 336 337 338 339
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()

340 341 342 343 344 345 346 347 348 349
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)

350
########### configure tests ###############
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
351 352 353 354 355 356
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)
357
cmake_dependent_option(KWIN_BUILD_ACTIVITIES "Enable building of KWin with kactivities support" ON "KF5Activities_FOUND" OFF)
Benjamin Port's avatar
Benjamin Port committed
358
cmake_dependent_option(KWIN_BUILD_RUNNERS "Enable building of KWin with krunner support" ON "KF5Runner_FOUND" OFF)
359

360 361
# Binary name of KWin
set(KWIN_NAME "kwin")
Hrvoje Senjan's avatar
Hrvoje Senjan committed
362 363
set(KWIN_INTERNAL_NAME_X11 "kwin_x11")
set(KWIN_INTERNAL_NAME_WAYLAND "kwin_wayland")
364

365
# KWIN_HAVE_XRENDER_COMPOSITING - whether XRender-based compositing support is available: may be disabled
366 367
if (KWIN_BUILD_XRENDER_COMPOSITING)
    set(KWIN_HAVE_XRENDER_COMPOSITING 1)
Martin Flöser's avatar
Martin Flöser committed
368
endif()
369

370
include_directories(${XKB_INCLUDE_DIR})
371

372
include_directories(${epoxy_INCLUDE_DIR})
373
set(HAVE_EPOXY_GLX ${epoxy_HAS_GLX})
374

375
# for things that are also used by kwin libraries
376
configure_file(libkwineffects/kwinconfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/libkwineffects/kwinconfig.h )
377
# for kwin internal things
378
set(HAVE_X11_XCB ${X11_XCB_FOUND})
379

380
include(CheckIncludeFile)
381
include(CheckIncludeFiles)
382
include(CheckSymbolExists)
383 384
check_include_files(unistd.h HAVE_UNISTD_H)
check_include_files(malloc.h HAVE_MALLOC_H)
385 386 387

check_include_file("sys/prctl.h" HAVE_SYS_PRCTL_H)
check_symbol_exists(PR_SET_DUMPABLE "sys/prctl.h" HAVE_PR_SET_DUMPABLE)
388
check_symbol_exists(PR_SET_PDEATHSIG "sys/prctl.h" HAVE_PR_SET_PDEATHSIG)
389 390 391 392 393 394 395 396
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")
397

398
check_include_file("sys/sysmacros.h" HAVE_SYS_SYSMACROS_H)
399

400 401 402 403 404 405 406 407
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")
408

409 410 411 412 413
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")

414 415 416 417

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

418
configure_file(config-kwin.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kwin.h)
419

420
########### global ###############
421
set(kwin_effects_dbus_xml ${CMAKE_CURRENT_SOURCE_DIR}/org.kde.kwin.Effects.xml)
422
qt5_add_dbus_interface(effects_interface_SRCS ${kwin_effects_dbus_xml} kwineffects_interface)
423
add_library(KWinEffectsInterface STATIC ${effects_interface_SRCS})
424
target_link_libraries(KWinEffectsInterface Qt5::DBus)
425

426
include_directories(BEFORE
427
    ${CMAKE_CURRENT_BINARY_DIR}/libkwineffects
428
    ${CMAKE_CURRENT_BINARY_DIR}
429
    ${CMAKE_CURRENT_SOURCE_DIR}/libkwineffects
430
    ${CMAKE_CURRENT_SOURCE_DIR}/effects
431
    ${CMAKE_CURRENT_SOURCE_DIR}/tabbox
432
    ${CMAKE_CURRENT_SOURCE_DIR}/platformsupport
433
)
434

435 436 437
add_subdirectory(libkwineffects)
if (KWIN_BUILD_KCMS)
    add_subdirectory(kcmkwin)
Martin Flöser's avatar
Martin Flöser committed
438
endif()
439

440
add_subdirectory(data)
441

442 443 444
add_subdirectory(effects)
add_subdirectory(scripts)
add_subdirectory(tabbox)
445
add_subdirectory(scripting)
446
add_subdirectory(helpers)
447

448 449
########### next target ###############

David Edmundson's avatar
David Edmundson committed
450
set(kwin_SRCS
451
    3rdparty/xcursor.c
452 453
    abstract_client.cpp
    abstract_opengl_context_attribute_builder.cpp
Roman Gilg's avatar
Roman Gilg committed
454
    abstract_output.cpp
455
    abstract_wayland_output.cpp
456
    activation.cpp
Kai Uwe Broulik's avatar
Kai Uwe Broulik committed
457
    appmenu.cpp
458 459 460 461 462 463 464 465 466 467 468 469 470
    atoms.cpp
    client_machine.cpp
    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
471
    dmabuftexture.cpp
472 473
    effectloader.cpp
    effects.cpp
474
    egl_context_attribute_builder.cpp
475 476 477 478 479 480
    events.cpp
    focuschain.cpp
    geometrytip.cpp
    gestures.cpp
    globalshortcuts.cpp
    group.cpp
481
    idle_inhibition.cpp
482 483 484
    input.cpp
    input_event.cpp
    input_event_spy.cpp
485
    inputmethod.cpp
486
    inputpanelv1client.cpp
487
    inputpanelv1integration.cpp
488 489 490 491 492 493 494
    internal_client.cpp
    keyboard_input.cpp
    keyboard_layout.cpp
    keyboard_layout_switching.cpp
    keyboard_repeat.cpp
    killwindow.cpp
    layers.cpp
495 496
    layershellv1client.cpp
    layershellv1integration.cpp
Martin Flöser's avatar
Martin Flöser committed
497
    libinput/connection.cpp
498
    libinput/context.cpp
Martin Flöser's avatar
Martin Flöser committed
499 500 501
    libinput/device.cpp
    libinput/events.cpp
    libinput/libinput_logging.cpp
Roman Gilg's avatar
Roman Gilg committed
502
    linux_dmabuf.cpp
503 504 505 506 507 508 509 510 511 512 513 514 515
    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
516 517
    plugin.cpp
    pluginmanager.cpp
518 519 520
    pointer_input.cpp
    popup_input_filter.cpp
    rootinfo_filter.cpp
Henri Chain's avatar
Henri Chain committed
521
    rulebooksettings.cpp
522
    rules.cpp
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538
    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
539
    subsurfacemonitor.cpp
540
    syncalarmx11filter.cpp
541
    tablet_input.cpp
542 543
    thumbnailitem.cpp
    toplevel.cpp
544
    touch_hide_cursor_spy.cpp
545 546 547 548 549 550 551 552 553 554
    touch_input.cpp
    udev.cpp
    unmanaged.cpp
    useractions.cpp
    utils.cpp
    virtualdesktops.cpp
    virtualdesktopsdbustypes.cpp
    virtualkeyboard_dbus.cpp
    was_user_interaction_x11_filter.cpp
    wayland_server.cpp
555
    waylandclient.cpp
556
    waylandshellintegration.cpp
557 558
    window_property_notify_x11_filter.cpp
    workspace.cpp
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
559
    x11client.cpp
560 561
    x11eventfilter.cpp
    xcbutils.cpp
562
    xcursortheme.cpp
563
    xdgshellclient.cpp
564
    xdgshellintegration.cpp
565
    xkb.cpp
566
    xwaylandclient.cpp
567
    xwl/xwayland_interface.cpp
568
)
569

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
kconfig_add_kcfg_files(kwin_SRCS settings.kcfgc)
Henri Chain's avatar
Henri Chain committed
610 611
kconfig_add_kcfg_files(kwin_SRCS rulesettings.kcfgc)
kconfig_add_kcfg_files(kwin_SRCS rulebooksettingsbase.kcfgc)
612

David Edmundson's avatar
David Edmundson committed
613 614 615 616 617
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 ${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)
618
qt5_add_dbus_adaptor(kwin_SRCS org.kde.KWin.Plugins.xml dbusinterface.h KWin::PluginManagerDBusInterface)
619

David Edmundson's avatar
David Edmundson committed
620 621 622
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
623

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

629 630 631
########### target link libraries ###############

set(kwin_OWN_LIBS
632
    kwineffects
633
    kwin4_effect_builtins
634 635 636
)

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

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

    KDecoration2::KDecoration
    KDecoration2::KDecoration2Private

660
    PW::KScreenLocker
661 662 663
)

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

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

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

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

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

David Edmundson's avatar
David Edmundson committed
706
add_library(kwin SHARED ${kwin_SRCS})
707
if (Libinput_VERSION_STRING VERSION_GREATER 1.14)
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
708
    set_source_files_properties(libinput/connection.cpp PROPERTIES COMPILE_DEFINITIONS LIBINPUT_HAS_TOTEM)
709
endif ()
710

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

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

718
generate_export_header(kwin EXPORT_FILE_NAME kwin_export.h)
719

Tobias C. Berner's avatar
Tobias C. Berner committed
720 721 722 723 724 725
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
726 727
add_executable(kwin_x11 main_x11.cpp)
target_link_libraries(kwin_x11 kwin KF5::Crash Qt5::X11Extras)
728

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

732 733
set(kwin_XWAYLAND_SRCS
   ${CMAKE_CURRENT_SOURCE_DIR}/xwl/clipboard.cpp
734
   ${CMAKE_CURRENT_SOURCE_DIR}/xwl/databridge.cpp
735 736 737 738
   ${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
739 740 741 742
   ${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
743
)
744 745 746 747 748 749 750 751 752
include(ECMQtDeclareLoggingCategory)
ecm_qt_declare_logging_category(kwin_XWAYLAND_SRCS
    HEADER
        xwayland_logging.h
    IDENTIFIER
        KWIN_XWL
    CATEGORY_NAME
        kwin_xwl
    DEFAULT_SEVERITY
753
        Warning
754 755
)

756 757
set(kwin_WAYLAND_SRCS
   main_wayland.cpp
758
   tabletmodemanager.cpp
759
)
760

761
add_executable(kwin_wayland ${kwin_WAYLAND_SRCS} ${kwin_XWAYLAND_SRCS})
762 763 764 765
target_link_libraries(kwin_wayland
                      kwin
                      KF5::Crash
)
766 767 768
if (HAVE_LIBCAP)
    target_link_libraries(kwin_wayland ${Libcap_LIBRARIES})
endif()
769

770
install(TARGETS kwin_wayland ${INSTALL_TARGETS_DEFAULT_ARGS})
771 772 773 774 775 776
if (HAVE_LIBCAP)
    install(
    CODE "execute_process(
            COMMAND
                ${SETCAP_EXECUTABLE}
                CAP_SYS_NICE=+ep
777
                \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/kwin_wayland)"
778 779
    )
endif()
780

781
add_subdirectory(platformsupport)
782
add_subdirectory(plugins)
783 784 785

target_link_libraries(kwin_wayland
    KWinQpaPlugin
786 787 788
    KF5GlobalAccelKWinPlugin
    KF5WindowSystemKWinPlugin
    KF5IdleTimeKWinPlugin
789
)
790

791 792 793 794
if (PipeWire_FOUND)
    target_link_libraries(kwin_wayland KWinScreencastPlugin)
endif()

795 796
########### install files ###############

797 798
install(FILES kwin.kcfg DESTINATION ${KCFG_INSTALL_DIR} RENAME ${KWIN_NAME}.kcfg)
install(FILES kwin.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR} RENAME ${KWIN_NAME}.notifyrc)
799 800
install(
    FILES
801
        org.kde.KWin.VirtualDesktopManager.xml
802
        org.kde.KWin.xml
803
        org.kde.kwin.Compositing.xml
804
        org.kde.kwin.Effects.xml
805
        org.kde.KWin.Plugins.xml
806
    DESTINATION
807
        ${KDE_INSTALL_DBUSINTERFACEDIR}
808
)
809
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kwin_export.h DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
810

811
# Install the KWin/Script service type
812
install(FILES scripting/kwinscript.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
813

814
add_subdirectory(qml)
815

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
816
if (BUILD_TESTING)
817 818 819 820
    find_package(WaylandProtocols REQUIRED)
    find_package(QtWaylandScanner ${QT_MIN_VERSION} REQUIRED)
    find_package(Wayland REQUIRED COMPONENTS Client)

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
821 822 823 824
    add_subdirectory(autotests)
    add_subdirectory(tests)
endif()

825 826 827
if (KF5DocTools_FOUND)
    add_subdirectory(doc)
endif()
828

829 830
add_subdirectory(kconf_update)

831 832 833 834
# 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})

835 836
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)

837
include(CMakePackageConfigHelpers)
838
set(CMAKECONFIG_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/KWinDBusInterface")
839
configure_package_config_file(KWinDBusInterfaceConfig.cmake.in
840
    "${CMAKE_CURRENT_BINARY_DIR}/KWinDBusInterfaceConfig.cmake"
841
    PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR
842
    INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR})
843 844
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/KWinDBusInterfaceConfig.cmake
    DESTINATION ${CMAKECONFIG_INSTALL_DIR})
845 846 847

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