Warning, /plasma/kwin/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 cmake_minimum_required(VERSION 3.16)
0002 
0003 set(PROJECT_VERSION "5.27.10") # Handled by release scripts
0004 project(KWin VERSION ${PROJECT_VERSION})
0005 
0006 set(CMAKE_C_STANDARD 99)
0007 set(CMAKE_CXX_STANDARD 20)
0008 set(CMAKE_CXX_STANDARD_REQUIRED ON)
0009 
0010 set(QT_MIN_VERSION "5.15.2")
0011 set(KF5_MIN_VERSION "5.102.0")
0012 set(KDE_COMPILERSETTINGS_LEVEL "5.82")
0013 
0014 find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
0015 
0016 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
0017 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH})
0018 
0019 include(CMakeDependentOption)
0020 include(CMakePackageConfigHelpers)
0021 include(FeatureSummary)
0022 include(WriteBasicConfigVersionFile)
0023 include(GenerateExportHeader)
0024 include(CheckCXXCompilerFlag)
0025 include(CheckIncludeFile)
0026 include(CheckIncludeFiles)
0027 include(CheckSymbolExists)
0028 
0029 include(KDEInstallDirs)
0030 include(KDECMakeSettings)
0031 include(KDECompilerSettings NO_POLICY_SCOPE)
0032 include(KDEClangFormat)
0033 include(KDEGitCommitHooks)
0034 
0035 include(ECMFindQmlModule)
0036 include(ECMInstallIcons)
0037 include(ECMOptionalAddSubdirectory)
0038 include(ECMConfiguredInstall)
0039 include(ECMQtDeclareLoggingCategory)
0040 
0041 find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
0042     Concurrent
0043     Core
0044     DBus
0045     Network
0046     Quick
0047     UiTools
0048     Widgets
0049 )
0050 if (QT_MAJOR_VERSION EQUAL "5")
0051     find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS X11Extras)
0052     find_package(Qt5XkbCommonSupport REQUIRED)
0053 else()
0054     find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS WaylandClient ShaderTools)
0055     if (Qt6WaylandClient_VERSION VERSION_LESS "6.4.1") # TODO Plasma 6: Drop once minimum Qt version is 6.4.1+
0056         include(Qt6WaylandClientMacrosKde)
0057     endif()
0058 endif()
0059 
0060 find_package(Qt${QT_MAJOR_VERSION}Test ${QT_MIN_VERSION} CONFIG QUIET)
0061 set_package_properties(Qt${QT_MAJOR_VERSION}Test PROPERTIES
0062     PURPOSE "Required for tests"
0063     TYPE OPTIONAL
0064 )
0065 add_feature_info("Qt${QT_MAJOR_VERSION}Test" Qt${QT_MAJOR_VERSION}Test_FOUND "Required for building tests")
0066 if (NOT Qt${QT_MAJOR_VERSION}Test_FOUND)
0067     set(BUILD_TESTING OFF CACHE BOOL "Build the testing tree.")
0068 endif()
0069 
0070 # required frameworks by Core
0071 find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
0072     Auth
0073     Config
0074     ConfigWidgets
0075     CoreAddons
0076     Crash
0077     DBusAddons
0078     GlobalAccel
0079     I18n
0080     IdleTime
0081     Package
0082     Plasma
0083     WidgetsAddons
0084     WindowSystem
0085 )
0086 # required frameworks by config modules
0087 find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
0088     Declarative
0089     KCMUtils
0090     NewStuff
0091     Service
0092     XmlGui
0093 )
0094 
0095 find_package(Threads)
0096 set_package_properties(Threads PROPERTIES
0097     PURPOSE "Needed for VirtualTerminal support in KWin Wayland"
0098     TYPE REQUIRED
0099 )
0100 
0101 find_package(KF5Wayland ${KF5_MIN_VERSION} CONFIG)
0102 set_package_properties(KF5Wayland PROPERTIES
0103     PURPOSE "Required to build wayland platform plugin and tests"
0104     TYPE REQUIRED
0105 )
0106 
0107 # optional frameworks
0108 find_package(KF5Activities ${KF5_MIN_VERSION} CONFIG)
0109 set_package_properties(KF5Activities PROPERTIES
0110     PURPOSE "Enable building of KWin with kactivities support"
0111     TYPE OPTIONAL
0112 )
0113 add_feature_info("KF5Activities" KF5Activities_FOUND "Enable building of KWin with kactivities support")
0114 
0115 find_package(KF5DocTools ${KF5_MIN_VERSION} CONFIG)
0116 set_package_properties(KF5DocTools PROPERTIES
0117     PURPOSE "Enable building documentation"
0118     TYPE OPTIONAL
0119 )
0120 add_feature_info("KF5DocTools" KF5DocTools_FOUND "Enable building documentation")
0121 
0122 find_package(KF5Runner ${KF5_MIN_VERSION} CONFIG)
0123 set_package_properties(KF5Runner PROPERTIES
0124     PURPOSE "Enable building of KWin with krunner support"
0125     TYPE OPTIONAL
0126     )
0127 add_feature_info("KF5Runner" KF5Runner_FOUND "Enable building of KWin with krunner support")
0128 
0129 find_package(KF5Kirigami2 ${KF5_MIN_VERSION} CONFIG)
0130 set_package_properties(KF5Kirigami2 PROPERTIES
0131     DESCRIPTION "A QtQuick based components set"
0132     PURPOSE "Required at runtime for Virtual desktop KCM"
0133     TYPE RUNTIME
0134 )
0135 
0136 find_package(KDecoration2 ${PROJECT_VERSION} CONFIG)
0137 set_package_properties(KDecoration2 PROPERTIES
0138     TYPE REQUIRED
0139     PURPOSE "Required for server side decoration support"
0140 )
0141 
0142 find_package(Breeze 5.9.0 CONFIG)
0143 set_package_properties(Breeze PROPERTIES
0144     TYPE OPTIONAL
0145     PURPOSE "For setting the default window decoration plugin"
0146 )
0147 if (${Breeze_FOUND})
0148     if (${BREEZE_WITH_KDECORATION})
0149         set(HAVE_BREEZE_DECO true)
0150     else()
0151         set(HAVE_BREEZE_DECO FALSE)
0152     endif()
0153 else()
0154     set(HAVE_BREEZE_DECO FALSE)
0155 endif()
0156 add_feature_info("Breeze-Decoration" HAVE_BREEZE_DECO "Default decoration plugin Breeze")
0157 
0158 find_package(EGL)
0159 set_package_properties(EGL PROPERTIES
0160     TYPE REQUIRED
0161     PURPOSE "Required to build KWin with EGL support"
0162 )
0163 
0164 find_package(epoxy 1.3)
0165 set_package_properties(epoxy PROPERTIES
0166     DESCRIPTION "libepoxy"
0167     URL "https://github.com/anholt/libepoxy"
0168     TYPE REQUIRED
0169     PURPOSE "OpenGL dispatch library"
0170 )
0171 
0172 set(HAVE_DL_LIBRARY FALSE)
0173 if (epoxy_HAS_GLX)
0174     find_library(DL_LIBRARY dl)
0175     if (DL_LIBRARY)
0176         set(HAVE_DL_LIBRARY TRUE)
0177     endif()
0178 endif()
0179 
0180 check_cxx_source_compiles("
0181 #include <fcntl.h>
0182 #include <sys/mman.h>
0183 #include <unistd.h>
0184 
0185 int main() {
0186     const int size = 10;
0187     int fd = memfd_create(\"test\", MFD_CLOEXEC | MFD_ALLOW_SEALING);
0188     ftruncate(fd, size);
0189     fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE | F_SEAL_SEAL);
0190     mmap(nullptr, size, PROT_WRITE, MAP_SHARED, fd, 0);
0191 }" HAVE_MEMFD)
0192 
0193 find_package(Wayland 1.21)
0194 set_package_properties(Wayland PROPERTIES
0195     TYPE REQUIRED
0196     PURPOSE "Required for building KWin with Wayland support"
0197 )
0198 
0199 find_package(WaylandProtocols 1.31)
0200 set_package_properties(WaylandProtocols PROPERTIES
0201     TYPE REQUIRED
0202     PURPOSE "Collection of Wayland protocols that add functionality not available in the Wayland core protocol"
0203     URL "https://gitlab.freedesktop.org/wayland/wayland-protocols/"
0204 )
0205 
0206 find_package(PlasmaWaylandProtocols 1.9.0 CONFIG)
0207 set_package_properties(PlasmaWaylandProtocols PROPERTIES
0208     TYPE REQUIRED
0209     PURPOSE "Collection of Plasma-specific Wayland protocols"
0210     URL "https://invent.kde.org/libraries/plasma-wayland-protocols/"
0211 )
0212 
0213 if (QT_MAJOR_VERSION EQUAL "5")
0214     find_package(QtWaylandScanner)
0215     set_package_properties(QtWaylandScanner PROPERTIES
0216         TYPE REQUIRED
0217         PURPOSE "Required for building KWin with Wayland support"
0218     )
0219 endif()
0220 
0221 find_package(XKB 0.7.0)
0222 set_package_properties(XKB PROPERTIES
0223     TYPE REQUIRED
0224     PURPOSE "Required for building KWin with Wayland support"
0225 )
0226 if (XKB_VERSION VERSION_GREATER_EQUAL 1.5.0)
0227     set(HAVE_XKBCOMMON_NO_SECURE_GETENV 1)
0228 else()
0229     set(HAVE_XKBCOMMON_NO_SECURE_GETENV 0)
0230 endif()
0231 
0232 pkg_check_modules(XKBX11 IMPORTED_TARGET xkbcommon-x11 REQUIRED)
0233 add_feature_info(XKBX11 XKBX11_FOUND "Required for handling keyboard events in X11 backend")
0234 
0235 find_package(Libinput 1.19)
0236 set_package_properties(Libinput PROPERTIES TYPE REQUIRED PURPOSE "Required for input handling on Wayland.")
0237 
0238 find_package(UDev)
0239 set_package_properties(UDev PROPERTIES
0240     URL "https://www.freedesktop.org/wiki/Software/systemd/"
0241     DESCRIPTION "Linux device library."
0242     TYPE REQUIRED
0243     PURPOSE "Required for input handling on Wayland."
0244 )
0245 
0246 find_package(Libdrm 2.4.112)
0247 set_package_properties(Libdrm PROPERTIES TYPE REQUIRED PURPOSE "Required for drm output on Wayland.")
0248 
0249 find_package(gbm)
0250 set_package_properties(gbm PROPERTIES TYPE REQUIRED PURPOSE "Required for egl output of drm backend.")
0251 if (gbm_VERSION VERSION_GREATER_EQUAL 21.1)
0252     set(HAVE_GBM_BO_GET_FD_FOR_PLANE 1)
0253 else()
0254     set(HAVE_GBM_BO_GET_FD_FOR_PLANE 0)
0255 endif()
0256 if (gbm_VERSION VERSION_GREATER_EQUAL 21.3)
0257     set(HAVE_GBM_BO_CREATE_WITH_MODIFIERS2 1)
0258 else()
0259     set(HAVE_GBM_BO_CREATE_WITH_MODIFIERS2 0)
0260 endif()
0261 
0262 pkg_check_modules(Libxcvt IMPORTED_TARGET libxcvt>=0.1.1 REQUIRED)
0263 add_feature_info(Libxcvt Libxcvt_FOUND "Required for generating modes in the drm backend")
0264 
0265 find_package(X11)
0266 set_package_properties(X11 PROPERTIES
0267     DESCRIPTION "X11 libraries"
0268     URL "https://www.x.org"
0269     TYPE REQUIRED
0270 )
0271 add_feature_info("XInput" X11_Xi_FOUND "Required for poll-free mouse cursor updates")
0272 set(HAVE_X11_XINPUT ${X11_Xinput_FOUND})
0273 
0274 find_package(lcms2)
0275 set_package_properties(lcms2 PROPERTIES
0276     DESCRIPTION "Small-footprint color management engine"
0277     URL "http://www.littlecms.com"
0278     TYPE REQUIRED
0279     PURPOSE "Required for the color management system"
0280 )
0281 
0282 # All the required XCB components
0283 find_package(XCB 1.10 REQUIRED COMPONENTS
0284     COMPOSITE
0285     CURSOR
0286     DAMAGE
0287     GLX
0288     ICCCM
0289     IMAGE
0290     KEYSYMS
0291     PRESENT
0292     RANDR
0293     RENDER
0294     SHAPE
0295     SHM
0296     SYNC
0297     XCB
0298     XFIXES
0299     XKB
0300     XINERAMA
0301 )
0302 set_package_properties(XCB PROPERTIES TYPE REQUIRED)
0303 
0304 # and the optional XCB dependencies
0305 if (XCB_ICCCM_VERSION VERSION_LESS "0.4")
0306     set(XCB_ICCCM_FOUND FALSE)
0307 endif()
0308 add_feature_info("XCB-ICCCM" XCB_ICCCM_FOUND "Required for building test applications for KWin")
0309 
0310 find_package(X11_XCB)
0311 set_package_properties(X11_XCB PROPERTIES
0312     PURPOSE "Required for building X11 windowed backend of kwin_wayland"
0313     TYPE OPTIONAL
0314 )
0315 
0316 # dependencies for QPA plugin
0317 if (QT_MAJOR_VERSION EQUAL "5")
0318     find_package(Qt5FontDatabaseSupport REQUIRED)
0319     find_package(Qt5ThemeSupport REQUIRED)
0320     find_package(Qt5ServiceSupport REQUIRED)
0321     find_package(Qt5EventDispatcherSupport REQUIRED)
0322 endif()
0323 
0324 find_package(Freetype)
0325 set_package_properties(Freetype PROPERTIES
0326     DESCRIPTION "A font rendering engine"
0327     URL "https://www.freetype.org"
0328     TYPE REQUIRED
0329     PURPOSE "Needed for KWin's QPA plugin."
0330 )
0331 find_package(Fontconfig)
0332 set_package_properties(Fontconfig PROPERTIES
0333     TYPE REQUIRED
0334     PURPOSE "Needed for KWin's QPA plugin."
0335 )
0336 
0337 find_package(Xwayland)
0338 set_package_properties(Xwayland PROPERTIES
0339     URL "https://x.org"
0340     DESCRIPTION "Xwayland X server"
0341     TYPE RUNTIME
0342     PURPOSE "Needed for running kwin_wayland"
0343 )
0344 set(HAVE_XWAYLAND_LISTENFD ${Xwayland_HAVE_LISTENFD})
0345 
0346 find_package(Libcap)
0347 set_package_properties(Libcap PROPERTIES
0348     TYPE OPTIONAL
0349     PURPOSE "Needed for running kwin_wayland with real-time scheduling policy"
0350 )
0351 set(HAVE_LIBCAP ${Libcap_FOUND})
0352 
0353 find_package(hwdata)
0354 set_package_properties(hwdata PROPERTIES
0355     TYPE RUNTIME
0356     PURPOSE "Runtime-only dependency needed for mapping monitor hardware vendor IDs to full names"
0357     URL "https://github.com/vcrhonek/hwdata"
0358 )
0359 
0360 find_package(QAccessibilityClient CONFIG)
0361 set_package_properties(QAccessibilityClient PROPERTIES
0362     URL "https://www.kde.org"
0363     DESCRIPTION "KDE client-side accessibility library"
0364     TYPE OPTIONAL
0365     PURPOSE "Required to enable accessibility features"
0366 )
0367 set(HAVE_ACCESSIBILITY ${QAccessibilityClient_FOUND})
0368 
0369 find_package(Qt5LinuxAccessibilitySupport REQUIRED)
0370 
0371 ecm_find_qmlmodule(QtQuick 2.3)
0372 ecm_find_qmlmodule(QtQuick.Controls 2.15)
0373 ecm_find_qmlmodule(QtQuick.Layouts 1.3)
0374 ecm_find_qmlmodule(QtQuick.Window 2.1)
0375 ecm_find_qmlmodule(QtMultimedia 5.0)
0376 ecm_find_qmlmodule(org.kde.kquickcontrolsaddons 2.0)
0377 ecm_find_qmlmodule(org.kde.plasma.core 2.0)
0378 ecm_find_qmlmodule(org.kde.plasma.components 2.0)
0379 
0380 ########### configure tests ###############
0381 option(KWIN_BUILD_DECORATIONS "Enable building of KWin decorations." ON)
0382 option(KWIN_BUILD_KCMS "Enable building of KWin configuration modules." ON)
0383 option(KWIN_BUILD_NOTIFICATIONS "Enable building of KWin with knotifications support" ON)
0384 option(KWIN_BUILD_SCREENLOCKER "Enable building of KWin lockscreen functionality" ON)
0385 option(KWIN_BUILD_TABBOX "Enable building of KWin Tabbox functionality" ON)
0386 cmake_dependent_option(KWIN_BUILD_ACTIVITIES "Enable building of KWin with kactivities support" ON "KF5Activities_FOUND" OFF)
0387 cmake_dependent_option(KWIN_BUILD_RUNNERS "Enable building of KWin with krunner support" ON "KF5Runner_FOUND" OFF)
0388 
0389 set(HAVE_EPOXY_GLX ${epoxy_HAS_GLX})
0390 
0391 # for kwin internal things
0392 set(HAVE_X11_XCB ${X11_XCB_FOUND})
0393 
0394 check_symbol_exists(SCHED_RESET_ON_FORK "sched.h" HAVE_SCHED_RESET_ON_FORK)
0395 add_feature_info("SCHED_RESET_ON_FORK"
0396                  HAVE_SCHED_RESET_ON_FORK
0397                  "Required for running kwin_wayland with real-time scheduling")
0398 
0399 
0400 pkg_check_modules(PipeWire IMPORTED_TARGET libpipewire-0.3>=0.3.29)
0401 add_feature_info(PipeWire PipeWire_FOUND "Required for Wayland screencasting")
0402 
0403 if (KWIN_BUILD_NOTIFICATIONS)
0404     find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Notifications)
0405 endif()
0406 
0407 if (KWIN_BUILD_SCREENLOCKER)
0408     find_package(KScreenLocker CONFIG)
0409     set_package_properties(KScreenLocker PROPERTIES
0410         TYPE REQUIRED
0411         PURPOSE "For screenlocker integration in kwin_wayland"
0412     )
0413 endif()
0414 
0415 ########### global ###############
0416 
0417 include_directories(BEFORE
0418     ${CMAKE_CURRENT_BINARY_DIR}/src/libkwineffects
0419     ${CMAKE_CURRENT_BINARY_DIR}/src/wayland
0420     ${CMAKE_CURRENT_BINARY_DIR}/src
0421     ${CMAKE_CURRENT_SOURCE_DIR}/src/libkwineffects
0422     ${CMAKE_CURRENT_SOURCE_DIR}/src/effects
0423     ${CMAKE_CURRENT_SOURCE_DIR}/src/tabbox
0424     ${CMAKE_CURRENT_SOURCE_DIR}/src/platformsupport
0425     ${CMAKE_CURRENT_SOURCE_DIR}/src/colors
0426 )
0427 
0428 check_cxx_compiler_flag(-Wno-unused-parameter COMPILER_UNUSED_PARAMETER_SUPPORTED)
0429 if (COMPILER_UNUSED_PARAMETER_SUPPORTED)
0430     add_compile_options(-Wno-unused-parameter)
0431 endif()
0432 
0433 add_definitions(
0434     -DQT_DISABLE_DEPRECATED_BEFORE=0
0435     -DQT_NO_KEYWORDS
0436     -DQT_USE_QSTRINGBUILDER
0437     -DQT_NO_URL_CAST_FROM_STRING
0438     -DQT_NO_CAST_TO_ASCII
0439     -DQT_NO_FOREACH
0440 
0441     # Prevent EGL headers from including platform headers, in particular Xlib.h.
0442     -DMESA_EGL_NO_X11_HEADERS
0443     -DEGL_NO_X11
0444     -DEGL_NO_PLATFORM_SPECIFIC_TYPES
0445 )
0446 
0447 if (KF5DocTools_FOUND)
0448     add_subdirectory(doc)
0449     kdoctools_install(po)
0450 endif()
0451 
0452 add_subdirectory(data)
0453 add_subdirectory(kconf_update)
0454 add_subdirectory(src)
0455 
0456 if (BUILD_TESTING)
0457     find_package(Wayland REQUIRED COMPONENTS Client)
0458 
0459     add_subdirectory(autotests)
0460     add_subdirectory(tests)
0461 endif()
0462 
0463 # add clang-format target for all our real source files
0464 file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
0465 kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
0466 kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
0467 
0468 feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
0469 
0470 set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KWinDBusInterface")
0471 configure_package_config_file(KWinDBusInterfaceConfig.cmake.in
0472     "${CMAKE_CURRENT_BINARY_DIR}/KWinDBusInterfaceConfig.cmake"
0473     PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR
0474     INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR})
0475 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/KWinDBusInterfaceConfig.cmake
0476     DESTINATION ${CMAKECONFIG_INSTALL_DIR})
0477 
0478 ecm_install_configured_files(INPUT plasma-kwin_x11.service.in plasma-kwin_wayland.service.in @ONLY
0479             DESTINATION ${KDE_INSTALL_SYSTEMDUSERUNITDIR})
0480 
0481 ki18n_install(po)