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

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

Laurent Montel's avatar
Laurent Montel committed
6
7
set(CMAKE_C_STANDARD 99)

8
set(QT_MIN_VERSION "5.15.0")
9
set(KF5_MIN_VERSION "5.94")
10
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
11

Nicolas Fella's avatar
Nicolas Fella committed
12
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
13
14
15

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

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

21
22
23
24
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDEClangFormat)
25
include(KDEGitCommitHooks)
26
27
28
29
30
31
32

include(ECMInstallIcons)
include(ECMOptionalAddSubdirectory)
include(ECMConfiguredInstall)
include(ECMQtDeclareLoggingCategory)

find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
33
34
35
36
37
38
39
    Concurrent
    Core
    DBus
    Quick
    UiTools
    Widgets
)
40
41
42
43
44
45
if (QT_MAJOR_VERSION EQUAL "5")
    find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS X11Extras)
    find_package(Qt5XkbCommonSupport REQUIRED)
else()
    find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS WaylandClient)
endif()
46

47
48
find_package(Qt${QT_MAJOR_VERSION}Test ${QT_MIN_VERSION} CONFIG QUIET)
set_package_properties(Qt${QT_MAJOR_VERSION}Test PROPERTIES
49
50
51
    PURPOSE "Required for tests"
    TYPE OPTIONAL
)
52
53
add_feature_info("Qt${QT_MAJOR_VERSION}Test" Qt${QT_MAJOR_VERSION}Test_FOUND "Required for building tests")
if (NOT Qt${QT_MAJOR_VERSION}Test_FOUND)
54
55
56
    set(BUILD_TESTING OFF CACHE BOOL "Build the testing tree.")
endif()

57
58
59
60
61
62
63
64
add_definitions(
    -DQT_DISABLE_DEPRECATED_BEFORE=0

    -DQT_NO_KEYWORDS

    -DQT_USE_QSTRINGBUILDER
    -DQT_NO_URL_CAST_FROM_STRING
    -DQT_NO_CAST_TO_ASCII
65
    -DQT_NO_FOREACH
66
)
67

68
69
70
71
72
# 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)

73
set(CMAKE_CXX_STANDARD 17)
Martin Flöser's avatar
Martin Flöser committed
74
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Martin Flöser's avatar
Martin Flöser committed
75

76
# required frameworks by Core
77
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
78
    Auth
79
80
81
82
    Config
    ConfigWidgets
    CoreAddons
    Crash
83
    DBusAddons
84
85
    GlobalAccel
    I18n
86
    IdleTime
87
    Package
88
89
90
91
92
    Plasma
    WidgetsAddons
    WindowSystem
)
# required frameworks by config modules
93
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
94
    Declarative
95
96
    KCMUtils
    NewStuff
97
    Service
98
    XmlGui
99
    ItemViews
100
101
)

102
103
find_package(Threads)
set_package_properties(Threads PROPERTIES
104
105
106
    PURPOSE "Needed for VirtualTerminal support in KWin Wayland"
    TYPE REQUIRED
)
107

108
109
110
111
112
113
find_package(KF5Wayland ${KF5_MIN_VERSION} CONFIG)
set_package_properties(KF5Wayland PROPERTIES
    PURPOSE "Required to build wayland platform plugin and tests"
    TYPE REQUIRED
)

114
# optional frameworks
115
find_package(KF5Activities ${KF5_MIN_VERSION} CONFIG)
116
set_package_properties(KF5Activities PROPERTIES
117
118
119
    PURPOSE "Enable building of KWin with kactivities support"
    TYPE OPTIONAL
)
120
121
add_feature_info("KF5Activities" KF5Activities_FOUND "Enable building of KWin with kactivities support")

122
find_package(KF5DocTools ${KF5_MIN_VERSION} CONFIG)
123
set_package_properties(KF5DocTools PROPERTIES
124
125
126
    PURPOSE "Enable building documentation"
    TYPE OPTIONAL
)
127
add_feature_info("KF5DocTools" KF5DocTools_FOUND "Enable building documentation")
128

