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
This commit is contained in:
Martin Gräßlin 2014-02-12 14:00:54 +01:00
parent 31e301174a
commit bada0c97ba
8 changed files with 51 additions and 30 deletions

View File

@ -38,7 +38,7 @@ endif()
set (QT_MIN_VERSION "5.2.0") set (QT_MIN_VERSION "5.2.0")
set(KF5_VERSION "4.96.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(KF5Activities ${KF5_VERSION} REQUIRED)
find_package(KF5Archive ${KF5_VERSION} REQUIRED) find_package(KF5Archive ${KF5_VERSION} REQUIRED)
@ -79,13 +79,18 @@ find_package(KF5XmlGui ${KF5_VERSION} REQUIRED)
#optional features #optional features
find_package(X11 MODULE) 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) find_package(XCB MODULE COMPONENTS XCB COMPOSITE DAMAGE SHAPE)
set_package_properties(XCB PROPERTIES DESCRIPTION "X protocol C-language Binding" set_package_properties(XCB PROPERTIES DESCRIPTION "X protocol C-language Binding"
URL "http://xcb.freedesktop.org" URL "http://xcb.freedesktop.org"
TYPE REQUIRED TYPE OPTIONAL
) )
if(X11_FOUND AND XCB_XCB_FOUND) if(X11_FOUND AND XCB_XCB_FOUND)
set(HAVE_X11 1) set(HAVE_X11 1)
find_package(Qt5 REQUIRED NO_MODULE COMPONENTS X11Extras)
#X11_Xrender discovery is done by FindX11 #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 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)") add_feature_info("X Screensaver Extension (libXss)" X11_Xscreensaver_FOUND "Support for KIdleTime (fallback mode)")

View File

