Commit d69d6325 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Introduce option to build without X11 libs

Currently we are very inconsistent with how we handle our various X11 dependencies.

Some places check whether specific sub-libraries are found and disable parts of the code accordingly.

Sometimes this is controlled by whether X11 is found at all, sometimes it depends on the sublibrary being present.

Some of this is obviously broken, e.g. in one like we check whether X11 is there and then use it unconditionally a few lines down.

Instead of the current system of optional deps and deps being conditional on other deps I propose that we introduce an explicit build option that controls the X11 support.

If on (the default) then all X11 libs are required.

If off then no X11 libs are searched for. Currently this results in a broken build since some places use X11 stuff unconditionally, but it gives us an easier way to test and fix those cases.
parent cf0be2fb
Pipeline #209209 passed with stage
in 12 minutes and 5 seconds
......@@ -9,6 +9,7 @@ set(KF5_MIN_VERSION "5.94")
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
set(INSTALL_SDDM_THEME TRUE)
option(INSTALL_SDDM_WAYLAND_SESSION OFF)
option(WITH_X11 "Build with X11 support. Building without is experimental" ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
......@@ -115,26 +116,43 @@ set_package_properties(Fontconfig PROPERTIES DESCRIPTION "Font access configurat
PURPOSE "Needed to build font configuration and installation tools"
)
find_package(X11)
set_package_properties(X11 PROPERTIES DESCRIPTION "X11 libraries"
URL "https://www.x.org"
TYPE OPTIONAL
PURPOSE "Required for building the X11 based workspace")
function(check_X11_lib _lib)
if (NOT TARGET X11::${_lib})
message(SEND_ERROR "Required component ${_lib} of X11 was not found")
if(WITH_X11)
find_package(X11)
set_package_properties(X11 PROPERTIES DESCRIPTION "X11 libraries"
URL "https://www.x.org"
TYPE REQUIRED
PURPOSE "Required for building the X11 based workspace")
function(check_X11_lib _lib)
if (NOT TARGET X11::${_lib})
message(SEND_ERROR "Required component ${_lib} of X11 was not found")
endif()
endfunction()
check_X11_lib(ICE)
check_X11_lib(SM)
check_X11_lib(X11)
check_X11_lib(Xau)
check_X11_lib(Xcursor)
check_X11_lib(Xfixes)
check_X11_lib(Xft)
check_X11_lib(Xrender)
check_X11_lib(Xtst)
set(HAVE_X11 1)
set(HAVE_XCURSOR 1)
set(HAVE_XFIXES 1)
find_package(XCB MODULE REQUIRED COMPONENTS XCB RANDR IMAGE)
set_package_properties(XCB PROPERTIES TYPE REQUIRED)
if (QT_MAJOR_VERSION EQUAL "5")
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS X11Extras)
endif()
endfunction()
check_X11_lib(ICE)
check_X11_lib(SM)
check_X11_lib(X11)
check_X11_lib(Xau)
check_X11_lib(Xcursor)
check_X11_lib(Xfixes)
check_X11_lib(Xft)
check_X11_lib(Xrender)
check_X11_lib(Xtst)
else()
set(HAVE_X11 0)
set(HAVE_XCURSOR 0)
set(HAVE_XFIXES 0)
endif()
find_package(PkgConfig REQUIRED)
pkg_check_modules(PipeWire IMPORTED_TARGET libpipewire-0.3)
......@@ -159,22 +177,6 @@ if(FONTCONFIG_FOUND)
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS PrintSupport)
endif()
if(X11_FOUND)
find_package(XCB MODULE REQUIRED COMPONENTS XCB RANDR IMAGE)
set_package_properties(XCB PROPERTIES TYPE REQUIRED)
if(NOT X11_SM_FOUND)
message(FATAL_ERROR "\nThe X11 Session Management (SM) development package could not be found.\nPlease install libSM.\n")
endif(NOT X11_SM_FOUND)
if (QT_MAJOR_VERSION EQUAL "5")
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS X11Extras)
endif()
endif()
if(X11_FOUND AND XCB_XCB_FOUND)
set(HAVE_X11 1)
endif()
find_package(AppStreamQt 0.10.6)
set_package_properties(AppStreamQt PROPERTIES DESCRIPTION "Access metadata for listing available software"
URL "https://www.freedesktop.org/wiki/Distributions/AppStream/"
......
......@@ -5,5 +5,3 @@ check_include_files(sys/time.h HAVE_SYS_TIME_H) # ksmserver, ksplashml, sftp
check_include_files(unistd.h HAVE_UNISTD_H)
set(HAVE_FONTCONFIG ${FONTCONFIG_FOUND}) # kcms/{fonts,kfontinst}
set(HAVE_XCURSOR ${X11_Xcursor_FOUND}) # many uses
set(HAVE_XFIXES ${X11_Xfixes_FOUND}) # klipper, kicker
......@@ -5,7 +5,7 @@ set(mouse_engine_SRCS
mouseengine.h
)
if (X11_Xfixes_FOUND)
if (HAVE_X11)
set(mouse_engine_SRCS ${mouse_engine_SRCS} cursornotificationhandler.cpp)
endif ()
......@@ -14,14 +14,14 @@ target_link_libraries(plasma_engine_mouse
Qt::Widgets
KF5::Plasma
KF5::WindowSystem
X11::X11
)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(plasma_engine_mouse Qt::X11Extras)
else()
target_link_libraries(plasma_engine_mouse Qt::GuiPrivate)
endif()
if (X11_Xfixes_FOUND)
target_link_libraries(plasma_engine_mouse X11::Xfixes)
if (HAVE_X11)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(plasma_engine_mouse Qt::X11Extras)
else()
target_link_libraries(plasma_engine_mouse Qt::GuiPrivate)
endif()
target_link_libraries(plasma_engine_mouse X11::X11 X11::Xfixes)
endif ()
......@@ -60,7 +60,7 @@ target_link_libraries(kcm_colors
krdb
)
if(X11_FOUND)
if(HAVE_X11)
target_link_libraries(kcm_colors X11::X11)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(kcm_colors Qt::X11Extras)
......
......@@ -46,17 +46,15 @@ target_link_libraries(kcm_cursortheme
PW::KWorkspace
krdb
)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(kcm_cursortheme Qt::X11Extras)
else()
target_link_libraries(kcm_cursortheme Qt::GuiPrivate)
endif()
if (X11_Xcursor_FOUND)
target_link_libraries(kcm_cursortheme X11::Xcursor)
endif ()
if (X11_Xfixes_FOUND)
target_link_libraries(kcm_cursortheme X11::Xfixes)
if (HAVE_X11)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(kcm_cursortheme Qt::X11Extras)
else()
target_link_libraries(kcm_cursortheme Qt::GuiPrivate)
endif()
target_link_libraries(kcm_cursortheme X11::Xcursor X11::Xfixes)
endif ()
########### next target ###############
......@@ -81,21 +79,18 @@ target_link_libraries(plasma-apply-cursortheme
KF5::I18n
KF5::KCMUtils
KF5::WindowSystem
X11::X11
XCB::XCB
PW::KWorkspace
)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(plasma-apply-cursortheme Qt::X11Extras)
else()
target_link_libraries(plasma-apply-cursortheme Qt::GuiPrivate)
if (HAVE_X11)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(plasma-apply-cursortheme Qt::X11Extras)
else()
target_link_libraries(plasma-apply-cursortheme Qt::GuiPrivate)
endif()
target_link_libraries(plasma-apply-cursortheme X11::X11 X11::Xcursor X11::Xfixes)
endif()
if (X11_Xcursor_FOUND)
target_link_libraries(plasma-apply-cursortheme X11::Xcursor)
endif ()
if (X11_Xfixes_FOUND)
target_link_libraries(plasma-apply-cursortheme X11::Xfixes)
endif ()
install(TARGETS plasma-apply-cursortheme DESTINATION ${KDE_INSTALL_BINDIR})
......
......@@ -28,7 +28,7 @@ kcmutils_generate_desktop_file (kcm_fonts)
target_link_libraries(kcm_fonts KF5::I18n KF5::WindowSystem KF5::KCMUtils KF5::QuickAddons KF5::Declarative kfontinst krdb)
if(X11_FOUND)
if(HAVE_X11)
target_link_libraries(kcm_fonts X11::X11 X11::Xft XCB::IMAGE)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(kcm_fonts Qt::X11Extras)
......
# KI18N Translation Domain for this library
add_definitions(-DTRANSLATION_DOMAIN=\"kfontinst\")
if (X11_Xft_FOUND)
if (HAVE_X11)
check_include_files(locale.h HAVE_LOCALE_H)
configure_file(config-fontinst.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-fontinst.h)
include_directories(
......
# KI18N Translation Domain for this library
add_definitions(-DTRANSLATION_DOMAIN=\"kcm_lookandfeel\")
if(X11_Xcursor_FOUND)
if(HAVE_X11)
set(HAVE_XCURSOR TRUE)
endif()
......@@ -19,7 +19,7 @@ add_library(lookandfeelmanager STATIC
../kcms-common.cpp
)
if (X11_Xcursor_FOUND)
if (HAVE_X11)
target_sources(lookandfeelmanager PRIVATE
../cursortheme/xcursor/cursortheme.cpp
../cursortheme/xcursor/xcursortheme.cpp
......@@ -49,19 +49,14 @@ target_link_libraries(lookandfeelmanager
krdb
)
if(X11_FOUND)
if(HAVE_X11)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(lookandfeelmanager Qt::X11Extras)
else()
target_link_libraries(lookandfeelmanager Qt::GuiPrivate)
endif()
target_link_libraries(lookandfeelmanager X11::Xcursor X11::Xfixes)
endif()
if (X11_Xcursor_FOUND)
target_link_libraries(lookandfeelmanager X11::Xcursor)
endif ()
if (X11_Xfixes_FOUND)
target_link_libraries(lookandfeelmanager X11::Xfixes)
endif ()
add_library(kcm_lookandfeel_objects OBJECT kcm.cpp)
target_link_libraries(kcm_lookandfeel_objects
......
......@@ -50,7 +50,8 @@ target_link_libraries(libklipper_common_static
KF5::WaylandClient
KF5::IconThemes
${ZLIB_LIBRARY})
if (X11_FOUND)
if (HAVE_X11)
target_link_libraries(libklipper_common_static XCB::XCB)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(libklipper_common_static Qt::X11Extras)
......
......@@ -68,10 +68,7 @@ target_include_directories(kworkspace PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_
configure_file(config-libkworkspace.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-libkworkspace.h)
if(X11_FOUND)
if(NOT X11_Xau_FOUND)
message(FATAL_ERROR "Found X11, but not libXau which is required for building kworkspace")
endif()
if(HAVE_X11)
target_link_libraries(kworkspace PRIVATE X11::Xau)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(kworkspace PRIVATE Qt::X11Extras)
......
......@@ -22,7 +22,7 @@ set(taskmanager_LIB_SRCS
windowtasksmodel.cpp
)
if (X11_FOUND)
if (HAVE_X11)
set(taskmanager_LIB_SRCS
${taskmanager_LIB_SRCS}
xstartuptasksmodel.cpp
......@@ -56,7 +56,7 @@ target_link_libraries(taskmanager
KF5::WindowSystem
)
if (X11_FOUND)
if (HAVE_X11)
target_link_libraries(taskmanager PRIVATE KF5::IconThemes)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(taskmanager PRIVATE Qt::X11Extras)
......@@ -101,7 +101,7 @@ install(FILES
DESTINATION ${KDE_INSTALL_INCLUDEDIR}/taskmanager COMPONENT Devel
)
if (X11_FOUND)
if (HAVE_X11)
install(FILES
xstartuptasksmodel.h
xwindowtasksmodel.h
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment