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

0001 cmake_minimum_required(VERSION 3.16)
0002 
0003 project(kscreenlocker)
0004 set(CMAKE_C_STANDARD 99)
0005 set(PROJECT_VERSION "5.25.80")
0006 set(PROJECT_VERSION_MAJOR 5)
0007 
0008 set(QT_MIN_VERSION "5.15.2")
0009 set(KF5_MIN_VERSION "5.97")
0010 set(KDE_COMPILERSETTINGS_LEVEL "5.82")
0011 
0012 set(CMAKE_CXX_STANDARD 17)
0013 set(CMAKE_CXX_STANDARD_REQUIRED ON)
0014 
0015 find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
0016 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${ECM_MODULE_PATH} )
0017 
0018 include(KDEInstallDirs)
0019 include(KDECMakeSettings)
0020 include(KDECompilerSettings NO_POLICY_SCOPE)
0021 include(ECMSetupVersion)
0022 include(ECMGenerateHeaders)
0023 include(CheckIncludeFiles)
0024 include(ECMMarkNonGuiExecutable)
0025 include(CMakePackageConfigHelpers)
0026 include(FeatureSummary)
0027 include(GenerateExportHeader)
0028 include(KDEClangFormat)
0029 include(KDEGitCommitHooks)
0030 
0031 include(CheckIncludeFile)
0032 include(CheckSymbolExists)
0033 check_include_file("sys/prctl.h" HAVE_SYS_PRCTL_H)
0034 check_symbol_exists(PR_SET_DUMPABLE "sys/prctl.h" HAVE_PR_SET_DUMPABLE)
0035 check_include_file("sys/procctl.h" HAVE_SYS_PROCCTL_H)
0036 check_symbol_exists(PROC_TRACE_CTL "sys/procctl.h" HAVE_PROC_TRACE_CTL)
0037 if (HAVE_PR_SET_DUMPABLE OR HAVE_PROC_TRACE_CTL)
0038   set(CAN_DISABLE_PTRACE TRUE)
0039 endif ()
0040 add_feature_info("prctl/procctl tracing control"
0041                  CAN_DISABLE_PTRACE
0042                  "Required for disallowing ptrace on greeter and kcheckpass process")
0043 
0044 find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS DBus Widgets Quick Test)
0045 find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
0046                     Crash
0047                     Declarative
0048                     KCMUtils
0049                     KIO
0050                     GlobalAccel
0051                     I18n
0052                     IdleTime
0053                     Notifications
0054                     Solid
0055                     WindowSystem
0056                     XmlGui
0057                     )
0058 
0059 find_package(X11)
0060 set_package_properties(X11 PROPERTIES DESCRIPTION "X11 libraries"
0061                         URL "https://www.x.org"
0062                         TYPE REQUIRED
0063                         PURPOSE "Required for building the X11 based workspace")
0064 
0065 find_package(XCB MODULE REQUIRED COMPONENTS XCB KEYSYMS XTEST)
0066 set_package_properties(XCB PROPERTIES TYPE REQUIRED)
0067 add_feature_info("XInput" X11_Xinput_FOUND "Required for grabbing XInput2 devices in the screen locker")
0068 
0069 if (QT_MAJOR_VERSION EQUAL "5")
0070     find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS X11Extras)
0071 endif()
0072 
0073 find_package(KF5Wayland CONFIG REQUIRED)
0074 set_package_properties(KF5Wayland PROPERTIES
0075                        TYPE REQUIRED
0076                        PURPOSE "Required for building screenlocker")
0077 find_package(WaylandScanner)
0078 find_package(Wayland 1.3 COMPONENTS Client Server)
0079 find_package(LayerShellQt REQUIRED)
0080 
0081 set_package_properties(Wayland PROPERTIES
0082                        TYPE REQUIRED
0083                        PURPOSE "Required for building screenlocker")
0084 
0085 find_package(loginctl)
0086 set_package_properties(loginctl PROPERTIES
0087     URL "https://www.freedesktop.org/software/systemd/man/loginctl.html"
0088     DESCRIPTION "Send control commands to the login manager"
0089     TYPE RUNTIME
0090     )
0091 set(HAVE_LOGINCTL ${loginctl_FOUND})
0092 
0093 if ( NOT HAVE_LOGINCTL )
0094     find_package(ConsoleKit)
0095     set_package_properties(ConsoleKit PROPERTIES
0096         URL "https://github.com/ConsoleKit2/ConsoleKit2"
0097         DESCRIPTION "Framework for tracking user login sessions"
0098         TYPE RECOMMENDED
0099         )
0100     set(HAVE_CONSOLEKIT ${ConsoleKit_FOUND})
0101 endif ()
0102 
0103 if (HAVE_LOGINCTL OR HAVE_CONSOLEKIT)
0104     set(HAVE_UNLOCK_CAPABILITY TRUE)
0105 endif ()
0106 
0107 add_feature_info("Unlock broken screenlocker"
0108                  HAVE_UNLOCK_CAPABILITY
0109                  "Needed for emergency unlock in case that the greeter is broken. In case your distribution does not provide loginctl or consolekit please contact plasma-devel@kde.org to discuss alternatives.")
0110 
0111 option(PAM_REQUIRED "Require building with PAM" ON)
0112 
0113 include(ConfigureChecks.cmake)
0114 
0115 configure_file(config-unix.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-unix.h )
0116 
0117 if (HAVE_CONSOLEKIT)
0118     configure_file(ck-unlock-session.cmake ${CMAKE_CURRENT_BINARY_DIR}/ck-unlock-session)
0119 endif ()
0120 
0121 # adjusting CMAKE_C_FLAGS to get wayland protocols to compile
0122 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu90")
0123 
0124 ecm_setup_version(${PROJECT_VERSION} VARIABLE_PREFIX KSCREENLOCKER
0125                         VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kscreenlocker_version.h"
0126                         PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KScreenLockerConfigVersion.cmake"
0127                         SOVERSION 5)
0128 
0129 configure_file(config-kscreenlocker.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kscreenlocker.h)
0130 include_directories(${CMAKE_CURRENT_BINARY_DIR})
0131 
0132 set(KSLD_INCLUDEDIR "${KDE_INSTALL_INCLUDEDIR}/KScreenLocker")
0133 
0134 include(ECMQtDeclareLoggingCategory)
0135 
0136 add_subdirectory(greeter)
0137 add_subdirectory(kcm)
0138 add_subdirectory(settings)
0139 
0140 add_definitions(-DTRANSLATION_DOMAIN=\"kscreenlocker\")
0141 
0142 set(screensaver_dbusXML dbus/org.freedesktop.ScreenSaver.xml)
0143 set(kscreensaver_dbusXML dbus/org.kde.screensaver.xml)
0144 set(powerdevilpolicyagent_xml dbus/kf5_org.kde.Solid.PowerManagement.PolicyAgent.xml)
0145 
0146 set(ksld_SRCS
0147    abstractlocker.cpp
0148    ksldapp.cpp
0149    interface.cpp
0150    globalaccel.cpp
0151    x11locker.cpp
0152    waylandlocker.cpp
0153    logind.cpp
0154    waylandserver.cpp
0155    powermanagement_inhibition.cpp
0156    abstractlocker.h
0157    ksldapp.h
0158    interface.h
0159    globalaccel.h
0160    x11locker.h
0161    waylandlocker.h
0162    logind.h
0163    waylandserver.h
0164    powermanagement_inhibition.h
0165 )
0166 
0167 ecm_qt_declare_logging_category(ksld_SRCS
0168     HEADER
0169         kscreenlocker_logging.h
0170     IDENTIFIER
0171         KSCREENLOCKER
0172     CATEGORY_NAME
0173         kscreenlocker
0174     DEFAULT_SEVERITY
0175         Critical
0176 )
0177 
0178 qt_add_dbus_adaptor(ksld_SRCS ${screensaver_dbusXML} interface.h ScreenLocker::Interface)
0179 qt_add_dbus_adaptor(ksld_SRCS ${kscreensaver_dbusXML} interface.h ScreenLocker::Interface kscreensaveradaptor KScreenSaverAdaptor)
0180 qt_add_dbus_interface(ksld_SRCS ${powerdevilpolicyagent_xml} powerdevilpolicyagent)
0181 
0182 ecm_add_wayland_server_protocol(ksld_SRCS
0183     PROTOCOL protocols/ksld.xml
0184     BASENAME ksld
0185 )
0186 
0187 add_library(KScreenLocker SHARED ${ksld_SRCS})
0188 
0189 target_link_libraries(KScreenLocker
0190 PUBLIC
0191    Qt::Core
0192 PRIVATE
0193    settings
0194    Qt::DBus
0195    KF5::I18n
0196    KF5::IdleTime
0197    KF5::GlobalAccel
0198    KF5::Notifications
0199    KF5::CoreAddons
0200    KF5::ConfigGui
0201    KF5::Package
0202    KF5::WindowSystem
0203    KF5::XmlGui
0204    X11::X11
0205    XCB::XCB
0206    XCB::KEYSYMS
0207    Wayland::Server
0208 )
0209 if (QT_MAJOR_VERSION EQUAL "5")
0210     target_link_libraries(KScreenLocker PUBLIC Qt5::X11Extras)
0211 else()
0212     target_link_libraries(KScreenLocker PRIVATE Qt::GuiPrivate)
0213 endif()
0214 
0215 set(kscreenlocker_greet_bin_abs ${CMAKE_INSTALL_FULL_LIBEXECDIR}/kscreenlocker_greet)
0216 # The file path of kscreenlocker_greet must be relative to the KScreenLocker library.
0217 file(RELATIVE_PATH kscreenlocker_greet_bin_rel ${CMAKE_INSTALL_FULL_LIBDIR} ${kscreenlocker_greet_bin_abs})
0218 target_compile_definitions(KScreenLocker PRIVATE
0219     KSCREENLOCKER_GREET_BIN_ABS="${kscreenlocker_greet_bin_abs}"
0220     KSCREENLOCKER_GREET_BIN_REL="${kscreenlocker_greet_bin_rel}"
0221 )
0222 
0223 if (X11_Xinput_FOUND)
0224     target_link_libraries(KScreenLocker PRIVATE X11::Xi)
0225 endif()
0226 
0227 target_include_directories(KScreenLocker INTERFACE "$<INSTALL_INTERFACE:${KSLD_INCLUDEDIR}>")
0228 
0229 # Needed to compile on Arm target.
0230 set_target_properties(KScreenLocker PROPERTIES COMPILE_FLAGS "-fPIC")
0231 
0232 add_library(PW::KScreenLocker ALIAS KScreenLocker)
0233 
0234 # add clang-format target for all our real source files
0235 file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h *.c)
0236 kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
0237 kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
0238 
0239 generate_export_header(KScreenLocker
0240     BASE_NAME KScreenLocker
0241     EXPORT_MACRO_NAME KSCREENLOCKER_EXPORT
0242     EXPORT_FILE_NAME KScreenLocker/kscreenlocker_export.h
0243 )
0244 
0245 configure_package_config_file(ScreenSaverDBusInterfaceConfig.cmake.in
0246     ${CMAKE_CURRENT_BINARY_DIR}/ScreenSaverDBusInterfaceConfig.cmake
0247     PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR
0248     INSTALL_DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/ScreenSaverDBusInterface")
0249 
0250 set_target_properties(KScreenLocker PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
0251 
0252 install(FILES
0253         ${CMAKE_CURRENT_BINARY_DIR}/ScreenSaverDBusInterfaceConfig.cmake
0254         DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/ScreenSaverDBusInterface")
0255 
0256 configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/KScreenLockerConfig.cmake.in"
0257     "${CMAKE_CURRENT_BINARY_DIR}/KScreenLockerConfig.cmake"
0258     PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR
0259     INSTALL_DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/KScreenLocker")
0260 
0261 if (HAVE_CONSOLEKIT)
0262   install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/ck-unlock-session DESTINATION ${KDE_INSTALL_BINDIR})
0263 endif ()
0264 
0265 install(TARGETS KScreenLocker EXPORT KScreenLockerTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY)
0266 install(EXPORT KScreenLockerTargets DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/KScreenLocker" FILE KScreenLockerTargets.cmake NAMESPACE PW::)
0267 
0268 ecm_generate_headers(KScreenLocker_CamelCase_HEADERS
0269     HEADER_NAMES
0270         KsldApp
0271     REQUIRED_HEADERS KScreenLocker_HEADERS)
0272 
0273 install(
0274     FILES
0275         ${CMAKE_CURRENT_BINARY_DIR}/KScreenLocker/kscreenlocker_export.h
0276         ${KScreenLocker_CamelCase_HEADERS}
0277         ${KScreenLocker_HEADERS}
0278     DESTINATION
0279         ${KSLD_INCLUDEDIR}/KScreenLocker
0280     COMPONENT Devel)
0281 
0282 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KScreenLockerConfig.cmake"
0283                           "${CMAKE_CURRENT_BINARY_DIR}/KScreenLockerConfigVersion.cmake"
0284                 DESTINATION "${KDE_INSTALL_CMAKEPACKAGEDIR}/KScreenLocker"
0285                 COMPONENT Devel)
0286 
0287 install(FILES kscreenlocker.notifyrc  DESTINATION ${KDE_INSTALL_KNOTIFYRCDIR} RENAME ksmserver.notifyrc)
0288 install(FILES ${screensaver_dbusXML}
0289         DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR}
0290         RENAME kf5_org.freedesktop.ScreenSaver.xml)
0291 
0292 install(FILES ${kscreensaver_dbusXML}
0293         DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR})
0294 
0295 
0296 install(FILES   updaters/kscreenlocker.upd DESTINATION ${KDE_INSTALL_DATADIR}/kconf_update)
0297 install(PROGRAMS updaters/ksreenlocker_5_3_separate_autologin.pl
0298                 DESTINATION ${KDE_INSTALL_DATADIR}/kconf_update)
0299 
0300 if(BUILD_TESTING)
0301    add_subdirectory(autotests)
0302    add_subdirectory(tests)
0303 endif()
0304 feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)