Commit 33b8ed6c authored by Volker Krause's avatar Volker Krause
Browse files

Adapt build system to also support Qt6

This includes Qt6 specific code changes as well, but still lacks the port
to KWaylandServer (that's also needed due to KF5::WaylandServer being
gone in 6).
parent e90d719e
Pipeline #145875 passed with stage
in 5 minutes and 2 seconds
......@@ -4,7 +4,7 @@ project(libkscreen)
set(PROJECT_VERSION "5.24.80")
set(QT_MIN_VERSION "5.15.0")
set(KF5_MIN_VERSION "5.86")
set(KF5_MIN_VERSION "5.91")
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
set(CMAKE_CXX_STANDARD 17)
......@@ -26,8 +26,11 @@ include(GenerateExportHeader)
include(KDEClangFormat)
include(KDEGitCommitHooks)
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core DBus Gui Test X11Extras)
find_package(QtWaylandScanner REQUIRED)
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED Core DBus Gui Test WaylandClient)
if (QT_MAJOR_VERSION EQUAL "5")
find_package(Qt5 CONFIG REQUIRED X11Extras)
find_package(QtWaylandScanner REQUIRED)
endif()
find_package(WaylandScanner)
# Wayland backend
......@@ -70,7 +73,7 @@ if(BUILD_TESTING)
add_subdirectory(tests)
endif()
set(CMAKECONFIG_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/KF5Screen")
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5Screen")
# add clang-format target for all our real source files
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
......@@ -110,7 +113,7 @@ install(EXPORT
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/kscreen_version.h"
DESTINATION "${KF5_INCLUDE_INSTALL_DIR}"
DESTINATION "${KDE_INSTALL_INCLUDEDIR_KF}"
COMPONENT Devel
)
install(FILES libkscreen.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR})
......
......@@ -16,22 +16,31 @@ ecm_qt_declare_logging_category(wayland_SRCS
CATEGORY_NAME kscreen.kwayland
)
ecm_add_qtwayland_client_protocol(wayland_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-output-device-v2.xml
BASENAME kde-output-device-v2
)
ecm_add_qtwayland_client_protocol(wayland_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-output-management-v2.xml
BASENAME kde-output-management-v2
)
ecm_add_qtwayland_client_protocol(wayland_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-primary-output-v1.xml
BASENAME kde-primary-output-v1
)
add_library(KSC_KWayland MODULE ${wayland_SRCS})
add_library(KSC_KWayland MODULE)
if (QT_MAJOR_VERSION EQUAL "5")
ecm_add_qtwayland_client_protocol(wayland_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-output-device-v2.xml
BASENAME kde-output-device-v2
)
ecm_add_qtwayland_client_protocol(wayland_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-output-management-v2.xml
BASENAME kde-output-management-v2
)
ecm_add_qtwayland_client_protocol(wayland_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-primary-output-v1.xml
BASENAME kde-primary-output-v1
)
else()
qt6_generate_wayland_protocol_client_sources(KSC_KWayland FILES
${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-output-device-v2.xml
${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-output-management-v2.xml
${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-primary-output-v1.xml
)
endif()
target_sources(KSC_KWayland PRIVATE ${wayland_SRCS})
set_target_properties(KSC_KWayland PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/kf5/kscreen")
set_target_properties(KSC_KWayland PROPERTIES PREFIX "")
......
......@@ -19,8 +19,10 @@ set_target_properties(KSC_QScreen PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_B
set_target_properties(KSC_QScreen PROPERTIES PREFIX "")
target_link_libraries(KSC_QScreen Qt::Core
Qt::Gui
Qt::X11Extras
KF5::Screen
)
if (TARGET Qt::X11Extras)
target_link_libraries(KSC_QScreen Qt::X11Extras)
endif()
install(TARGETS KSC_QScreen DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/kscreen/)
......@@ -7,7 +7,11 @@
#include "xcbeventlistener.h"
#include <QGuiApplication>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <private/qtx11extras_p.h>
#else
#include <QX11Info>
#endif
#include <QRect>
......@@ -107,7 +111,11 @@ QString XCBEventListener::connectionToString(xcb_randr_connection_t connection)
return QStringLiteral("invalid value (%1)").arg(connection);
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
bool XCBEventListener::nativeEventFilter(const QByteArray &eventType, void *message, long int *result)
#else
bool XCBEventListener::nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result)
#endif
{
Q_UNUSED(result);
......
......@@ -22,7 +22,11 @@ public:
XCBEventListener();
~XCBEventListener() override;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
bool nativeEventFilter(const QByteArray &eventType, void *message, long int *result) override;
#else
bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override;
#endif
Q_SIGNALS:
/* Emitted when only XRandR 1.1 or older is available */
......
......@@ -15,7 +15,11 @@
#include <type_traits>
#include <QScopedPointer>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <private/qtx11extras_p.h>
#else
#include <QX11Info>
#endif
#include <xcb/randr.h>
#include <xcb/xcb.h>
......
......@@ -20,9 +20,13 @@ set_target_properties(KSC_XRandR PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BI
set_target_properties(KSC_XRandR PROPERTIES PREFIX "")
target_link_libraries(KSC_XRandR Qt::Core
Qt::Gui
Qt::X11Extras
${XCB_LIBRARIES}
KF5::Screen
)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(KSC_XRandR Qt::X11Extras)
else()
target_link_libraries(KSC_XRandR Qt::GuiPrivate)
endif()
install(TARGETS KSC_XRandR DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/kscreen/)
......@@ -19,7 +19,11 @@
#include <QTime>
#include <QTimer>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <private/qtx11extras_p.h>
#else
#include <QX11Info>
#endif
xcb_screen_t *XRandR::s_screen = nullptr;
xcb_window_t XRandR::s_rootWindow = 0;
......
......@@ -18,7 +18,11 @@
#include <QRect>
#include <QScopedPointer>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <private/qtx11extras_p.h>
#else
#include <QX11Info>
#endif
using namespace KScreen;
......
......@@ -11,7 +11,11 @@
#include "screen.h"
#include "xrandrconfig.h"
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <private/qtx11extras_p.h>
#else
#include <QX11Info>
#endif
XRandRScreen::XRandRScreen(XRandRConfig *config)
: QObject(config)
......
......@@ -17,9 +17,13 @@ set_target_properties(KSC_XRandR11 PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_
set_target_properties(KSC_XRandR11 PROPERTIES PREFIX "")
target_link_libraries(KSC_XRandR11 Qt::Core
Qt::Gui
Qt::X11Extras
${XCB_LIBRARIES}
KF5::Screen
)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(KSC_XRandR11 Qt::X11Extras)
else()
target_link_libraries(KSC_XRandR11 Qt::GuiPrivate)
endif()
install(TARGETS KSC_XRandR11 DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/kscreen/)
......@@ -40,8 +40,12 @@ target_link_libraries(KF5Screen
Qt::Gui
PRIVATE
Qt::DBus
Qt::X11Extras
)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(KF5Screen PRIVATE Qt::X11Extras)
else()
target_link_libraries(KF5Screen PRIVATE Qt::GuiPrivate)
endif()
set_target_properties(KF5Screen PROPERTIES
VERSION "${KSCREEN_VERSION}"
......@@ -49,7 +53,7 @@ set_target_properties(KF5Screen PROPERTIES
EXPORT_NAME Screen
)
target_include_directories(KF5Screen PUBLIC "$<INSTALL_INTERFACE:${KF5_INCLUDE_INSTALL_DIR}/KScreen>")
target_include_directories(KF5Screen PUBLIC "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF}/KScreen>")
install(TARGETS KF5Screen EXPORT KF5ScreenTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
add_library(KF5::Screen ALIAS KF5Screen)
......@@ -72,12 +76,12 @@ ecm_generate_headers(KScreen_HEADERS
)
install(FILES ${KScreen_HEADERS}
DESTINATION ${KF5_INCLUDE_INSTALL_DIR}/KScreen/KScreen
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/KScreen/KScreen
COMPONENT Devel)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kscreen_export.h
backendmanager_p.h # needed for unit-tests in KScreen
${KScreen_REQ_HEADERS}
DESTINATION ${KF5_INCLUDE_INSTALL_DIR}/KScreen/kscreen)
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/KScreen/kscreen)
if(NOT WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/kscreen2.pc.in ${CMAKE_CURRENT_BINARY_DIR}/kscreen2.pc @ONLY)
......
......@@ -21,9 +21,13 @@ target_link_libraries(kscreen_backend_launcher
KF5Screen
Qt::Core
Qt::Gui
Qt::X11Extras
Qt::DBus
)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(kscreen_backend_launcher Qt::X11Extras)
else()
target_link_libraries(kscreen_backend_launcher Qt::GuiPrivate)
endif()
install(TARGETS kscreen_backend_launcher
DESTINATION ${CMAKE_INSTALL_FULL_LIBEXECDIR_KF5}
......
......@@ -10,6 +10,7 @@
#include <QObject>
#include <QTimer>
#include <QVariant>
#include "types.h"
......
......@@ -16,7 +16,11 @@
#include <QDBusConnectionInterface>
#include <QDir>
#include <QPluginLoader>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <private/qtx11extras_p.h>
#else
#include <QX11Info>
#endif
#include <memory>
......
......@@ -25,7 +25,11 @@
#include <QGuiApplication>
#include <QStandardPaths>
#include <QThread>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <private/qtx11extras_p.h>
#else
#include <QX11Info>
#endif
#include <memory>
......@@ -227,7 +231,7 @@ KScreen::AbstractBackend *BackendManager::loadBackendInProcess(const QString &na
}
// qCDebug(KSCREEN) << "Connecting ConfigMonitor to backend.";
ConfigMonitor::instance()->connectInProcessBackend(backend);
m_inProcessBackend = qMakePair<KScreen::AbstractBackend *, QVariantMap>(backend, arguments);
m_inProcessBackend = qMakePair<KScreen::AbstractBackend *, QVariantMap>(static_cast<KScreen::AbstractBackend *>(backend), QVariantMap(arguments));
setConfig(backend->config());
return backend;
}
......
......@@ -9,6 +9,7 @@
#define KSCREEN_CONFIG_H
#include "kscreen_export.h"
#include "output.h"
#include "screen.h"
#include "types.h"
......
......@@ -253,9 +253,9 @@ bool Edid::Private::parse(const QByteArray &rawData)
* |\---/\---/\---/
* R C1 C2 C3 */
pnpId.resize(3);
pnpId[0] = 'A' + ((data[GCM_EDID_OFFSET_PNPID + 0] & 0x7c) / 4) - 1;
pnpId[1] = 'A' + ((data[GCM_EDID_OFFSET_PNPID + 0] & 0x3) * 8) + ((data[GCM_EDID_OFFSET_PNPID + 1] & 0xe0) / 32) - 1;
pnpId[2] = 'A' + (data[GCM_EDID_OFFSET_PNPID + 1] & 0x1f) - 1;
pnpId[0] = QLatin1Char('A' + ((data[GCM_EDID_OFFSET_PNPID + 0] & 0x7c) / 4) - 1);
pnpId[1] = QLatin1Char('A' + ((data[GCM_EDID_OFFSET_PNPID + 0] & 0x3) * 8) + ((data[GCM_EDID_OFFSET_PNPID + 1] & 0xe0) / 32) - 1);
pnpId[2] = QLatin1Char('A' + (data[GCM_EDID_OFFSET_PNPID + 1] & 0x1f) - 1);
// load the PNP_IDS file and load the vendor name
QFile pnpIds(QStringLiteral(PNP_IDS));
......
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