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