From bada0c97ba38fc60e3262ae69b43334768c5db47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 12 Feb 2014 14:00:54 +0100 Subject: [PATCH] Ensure that we can build without X11 or XCB * X11 is optional dependency * XCB is optional dependency * Qt::X11Extras is only found if both X11 and XCB are found * switch to HAVE_X11 instead of X11_FOUND in CMakeLists * remove/fix custom added definitions * use #if HAVE_X11 instead of #ifdef HAVE_X11 (that is always true) REVIEW: 115698 --- CMakeLists.txt | 9 ++++++-- src/declarativeimports/core/CMakeLists.txt | 11 +++++---- src/declarativeimports/core/dialog.cpp | 1 + src/declarativeimports/core/dialogshadows.cpp | 23 ++++++++++++------- src/plasma/CMakeLists.txt | 8 ++++--- src/plasma/private/componentinstaller.cpp | 2 -- src/shell/CMakeLists.txt | 4 +--- src/shell/panelshadows.cpp | 23 ++++++++++++------- 8 files changed, 51 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cdcc9a57a..e80978e68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ endif() set (QT_MIN_VERSION "5.2.0") set(KF5_VERSION "4.96.0") -find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Quick X11Extras Sql UiTools Qml Widgets Svg Declarative Script Test PrintSupport) +find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Quick Sql UiTools Qml Widgets Svg Declarative Script Test PrintSupport) find_package(KF5Activities ${KF5_VERSION} REQUIRED) find_package(KF5Archive ${KF5_VERSION} REQUIRED) @@ -79,13 +79,18 @@ find_package(KF5XmlGui ${KF5_VERSION} REQUIRED) #optional features find_package(X11 MODULE) +set_package_properties(X11 PROPERTIES DESCRIPTION "X11 libraries" + URL "http://www.x.org" + TYPE OPTIONAL + ) find_package(XCB MODULE COMPONENTS XCB COMPOSITE DAMAGE SHAPE) set_package_properties(XCB PROPERTIES DESCRIPTION "X protocol C-language Binding" URL "http://xcb.freedesktop.org" - TYPE REQUIRED + TYPE OPTIONAL ) if(X11_FOUND AND XCB_XCB_FOUND) set(HAVE_X11 1) + find_package(Qt5 REQUIRED NO_MODULE COMPONENTS X11Extras) #X11_Xrender discovery is done by FindX11 add_feature_info("X Rendering Extension (libXrender)" X11_Xrender_FOUND "Support for compositing, rendering operations, and alpha-blending. STRONGLY RECOMMENDED") add_feature_info("X Screensaver Extension (libXss)" X11_Xscreensaver_FOUND "Support for KIdleTime (fallback mode)") diff --git a/src/declarativeimports/core/CMakeLists.txt b/src/declarativeimports/core/CMakeLists.txt index 2ea89b3d1..dadd350f5 100644 --- a/src/declarativeimports/core/CMakeLists.txt +++ b/src/declarativeimports/core/CMakeLists.txt @@ -1,16 +1,19 @@ project(corebindings) -add_definitions(-DHAVE_X11=${HAVE_X11}) -if(XCB_XCB_FOUND AND XCB_COMPOSITE_FOUND AND XCB_DAMAGE_FOUND) +if(HAVE_X11 AND XCB_XCB_FOUND AND XCB_COMPOSITE_FOUND AND XCB_DAMAGE_FOUND) add_definitions(-DHAVE_XCB_COMPOSITE=1) include_directories( ${XCB_XCB_INCLUDE_DIR} ${XCB_DAMAGE_INCLUDE_DIR} ${XCB_COMPOSITE_INCLUDE_DIR} ) +else() + add_definitions(-DHAVE_XCB_COMPOSITE=0) endif() -if(XCB_XCB_FOUND AND XCB_SHAPE_FOUND) +if(HAVE_X11 AND XCB_XCB_FOUND AND XCB_SHAPE_FOUND) add_definitions(-DHAVE_XCB_SHAPE=1) include_directories(${XCB_SHAPE_INCLUDE_DIR}) +else() + add_definitions(-DHAVE_XCB_SHAPE=0) endif() set(corebindings_SRCS @@ -44,7 +47,7 @@ target_link_libraries(corebindingsplugin KF5::WindowSystem KF5::Plasma) -if(X11_FOUND) +if(HAVE_X11) target_link_libraries(corebindingsplugin ${X11_LIBRARIES} ${XCB_XCB_LIBRARY} ) target_link_libraries(corebindingsplugin Qt5::X11Extras) diff --git a/src/declarativeimports/core/dialog.cpp b/src/declarativeimports/core/dialog.cpp index d88b9700e..b353caf02 100644 --- a/src/declarativeimports/core/dialog.cpp +++ b/src/declarativeimports/core/dialog.cpp @@ -39,6 +39,7 @@ #include +#include #if HAVE_XCB_SHAPE #include #include diff --git a/src/declarativeimports/core/dialogshadows.cpp b/src/declarativeimports/core/dialogshadows.cpp index 5e7062ae2..0a19df6db 100644 --- a/src/declarativeimports/core/dialogshadows.cpp +++ b/src/declarativeimports/core/dialogshadows.cpp @@ -21,8 +21,9 @@ #include #include #include +#include -#ifdef HAVE_X11 +#if HAVE_X11 #include #include #include @@ -75,12 +76,12 @@ public: QPixmap m_emptyVerticalPix; QPixmap m_emptyHorizontalPix; +#if HAVE_X11 //! xcb connection xcb_connection_t* _connection; //! graphical context xcb_gcontext_t _gc; -#if HAVE_X11 bool m_isX11; #endif @@ -230,7 +231,7 @@ void DialogShadows::Private::initPixmap(const QString &element) QPixmap DialogShadows::Private::initEmptyPixmap(const QSize &size) { -#ifdef HAVE_X11 +#if HAVE_X11 if (!m_isX11) { return QPixmap(); } @@ -240,6 +241,7 @@ QPixmap DialogShadows::Private::initEmptyPixmap(const QSize &size) } return tempEmptyPix; #else + Q_UNUSED(size) return QPixmap(); #endif } @@ -269,7 +271,7 @@ void DialogShadows::Private::setupPixmaps() void DialogShadows::Private::setupData(Plasma::FrameSvg::EnabledBorders enabledBorders) { -#ifdef HAVE_X11 +#if HAVE_X11 if (!m_isX11) { return; } @@ -402,7 +404,7 @@ void DialogShadows::Private::setupData(Plasma::FrameSvg::EnabledBorders enabledB void DialogShadows::Private::freeX11Pixmaps() { -#ifdef HAVE_X11 +#if HAVE_X11 if (!m_isX11) { return; } @@ -441,7 +443,7 @@ void DialogShadows::Private::freeX11Pixmaps() void DialogShadows::Private::clearPixmaps() { -#ifdef HAVE_X11 +#if HAVE_X11 freeX11Pixmaps(); m_emptyCornerPix = QPixmap(); @@ -458,7 +460,7 @@ void DialogShadows::Private::clearPixmaps() void DialogShadows::Private::updateShadow(const QWindow *window, Plasma::FrameSvg::EnabledBorders enabledBorders) { -#ifdef HAVE_X11 +#if HAVE_X11 if (!m_isX11) { return; } @@ -476,18 +478,23 @@ void DialogShadows::Private::updateShadow(const QWindow *window, Plasma::FrameSv //qDebug() << "going to set the shadow of" << window->winId() << "to" << data; XChangeProperty(dpy, window->winId(), atom, XA_CARDINAL, 32, PropModeReplace, reinterpret_cast(data[enabledBorders].constData()), data[enabledBorders].size()); +#else + Q_UNUSED(window) + Q_UNUSED(enabledBorders) #endif } void DialogShadows::Private::clearShadow(const QWindow *window) { -#ifdef HAVE_X11 +#if HAVE_X11 if (!m_isX11) { return; } Display *dpy = QX11Info::display(); Atom atom = XInternAtom(dpy, "_KDE_NET_WM_SHADOW", False); XDeleteProperty(dpy, window->winId(), atom); +#else + Q_UNUSED(window) #endif } diff --git a/src/plasma/CMakeLists.txt b/src/plasma/CMakeLists.txt index 9679cc96f..ef886c82b 100644 --- a/src/plasma/CMakeLists.txt +++ b/src/plasma/CMakeLists.txt @@ -12,7 +12,7 @@ if(KDE_PLATFORM_FEATURE_BINARY_COMPATIBLE_FEATURE_REDUCTION) set(PLASMA_NO_PACKAGE_EXTRADATA TRUE) endif() -if(NOT X11_FOUND) +if(NOT HAVE_X11) set(PLASMA_NO_PACKAGEKIT TRUE) endif() @@ -87,7 +87,9 @@ set(Plasma_LIB_SRCS scripting/scriptengine.cpp ) -set(Plasma_LIB_SRCS ${Plasma_LIB_SRCS} private/effectwatcher.cpp) +if(HAVE_X11) + set(Plasma_LIB_SRCS ${Plasma_LIB_SRCS} private/effectwatcher.cpp) +endif() kconfig_add_kcfg_files(Plasma_LIB_SRCS data/kconfigxt/libplasma-theme-global.kcfgc) @@ -103,7 +105,7 @@ kconfig_add_kcfg_files(Plasma_LIB_SRCS data/kconfigxt/libplasma-theme-global.kcf add_library(KF5Plasma ${Plasma_LIB_SRCS}) add_library(KF5::Plasma ALIAS KF5Plasma) -if(X11_FOUND) +if(HAVE_X11) set(PLASMA_EXTRA_LIBS ${PLASMA_EXTRA_LIBS} Qt5::X11Extras ${X11_LIBRARIES} ${XCB_XCB_LIBRARY}) endif() diff --git a/src/plasma/private/componentinstaller.cpp b/src/plasma/private/componentinstaller.cpp index 4f70baa9c..571d98a12 100644 --- a/src/plasma/private/componentinstaller.cpp +++ b/src/plasma/private/componentinstaller.cpp @@ -19,14 +19,12 @@ #include "private/componentinstaller_p.h" -#ifdef PLASMA_ENABLE_PACKAGEKIT_SUPPORT #include #include #include #include #include #include -#endif namespace Plasma { diff --git a/src/shell/CMakeLists.txt b/src/shell/CMakeLists.txt index 5fbbf874a..61bd1265d 100644 --- a/src/shell/CMakeLists.txt +++ b/src/shell/CMakeLists.txt @@ -9,8 +9,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) -add_definitions(-DHAVE_X11=${HAVE_X11}) - find_package(Qt5Qml REQUIRED) find_package(Qt5Quick REQUIRED) find_package(Qt5Script REQUIRED) @@ -70,7 +68,7 @@ target_link_libraries(plasma-shell ) target_include_directories(plasma-shell PRIVATE "${CMAKE_BINARY_DIR}") -if(X11_FOUND) +if(HAVE_X11) target_link_libraries(plasma-shell ${X11_LIBRARIES} ${XCB_XCB_LIBRARY} ) target_link_libraries(plasma-shell Qt5::X11Extras) endif() diff --git a/src/shell/panelshadows.cpp b/src/shell/panelshadows.cpp index 58bbb467d..65be4632c 100644 --- a/src/shell/panelshadows.cpp +++ b/src/shell/panelshadows.cpp @@ -21,7 +21,8 @@ #include #include -#ifdef HAVE_X11 +#include +#if HAVE_X11 #include #include #include @@ -74,12 +75,12 @@ public: QPixmap m_emptyVerticalPix; QPixmap m_emptyHorizontalPix; +#if HAVE_X11 //! xcb connection xcb_connection_t* _connection; //! graphical context xcb_gcontext_t _gc; -#if HAVE_X11 bool m_isX11; #endif @@ -229,7 +230,7 @@ void PanelShadows::Private::initPixmap(const QString &element) QPixmap PanelShadows::Private::initEmptyPixmap(const QSize &size) { -#ifdef HAVE_X11 +#if HAVE_X11 if (!m_isX11) { return QPixmap(); } @@ -239,6 +240,7 @@ QPixmap PanelShadows::Private::initEmptyPixmap(const QSize &size) } return tempEmptyPix; #else + Q_UNUSED(size) return QPixmap(); #endif } @@ -268,7 +270,7 @@ void PanelShadows::Private::setupPixmaps() void PanelShadows::Private::setupData(Plasma::FrameSvg::EnabledBorders enabledBorders) { -#ifdef HAVE_X11 +#if HAVE_X11 if (!m_isX11) { return; } @@ -401,7 +403,7 @@ void PanelShadows::Private::setupData(Plasma::FrameSvg::EnabledBorders enabledBo void PanelShadows::Private::freeX11Pixmaps() { -#ifdef HAVE_X11 +#if HAVE_X11 if (!m_isX11) { return; } @@ -440,7 +442,7 @@ void PanelShadows::Private::freeX11Pixmaps() void PanelShadows::Private::clearPixmaps() { -#ifdef HAVE_X11 +#if HAVE_X11 freeX11Pixmaps(); m_emptyCornerPix = QPixmap(); @@ -457,7 +459,7 @@ void PanelShadows::Private::clearPixmaps() void PanelShadows::Private::updateShadow(const QWindow *window, Plasma::FrameSvg::EnabledBorders enabledBorders) { -#ifdef HAVE_X11 +#if HAVE_X11 if (!m_isX11) { return; } @@ -475,18 +477,23 @@ void PanelShadows::Private::updateShadow(const QWindow *window, Plasma::FrameSvg qDebug() << "going to set the shadow of" << window->winId() << "to" << data; XChangeProperty(dpy, window->winId(), atom, XA_CARDINAL, 32, PropModeReplace, reinterpret_cast(data[enabledBorders].constData()), data[enabledBorders].size()); +#else + Q_UNUSED(window) + Q_UNUSED(enabledBorders) #endif } void PanelShadows::Private::clearShadow(const QWindow *window) { -#ifdef HAVE_X11 +#if HAVE_X11 if (!m_isX11) { return; } Display *dpy = QX11Info::display(); Atom atom = XInternAtom(dpy, "_KDE_NET_WM_SHADOW", False); XDeleteProperty(dpy, window->winId(), atom); +#else + Q_UNUSED(window) #endif }