Benjamin Port's avatar
Benjamin Port committed
129
130
131
132
133
134
135
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")

136
137
138
find_package(KF5Kirigami2 ${KF5_MIN_VERSION} CONFIG)
set_package_properties(KF5Kirigami2 PROPERTIES
    DESCRIPTION "A QtQuick based components set"
139
    PURPOSE "Required at runtime for Virtual desktop KCM"
140
141
142
    TYPE RUNTIME
)

143
find_package(KDecoration2 ${PROJECT_VERSION} CONFIG REQUIRED)
144

Martin Flöser's avatar
Martin Flöser committed
145
find_package(Breeze 5.9.0 CONFIG)
146
set_package_properties(Breeze PROPERTIES
147
148
149
150
151
    TYPE OPTIONAL
    PURPOSE "For setting the default window decoration plugin"
)
if (${Breeze_FOUND})
    if (${BREEZE_WITH_KDECORATION})
152
153
154
155
156
157
158
159
160
        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")

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

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
167
find_package(epoxy 1.3)
168
169
170
171
172
173
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
174

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

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

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
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
find_package(Wayland 1.20 REQUIRED COMPONENTS
    Server
)

find_package(WaylandProtocols 1.25)
set_package_properties(WaylandProtocols PROPERTIES
    TYPE REQUIRED
    PURPOSE "Collection of Wayland protocols that add functionality not available in the Wayland core protocol"
    URL "https://gitlab.freedesktop.org/wayland/wayland-protocols/"
)

find_package(PlasmaWaylandProtocols CONFIG)
set_package_properties(PlasmaWaylandProtocols PROPERTIES
    TYPE REQUIRED
    PURPOSE "Collection of Plasma-specific Wayland protocols"
    URL "https://invent.kde.org/libraries/plasma-wayland-protocols/"
)

if (QT_MAJOR_VERSION EQUAL "5")
    find_package(QtWaylandScanner)
    set_package_properties(QtWaylandScanner PROPERTIES
        TYPE REQUIRED
        PURPOSE "Required for building KWin with Wayland support"
    )
endif()

220
find_package(XKB 0.7.0)
221
set_package_properties(XKB PROPERTIES
222
223
224
    TYPE REQUIRED
    PURPOSE "Required for building KWin with Wayland support"
)
225

David Redondo's avatar
David Redondo committed
226
find_package(Libinput 1.19)
Martin Flöser's avatar
Martin Flöser committed
227
set_package_properties(Libinput PROPERTIES TYPE REQUIRED PURPOSE "Required for input handling on Wayland.")
Martin Flöser's avatar
Martin Flöser committed
228
229

find_package(UDev)
230
set_package_properties(UDev PROPERTIES
231
    URL "https://www.freedesktop.org/wiki/Software/systemd/"
232
233
234
235
    DESCRIPTION "Linux device library."
    TYPE REQUIRED
    PURPOSE "Required for input handling on Wayland."
)
Martin Flöser's avatar
Martin Flöser committed
236

237
find_package(Libdrm 2.4.62)
238
set_package_properties(Libdrm PROPERTIES TYPE REQUIRED PURPOSE "Required for drm output on Wayland.")
239

240
find_package(gbm)
Xaver Hugl's avatar
Xaver Hugl committed
241
set_package_properties(gbm PROPERTIES TYPE REQUIRED PURPOSE "Required for egl output of drm backend.")
242
243
244
245
246
if (${gbm_VERSION} GREATER_EQUAL 21.1)
    set(HAVE_GBM_BO_GET_FD_FOR_PLANE 1)
else()
    set(HAVE_GBM_BO_GET_FD_FOR_PLANE 0)
endif()
247

Nicolas Fella's avatar
Nicolas Fella committed
248
pkg_check_modules(Libxcvt IMPORTED_TARGET libxcvt>=0.1.1 REQUIRED)
249
250
add_feature_info(Libxcvt Libxcvt_FOUND "Required for generating modes in the drm backend")

251
find_package(X11)
252
253
254
255
256
set_package_properties(X11 PROPERTIES
    DESCRIPTION "X11 libraries"
    URL "https://www.x.org"
    TYPE REQUIRED
)
257
add_feature_info("XInput" X11_Xi_FOUND "Required for poll-free mouse cursor updates")
258
set(HAVE_X11_XINPUT ${X11_Xinput_FOUND})
259

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
260
261
262
263
find_package(lcms2)
set_package_properties(lcms2 PROPERTIES
    DESCRIPTION "Small-footprint color management engine"
    URL "http://www.littlecms.com"
Xaver Hugl's avatar
Xaver Hugl committed
264
265
    TYPE REQUIRED
    PURPOSE "Required for the color management system"
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
266
267
)

268
# All the required XCB components
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
find_package(XCB 1.10 REQUIRED COMPONENTS
    COMPOSITE
    CURSOR
    DAMAGE
    GLX
    ICCCM
    IMAGE
    KEYSYMS
    RANDR
    RENDER
    SHAPE
    SHM
    SYNC
    XCB
    XFIXES
284
285
286
287
)
set_package_properties(XCB PROPERTIES TYPE REQUIRED)

# and the optional XCB dependencies
288
289
290
if (XCB_ICCCM_VERSION VERSION_LESS "0.4")
    set(XCB_ICCCM_FOUND FALSE)
endif()
291
292
add_feature_info("XCB-ICCCM" XCB_ICCCM_FOUND "Required for building test applications for KWin")

293
294
find_package(X11_XCB)
set_package_properties(X11_XCB PROPERTIES
295
296
297
    PURPOSE "Required for building X11 windowed backend of kwin_wayland"
    TYPE OPTIONAL
)
298

299
# dependencies for QPA plugin
300
301
302
303
304
305
if (QT_MAJOR_VERSION EQUAL "5")
    find_package(Qt5FontDatabaseSupport REQUIRED)
    find_package(Qt5ThemeSupport REQUIRED)
    find_package(Qt5ServiceSupport REQUIRED)
    find_package(Qt5EventDispatcherSupport REQUIRED)
endif()
306

307
find_package(Freetype REQUIRED)
308
309
310
311
312
313
set_package_properties(Freetype PROPERTIES
    DESCRIPTION "A font rendering engine"
    URL "https://www.freetype.org"
    TYPE REQUIRED
    PURPOSE "Needed for KWin's QPA plugin."
)
314
find_package(Fontconfig REQUIRED)
315
set_package_properties(Fontconfig PROPERTIES
316
317
318
    TYPE REQUIRED
    PURPOSE "Needed for KWin's QPA plugin."
)
319

320
321
find_package(Xwayland)
set_package_properties(Xwayland PROPERTIES
Volker Krause's avatar
Volker Krause committed
322
    URL "https://x.org"
323
324
325
    DESCRIPTION "Xwayland X server"
    TYPE RUNTIME
    PURPOSE "Needed for running kwin_wayland"
326
)
327
set(HAVE_XWAYLAND_LISTENFD ${Xwayland_HAVE_LISTENFD})
328

329
330
331
332
333
334
335
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})

336
337
338
339
340
341
342
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"
)

343
344
345
346
347
348
349
350
351
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})

352
include(ECMFindQmlModule)
353
354
355
356
357
358
359
360
361
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)

362
########### configure tests ###############
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
363
364
365
366
include(CMakeDependentOption)