@ -1,16 +1,19 @@
project(corebindings) project(corebindings)
add_definitions(-DHAVE_X11=${HAVE_X11}) if(HAVE_X11 AND XCB_XCB_FOUND AND XCB_COMPOSITE_FOUND AND XCB_DAMAGE_FOUND)
if(XCB_XCB_FOUND AND XCB_COMPOSITE_FOUND AND XCB_DAMAGE_FOUND)
add_definitions(-DHAVE_XCB_COMPOSITE=1) add_definitions(-DHAVE_XCB_COMPOSITE=1)
include_directories( include_directories(
${XCB_XCB_INCLUDE_DIR} ${XCB_XCB_INCLUDE_DIR}
${XCB_DAMAGE_INCLUDE_DIR} ${XCB_DAMAGE_INCLUDE_DIR}
${XCB_COMPOSITE_INCLUDE_DIR} ${XCB_COMPOSITE_INCLUDE_DIR}
) )
else()
add_definitions(-DHAVE_XCB_COMPOSITE=0)
endif() 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) add_definitions(-DHAVE_XCB_SHAPE=1)
include_directories(${XCB_SHAPE_INCLUDE_DIR}) include_directories(${XCB_SHAPE_INCLUDE_DIR})
else()
add_definitions(-DHAVE_XCB_SHAPE=0)
endif() endif()
set(corebindings_SRCS set(corebindings_SRCS
@ -44,7 +47,7 @@ target_link_libraries(corebindingsplugin
KF5::WindowSystem KF5::WindowSystem
KF5::Plasma) KF5::Plasma)
if(X11_FOUND) if(HAVE_X11)
target_link_libraries(corebindingsplugin ${X11_LIBRARIES} ${XCB_XCB_LIBRARY} ) target_link_libraries(corebindingsplugin ${X11_LIBRARIES} ${XCB_XCB_LIBRARY} )
target_link_libraries(corebindingsplugin Qt5::X11Extras) target_link_libraries(corebindingsplugin Qt5::X11Extras)

View File

@ -39,6 +39,7 @@
#include <QDebug> #include <QDebug>
#include <config-plasma.h>
#if HAVE_XCB_SHAPE #if HAVE_XCB_SHAPE
#include <QX11Info> #include <QX11Info>
#include <xcb/shape.h> #include <xcb/shape.h>

View File

@ -21,8 +21,9 @@
#include <QGlobalStatic> #include <QGlobalStatic>
#include <QWindow> #include <QWindow>
#include <QPainter> #include <QPainter>
#include <config-plasma.h>
#ifdef HAVE_X11 #if HAVE_X11
#include <QX11Info> #include <QX11Info>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -75,12 +76,12 @@ public:
QPixmap m_emptyVerticalPix; QPixmap m_emptyVerticalPix;
QPixmap m_emptyHorizontalPix; QPixmap m_emptyHorizontalPix;
#if HAVE_X11
//! xcb connection //! xcb connection
xcb_connection_t* _connection; xcb_connection_t* _connection;
//! graphical context //! graphical context
xcb_gcontext_t _gc; xcb_gcontext_t _gc;
#if HAVE_X11
bool m_isX11; bool m_isX11;
#endif #endif
@ -230,7 +231,7 @@ void DialogShadows::Private::initPixmap(const QString &element)
QPixmap DialogShadows::Private::initEmptyPixmap(const QSize &size) QPixmap DialogShadows::Private::initEmptyPixmap(const QSize &size)
{ {
#ifdef HAVE_X11 #if HAVE_X11
if (!m_isX11) { if (!m_isX11) {
return QPixmap(); return QPixmap();
} }
@ -240,6 +241,7 @@ QPixmap DialogShadows::Private::initEmptyPixmap(const QSize &size)
} }
return tempEmptyPix; return tempEmptyPix;
#else #else
Q_UNUSED(size)
return QPixmap(); return QPixmap();
#endif #endif
} }
@ -269,7 +271,7 @@ void DialogShadows::Private::setupPixmaps()
void DialogShadows::Private::setupData(Plasma::FrameSvg::EnabledBorders enabledBorders) void DialogShadows::Private::setupData(Plasma::FrameSvg::EnabledBorders enabledBorders)
{ {
#ifdef HAVE_X11 #if HAVE_X11
if (!m_isX11) { if (!m_isX11) {
return; return;
} }
@ -402,7 +404,7 @@ void DialogShadows::Private::setupData(Plasma::FrameSvg::EnabledBorders enabledB
void DialogShadows::Private::freeX11Pixmaps() void DialogShadows::Private::freeX11Pixmaps()
{ {
#ifdef HAVE_X11 #if HAVE_X11
if (!m_isX11) { if (!m_isX11) {
return; return;
} }
@ -441,7 +443,7 @@ void DialogShadows::Private::freeX11Pixmaps()
void DialogShadows::Private::clearPixmaps() void DialogShadows::Private::clearPixmaps()
{ {
#ifdef HAVE_X11 #if HAVE_X11
freeX11Pixmaps(); freeX11Pixmaps();
m_emptyCornerPix = QPixmap(); m_emptyCornerPix = QPixmap();
@ -458,7 +460,7 @@ void DialogShadows::Private::clearPixmaps()
void DialogShadows::Private::updateShadow(const QWindow *window, Plasma::FrameSvg::EnabledBorders enabledBorders) void DialogShadows::Private::updateShadow(const QWindow *window, Plasma::FrameSvg::EnabledBorders enabledBorders)
{ {
#ifdef HAVE_X11 #if HAVE_X11
if (!m_isX11) { if (!m_isX11) {
return; 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; //qDebug() << "going to set the shadow of" << window->winId() << "to" << data;
XChangeProperty(dpy, window->winId(), atom, XA_CARDINAL, 32, PropModeReplace, XChangeProperty(dpy, window->winId(), atom, XA_CARDINAL, 32, PropModeReplace,
reinterpret_cast<const unsigned char *>(data[enabledBorders].constData()), data[enabledBorders].size()); reinterpret_cast<const unsigned char *>(data[enabledBorders].constData()), data[enabledBorders].size());
#else
Q_UNUSED(window)
Q_UNUSED(enabledBorders)
#endif #endif
} }
void DialogShadows::Private::clearShadow(const QWindow *window) void DialogShadows::Private::clearShadow(const QWindow *window)
{ {
#ifdef HAVE_X11 #if HAVE_X11
if (!m_isX11) { if (!m_isX11) {
return; return;
} }
Display *dpy = QX11Info::display(); Display *dpy = QX11Info::display();
Atom atom = XInternAtom(dpy, "_KDE_NET_WM_SHADOW", False); Atom atom = XInternAtom(dpy, "_KDE_NET_WM_SHADOW", False);
XDeleteProperty(dpy, window->winId(), atom); XDeleteProperty(dpy, window->winId(), atom);
#else
Q_UNUSED(window)
#endif #endif
} }

View File

@ -12,7 +12,7 @@ if(KDE_PLATFORM_FEATURE_BINARY_COMPATIBLE_FEATURE_REDUCTION)
set(PLASMA_NO_PACKAGE_EXTRADATA TRUE) set(PLASMA_NO_PACKAGE_EXTRADATA TRUE)
endif() endif()
if(NOT X11_FOUND) if(NOT HAVE_X11)
set(PLASMA_NO_PACKAGEKIT TRUE) set(PLASMA_NO_PACKAGEKIT TRUE)
endif() endif()
@ -87,7 +87,9 @@ set(Plasma_LIB_SRCS
scripting/scriptengine.cpp 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) 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(KF5Plasma ${Plasma_LIB_SRCS})
add_library(KF5::Plasma ALIAS KF5Plasma) 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}) set(PLASMA_EXTRA_LIBS ${PLASMA_EXTRA_LIBS} Qt5::X11Extras ${X11_LIBRARIES} ${XCB_XCB_LIBRARY})
endif() endif()

View File

@ -19,14 +19,12 @@
#include "private/componentinstaller_p.h" #include "private/componentinstaller_p.h"
#ifdef PLASMA_ENABLE_PACKAGEKIT_SUPPORT
#include <QSet> #include <QSet>
#include <QDBusInterface> #include <QDBusInterface>
#include <QDBusPendingCall> #include <QDBusPendingCall>
#include <QWidget> #include <QWidget>
#include <QLatin1String> #include <QLatin1String>
#include <QStringList> #include <QStringList>
#endif
namespace Plasma namespace Plasma
{ {

View File

@ -9,8 +9,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
add_definitions(-DHAVE_X11=${HAVE_X11})
find_package(Qt5Qml REQUIRED) find_package(Qt5Qml REQUIRED)
find_package(Qt5Quick REQUIRED) find_package(Qt5Quick REQUIRED)
find_package(Qt5Script REQUIRED) find_package(Qt5Script REQUIRED)
@ -70,7 +68,7 @@ target_link_libraries(plasma-shell
) )
target_include_directories(plasma-shell PRIVATE "${CMAKE_BINARY_DIR}") 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 ${X11_LIBRARIES} ${XCB_XCB_LIBRARY} )
target_link_libraries(plasma-shell Qt5::X11Extras) target_link_libraries(plasma-shell Qt5::X11Extras)
endif() endif()

View File

@ -21,7 +21,8 @@
#include <QWindow> #include <QWindow>
#include <QPainter> #include <QPainter>
#ifdef HAVE_X11 #include <config-plasma.h>
#if HAVE_X11
#include <QX11Info> #include <QX11Info>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -74,12 +75,12 @@ public:
QPixmap m_emptyVerticalPix; QPixmap m_emptyVerticalPix;
QPixmap m_emptyHorizontalPix; QPixmap m_emptyHorizontalPix;
#if HAVE_X11
//! xcb connection //! xcb connection
xcb_connection_t* _connection; xcb_connection_t* _connection;
//! graphical context //! graphical context
xcb_gcontext_t _gc; xcb_gcontext_t _gc;
#if HAVE_X11
bool m_isX11; bool m_isX11;
#endif #endif
@ -229,7 +230,7 @@ void PanelShadows::Private::initPixmap(const QString &element)
QPixmap PanelShadows::Private::initEmptyPixmap(const QSize &size) QPixmap PanelShadows::Private::initEmptyPixmap(const QSize &size)
{ {
#ifdef HAVE_X11 #if HAVE_X11
if (!m_isX11) { if (!m_isX11) {
return QPixmap(); return QPixmap();
} }
@ -239,6 +240,7 @@ QPixmap PanelShadows::Private::initEmptyPixmap(const QSize &size)
} }
return tempEmptyPix; return tempEmptyPix;
#else #else
Q_UNUSED(size)
return QPixmap(); return QPixmap();
#endif #endif
} }
@ -268,7 +270,7 @@ void PanelShadows::Private::setupPixmaps()
void PanelShadows::Private::setupData(Plasma::FrameSvg::EnabledBorders enabledBorders) void PanelShadows::Private::setupData(Plasma::FrameSvg::EnabledBorders enabledBorders)
{ {
#ifdef HAVE_X11 #if HAVE_X11
if (!m_isX11) { if (!m_isX11) {
return; return;
} }
@ -401,7 +403,7 @@ void PanelShadows::Private::setupData(Plasma::FrameSvg::EnabledBorders enabledBo
void PanelShadows::Private::freeX11Pixmaps() void PanelShadows::Private::freeX11Pixmaps()
{ {
#ifdef HAVE_X11 #if HAVE_X11
if (!m_isX11) { if (!m_isX11) {
return; return;
} }
@ -440,7 +442,7 @@ void PanelShadows::Private::freeX11Pixmaps()
void PanelShadows::Private::clearPixmaps() void PanelShadows::Private::clearPixmaps()
{ {
#ifdef HAVE_X11 #if HAVE_X11
freeX11Pixmaps(); freeX11Pixmaps();
m_emptyCornerPix = QPixmap(); m_emptyCornerPix = QPixmap();
@ -457,7 +459,7 @@ void PanelShadows::Private::clearPixmaps()
void PanelShadows::Private::updateShadow(const QWindow *window, Plasma::FrameSvg::EnabledBorders enabledBorders) void PanelShadows::Private::updateShadow(const QWindow *window, Plasma::FrameSvg::EnabledBorders enabledBorders)
{ {
#ifdef HAVE_X11 #if HAVE_X11
if (!m_isX11) { if (!m_isX11) {
return; 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; qDebug() << "going to set the shadow of" << window->winId() << "to" << data;
XChangeProperty(dpy, window->winId(), atom, XA_CARDINAL, 32, PropModeReplace, XChangeProperty(dpy, window->winId(), atom, XA_CARDINAL, 32, PropModeReplace,
reinterpret_cast<const unsigned char *>(data[enabledBorders].constData()), data[enabledBorders].size()); reinterpret_cast<const unsigned char *>(data[enabledBorders].constData()), data[enabledBorders].size());
#else
Q_UNUSED(window)
Q_UNUSED(enabledBorders)
#endif #endif
} }
void PanelShadows::Private::clearShadow(const QWindow *window) void PanelShadows::Private::clearShadow(const QWindow *window)
{ {
#ifdef HAVE_X11 #if HAVE_X11
if (!m_isX11) { if (!m_isX11) {
return; return;
} }
Display *dpy = QX11Info::display(); Display *dpy = QX11Info::display();
Atom atom = XInternAtom(dpy, "_KDE_NET_WM_SHADOW", False); Atom atom = XInternAtom(dpy, "_KDE_NET_WM_SHADOW", False);
XDeleteProperty(dpy, window->winId(), atom); XDeleteProperty(dpy, window->winId(), atom);
#else
Q_UNUSED(window)
#endif #endif
} }