option(KWIN_BUILD_DECORATIONS "Enable building of KWin decorations." ON)
option(KWIN_BUILD_KCMS "Enable building of KWin configuration modules." ON)
367
option(KWIN_BUILD_NOTIFICATIONS "Enable building of KWin with knotifications support" ON)
368
option(KWIN_BUILD_SCREENLOCKER "Enable building of KWin lockscreen functionality" ON)
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
369
option(KWIN_BUILD_TABBOX "Enable building of KWin Tabbox functionality" ON)
370
cmake_dependent_option(KWIN_BUILD_ACTIVITIES "Enable building of KWin with kactivities support" ON "KF5Activities_FOUND" OFF)
Benjamin Port's avatar
Benjamin Port committed
371
cmake_dependent_option(KWIN_BUILD_RUNNERS "Enable building of KWin with krunner support" ON "KF5Runner_FOUND" OFF)
372

373
374
# Binary name of KWin
set(KWIN_NAME "kwin")
Hrvoje Senjan's avatar
Hrvoje Senjan committed
375
376
set(KWIN_INTERNAL_NAME_X11 "kwin_x11")
set(KWIN_INTERNAL_NAME_WAYLAND "kwin_wayland")
377

378
379
include_directories(${XKB_INCLUDE_DIR})

380
set(HAVE_EPOXY_GLX ${epoxy_HAS_GLX})
381

382
# for kwin internal things
383
set(HAVE_X11_XCB ${X11_XCB_FOUND})
384

385
include(CheckIncludeFile)
386
include(CheckIncludeFiles)
387
include(CheckSymbolExists)
388

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

394

395
pkg_check_modules(PipeWire IMPORTED_TARGET libpipewire-0.3>=0.3.29)
396
397
add_feature_info(PipeWire PipeWire_FOUND "Required for Wayland screencasting")

398
399
400
401
if (KWIN_BUILD_NOTIFICATIONS)
    find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Notifications)
endif()

402
403
404
405
406
407
408
409
if (KWIN_BUILD_SCREENLOCKER)
    find_package(KScreenLocker CONFIG REQUIRED)
    set_package_properties(KScreenLocker PROPERTIES
        TYPE REQUIRED
        PURPOSE "For screenlocker integration in kwin_wayland"
    )
endif()

410
########### global ###############
411

412
include_directories(BEFORE
413
    ${CMAKE_CURRENT_BINARY_DIR}/src/libkwineffects
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
414
    ${CMAKE_CURRENT_BINARY_DIR}/src/wayland
415
416
417
418
419
    ${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
420
    ${CMAKE_CURRENT_SOURCE_DIR}/src/colors
421
)
422

423
424
if (KF5DocTools_FOUND)
    add_subdirectory(doc)
Martin Flöser's avatar
Martin Flöser committed
425
endif()
426

427
428
429
430
431
432
433
434
435
436
437
438
439
include(ECMSetupQtPluginMacroNames)
ecm_setup_qtplugin_macro_names(
    JSON_ARG2
        "KWIN_EFFECT_FACTORY"
    JSON_ARG3
        "KWIN_EFFECT_FACTORY_ENABLED"
        "KWIN_EFFECT_FACTORY_SUPPORTED"
    JSON_ARG4
        "KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED"
    CONFIG_CODE_VARIABLE
        PACKAGE_SETUP_AUTOMOC_VARIABLES
)

440
add_subdirectory(data)
441
442
add_subdirectory(kconf_update)
add_subdirectory(src)
443

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
444
if (BUILD_TESTING)
445
446
    find_package(Wayland REQUIRED COMPONENTS Client)

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
447
448
449
450
    add_subdirectory(autotests)
    add_subdirectory(tests)
endif()

451
452
453
# 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})
454
kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
455

456
457
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)

458
include(CMakePackageConfigHelpers)
459
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KWinDBusInterface")
460
configure_package_config_file(KWinDBusInterfaceConfig.cmake.in
461
    "${CMAKE_CURRENT_BINARY_DIR}/KWinDBusInterfaceConfig.cmake"
462
    PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR
463
    INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR})
464
465
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/KWinDBusInterfaceConfig.cmake
    DESTINATION ${CMAKECONFIG_INSTALL_DIR})
466

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