Reduce number of optional dependencies

Change some optional dependencies from being optional to being mandatory
or being mandatory but behind on-by-default cmake flags. Eg: instead of
only compiling Wayland support if we find the appropriate libraries, we
always require the libraries unless the user specifies WITH_WAYLAND=OFF.

Optional libraries are hard to discover by packagers (since they don't
see an error once we add them) and create lots of possible build flavors
with a different features that can confuse users.
This commit is contained in:
Albert Vaca Cintora 2023-07-19 17:08:03 +00:00
parent c96559372b
commit 495e3019e4
11 changed files with 48 additions and 74 deletions

View file

@ -49,8 +49,7 @@ target_include_directories(kdeconnectversion INTERFACE ${CMAKE_CURRENT_BINARY_DI
find_package(Qca-qt${QT_MAJOR_VERSION} ${QCA_MIN_VERSION} REQUIRED) find_package(Qca-qt${QT_MAJOR_VERSION} ${QCA_MIN_VERSION} REQUIRED)
set(Qca_LIBRARY qca-qt${QT_MAJOR_VERSION}) set(Qca_LIBRARY qca-qt${QT_MAJOR_VERSION})
set(KF5_REQUIRED_COMPONENTS I18n ConfigWidgets DBusAddons IconThemes Notifications KIO KCMUtils Service Solid Kirigami2 People WindowSystem GuiAddons) set(KF5_REQUIRED_COMPONENTS I18n ConfigWidgets DBusAddons IconThemes Notifications KIO KCMUtils Service Solid Kirigami2 People WindowSystem GuiAddons DocTools)
set(KF5_OPTIONAL_COMPONENTS DocTools)
set_package_properties(KF5Kirigami2 PROPERTIES set_package_properties(KF5Kirigami2 PROPERTIES
DESCRIPTION "QtQuick plugins to build user interfaces based on KDE UX guidelines" DESCRIPTION "QtQuick plugins to build user interfaces based on KDE UX guidelines"
@ -60,11 +59,20 @@ set_package_properties(KF5Kirigami2 PROPERTIES
) )
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
find_package(KF5Package REQUIRED) option(WITH_X11 "Build with X11 support" ON)
find_package(KF5PulseAudioQt) option(WITH_PULSEAUDIO "Build with Pulseaudio support" ON)
if (QT_MAJOR_VERSION EQUAL "5") else()
find_package(QtWaylandScanner REQUIRED) set(WITH_X11 OFF)
set(WITH_PULSEAUDIO OFF)
endif() endif()
if(UNIX AND NOT APPLE)
find_package(KF5Package REQUIRED)
if (WITH_PULSEAUDIO)
find_package(KF5PulseAudioQt)
endif()
find_package(QtWaylandScanner REQUIRED)
find_package(Wayland 1.9 REQUIRED Client) find_package(Wayland 1.9 REQUIRED Client)
find_package(Qt${QT_MAJOR_VERSION} REQUIRED COMPONENTS WaylandClient) find_package(Qt${QT_MAJOR_VERSION} REQUIRED COMPONENTS WaylandClient)
find_package(WaylandProtocols REQUIRED) find_package(WaylandProtocols REQUIRED)
@ -79,8 +87,6 @@ set_package_properties(KF5PeopleVCard PROPERTIES
TYPE RUNTIME TYPE RUNTIME
) )
add_definitions(-DHAVE_KIO)
#ecm_find_qmlmodule(org.kde.people 1.0) FIXME This results in KPeople code being called which triggers DBus calls which breaks the Windows CI #ecm_find_qmlmodule(org.kde.people 1.0) FIXME This results in KPeople code being called which triggers DBus calls which breaks the Windows CI
ecm_find_qmlmodule(QtQuick.Particles 2.0) ecm_find_qmlmodule(QtQuick.Particles 2.0)
@ -91,9 +97,6 @@ if (UNIX AND NOT APPLE AND QT_MAJOR_VERSION EQUAL "5")
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS X11Extras) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS X11Extras)
endif() endif()
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS ${KF5_REQUIRED_COMPONENTS}) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS ${KF5_REQUIRED_COMPONENTS})
if (KF5_OPTIONAL_COMPONENTS)
find_package(KF5 ${KF5_MIN_VERSION} OPTIONAL_COMPONENTS ${KF5_OPTIONAL_COMPONENTS})
endif()
if (WIN32) if (WIN32)
get_filename_component(WINDOWS_KITS_DIR get_filename_component(WINDOWS_KITS_DIR
@ -132,10 +135,9 @@ if(NOT WIN32 AND NOT APPLE)
add_subdirectory(plasmoid) add_subdirectory(plasmoid)
endif() endif()
if(KF5DocTools_FOUND)
add_subdirectory(doc) add_subdirectory(doc)
kdoctools_install(po) kdoctools_install(po)
endif()
ki18n_install(po) ki18n_install(po)
if(BUILD_TESTING) if(BUILD_TESTING)

View file

@ -64,6 +64,8 @@ PUBLIC
Qt${QT_MAJOR_VERSION}::Network Qt${QT_MAJOR_VERSION}::Network
KF5::CoreAddons KF5::CoreAddons
${Qca_LIBRARY} ${Qca_LIBRARY}
KF5::KIOCore
KF5::KIOGui
PRIVATE PRIVATE
Qt${QT_MAJOR_VERSION}::DBus Qt${QT_MAJOR_VERSION}::DBus
KF5::I18n KF5::I18n
@ -74,10 +76,6 @@ if(WIN32)
target_link_libraries(kdeconnectcore PRIVATE ws2_32.lib) # winsock2 target_link_libraries(kdeconnectcore PRIVATE ws2_32.lib) # winsock2
endif() endif()
if(${KF5KIO_FOUND})
target_link_libraries(kdeconnectcore PUBLIC KF5::KIOCore KF5::KIOGui)
endif()
if (BLUETOOTH_ENABLED) if (BLUETOOTH_ENABLED)
target_compile_definitions(kdeconnectcore PRIVATE -DKDECONNECT_BLUETOOTH) target_compile_definitions(kdeconnectcore PRIVATE -DKDECONNECT_BLUETOOTH)
target_link_libraries(kdeconnectcore PRIVATE Qt5::Bluetooth) target_link_libraries(kdeconnectcore PRIVATE Qt5::Bluetooth)

View file

@ -12,10 +12,6 @@
#include <core_debug.h> #include <core_debug.h>
#include <daemon.h> #include <daemon.h>
#ifdef HAVE_KIO
#include <kio/global.h>
#endif
CompositeUploadJob::CompositeUploadJob(const QString &deviceId, bool displayNotification) CompositeUploadJob::CompositeUploadJob(const QString &deviceId, bool displayNotification)
: KCompositeJob() : KCompositeJob()
, m_server(new Server(this)) , m_server(new Server(this))

View file

@ -8,9 +8,7 @@
#include <QDebug> #include <QDebug>
#if HAVE_KIO
#include <KIO/CommandLauncherJob> #include <KIO/CommandLauncherJob>
#endif
void OpenConfig::setXdgActivationToken(const QString &token) void OpenConfig::setXdgActivationToken(const QString &token)
{ {
@ -34,14 +32,10 @@ void OpenConfig::openConfiguration(const QString &deviceId, const QString &plugi
args << argument; args << argument;
} }
#if HAVE_KIO
auto job = new KIO::CommandLauncherJob(QStringLiteral("kdeconnect-settings"), args); auto job = new KIO::CommandLauncherJob(QStringLiteral("kdeconnect-settings"), args);
job->setDesktopName(QStringLiteral("org.kde.kdeconnect-settings")); job->setDesktopName(QStringLiteral("org.kde.kdeconnect-settings"));
job->setStartupId(m_currentToken.toUtf8()); job->setStartupId(m_currentToken.toUtf8());
job->start(); job->start();
#else
QProcess::startDetached(QStringLiteral("kdeconnect-settings"), args);
#endif
m_currentToken = QString(); m_currentToken = QString();
} }

View file

@ -35,7 +35,6 @@ if(UNIX AND NOT APPLE)
target_sources(kdeconnectdeclarativeplugin PRIVATE ${wayland_SRCS}) target_sources(kdeconnectdeclarativeplugin PRIVATE ${wayland_SRCS})
target_link_libraries(kdeconnectdeclarativeplugin PRIVATE Wayland::Client Qt::WaylandClient Qt::GuiPrivate) target_link_libraries(kdeconnectdeclarativeplugin PRIVATE Wayland::Client Qt::WaylandClient Qt::GuiPrivate)
target_sources(kdeconnectdeclarativeplugin PUBLIC pointerlockerwayland.cpp) target_sources(kdeconnectdeclarativeplugin PUBLIC pointerlockerwayland.cpp)
target_compile_definitions(kdeconnectdeclarativeplugin PRIVATE -DWITH_WAYLAND=1)
endif() endif()
target_link_libraries(kdeconnectdeclarativeplugin PRIVATE Qt::Quick kdeconnectinterfaces kdeconnectcore) target_link_libraries(kdeconnectdeclarativeplugin PRIVATE Qt::Quick kdeconnectinterfaces kdeconnectcore)

View file

@ -23,12 +23,12 @@
#include "interfaces/notificationsmodel.h" #include "interfaces/notificationsmodel.h"
#include "openconfig.h" #include "openconfig.h"
#include "pointerlocker.h" #include "pointerlocker.h"
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
#include "pointerlockerwayland.h"
#endif
#include <pluginmodel.h> #include <pluginmodel.h>
#include <remotecommandsmodel.h> #include <remotecommandsmodel.h>
#include <remotesinksmodel.h> #include <remotesinksmodel.h>
#if WITH_WAYLAND
#include "pointerlockerwayland.h"
#endif
QObject *createDBusResponse() QObject *createDBusResponse()
{ {
@ -89,7 +89,7 @@ void KdeConnectDeclarativePlugin::registerTypes(const char *uri)
}); });
qmlRegisterSingletonType<AbstractPointerLocker>("org.kde.kdeconnect", 1, 0, "PointerLocker", [](QQmlEngine *, QJSEngine *) -> QObject * { qmlRegisterSingletonType<AbstractPointerLocker>("org.kde.kdeconnect", 1, 0, "PointerLocker", [](QQmlEngine *, QJSEngine *) -> QObject * {
AbstractPointerLocker *ret; AbstractPointerLocker *ret;
#if WITH_WAYLAND #if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
if (qGuiApp->platformName() == QLatin1String("wayland")) if (qGuiApp->platformName() == QLatin1String("wayland"))
ret = new PointerLockerWayland; ret = new PointerLockerWayland;
else else

View file

@ -52,15 +52,15 @@ if(NOT APPLE)
add_subdirectory(sftp) add_subdirectory(sftp)
endif() endif()
if(KF5PulseAudioQt_FOUND OR WIN32) if(WITH_PULSEAUDIO OR WIN32)
add_subdirectory(pausemusic) add_subdirectory(pausemusic)
endif() endif()
if(Qt5Multimedia_FOUND AND (KF5PulseAudioQt_FOUND OR WIN32)) if(WITH_PULSEAUDIO OR WIN32)
add_subdirectory(findthisdevice) add_subdirectory(findthisdevice)
endif() endif()
if (WIN32 OR APPLE OR KF5PulseAudioQt_FOUND) if (WITH_PULSEAUDIO OR WIN32 OR APPLE)
add_subdirectory(systemvolume) add_subdirectory(systemvolume)
endif() endif()

View file

@ -9,19 +9,18 @@ if(UNIX AND NOT APPLE)
target_sources(kdeconnect_mousepad PUBLIC waylandremoteinput.cpp ${SRCS}) target_sources(kdeconnect_mousepad PUBLIC waylandremoteinput.cpp ${SRCS})
find_package(LibFakeKey QUIET)
set_package_properties(LibFakeKey PROPERTIES DESCRIPTION "fake key events"
URL "https://www.yoctoproject.org/tools-resources/projects/matchbox"
TYPE OPTIONAL
PURPOSE "Needed for the remote mousepad plugin"
)
target_sources(kdeconnect_mousepad PRIVATE ${wayland_SRCS}) target_sources(kdeconnect_mousepad PRIVATE ${wayland_SRCS})
target_link_libraries(kdeconnect_mousepad Wayland::Client Qt::WaylandClient PkgConfig::XkbCommon) target_link_libraries(kdeconnect_mousepad Wayland::Client Qt::WaylandClient PkgConfig::XkbCommon)
target_sources(kdeconnect_mousepad PUBLIC waylandremoteinput.cpp) target_sources(kdeconnect_mousepad PUBLIC waylandremoteinput.cpp)
set(HAVE_WAYLAND TRUE)
if (LibFakeKey_FOUND) if (WITH_X11)
find_package(LibFakeKey REQUIRED)
set_package_properties(LibFakeKey PROPERTIES DESCRIPTION "fake key events"
URL "https://github.com/dtapuska/fakekey"
TYPE REQUIRED
PURPOSE "Needed for the remote mouse input plugin"
)
if (QT_MAJOR_VERSION EQUAL "5") if (QT_MAJOR_VERSION EQUAL "5")
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS X11Extras) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS X11Extras)
endif() endif()
@ -31,18 +30,15 @@ if(UNIX AND NOT APPLE)
endif() endif()
endif() endif()
set(HAVE_WINDOWS ${WIN32})
set(HAVE_X11 ${LibFakeKey_FOUND})
set(HAVE_MACOS ${APPLE})
configure_file(config-mousepad.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-mousepad.h) configure_file(config-mousepad.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-mousepad.h)
target_link_libraries(kdeconnect_mousepad kdeconnectcore Qt::Gui KF5::I18n) target_link_libraries(kdeconnect_mousepad kdeconnectcore Qt::Gui KF5::I18n)
if (HAVE_WINDOWS) if (WIN32)
target_sources(kdeconnect_mousepad PUBLIC windowsremoteinput.cpp) target_sources(kdeconnect_mousepad PUBLIC windowsremoteinput.cpp)
endif() endif()
if(HAVE_X11) if(WITH_X11)
target_sources(kdeconnect_mousepad PUBLIC x11remoteinput.cpp) target_sources(kdeconnect_mousepad PUBLIC x11remoteinput.cpp)
if (QT_MAJOR_VERSION EQUAL "5") if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(kdeconnect_mousepad Qt5::X11Extras) target_link_libraries(kdeconnect_mousepad Qt5::X11Extras)
@ -50,7 +46,7 @@ if(HAVE_X11)
target_link_libraries(kdeconnect_mousepad ${X11_LIBRARIES} ${XTEST_LIBRARIES} ${LibFakeKey_LIBRARIES}) target_link_libraries(kdeconnect_mousepad ${X11_LIBRARIES} ${XTEST_LIBRARIES} ${LibFakeKey_LIBRARIES})
endif() endif()
if (HAVE_MACOS) if (APPLE)
target_sources(kdeconnect_mousepad PUBLIC macosremoteinput.mm) target_sources(kdeconnect_mousepad PUBLIC macosremoteinput.mm)
target_link_libraries(kdeconnect_mousepad "-framework CoreGraphics" "-framework ApplicationServices" "-framework Cocoa") target_link_libraries(kdeconnect_mousepad "-framework CoreGraphics" "-framework ApplicationServices" "-framework Cocoa")
endif() endif()

View file

@ -1,4 +1 @@
#cmakedefine01 HAVE_WAYLAND #cmakedefine01 WITH_X11
#cmakedefine01 HAVE_X11
#cmakedefine01 HAVE_WINDOWS
#cmakedefine01 HAVE_MACOS

View file

@ -11,16 +11,14 @@
#include <KPluginFactory> #include <KPluginFactory>
#include <QGuiApplication> #include <QGuiApplication>
#if HAVE_WINDOWS #if defined(Q_OS_WIN)
#include "windowsremoteinput.h" #include "windowsremoteinput.h"
#elif HAVE_MACOS #elif defined(Q_OS_MACOS)
#include "macosremoteinput.h" #include "macosremoteinput.h"
#else #else
#if HAVE_X11
#include "x11remoteinput.h"
#endif
#if HAVE_WAYLAND
#include "waylandremoteinput.h" #include "waylandremoteinput.h"
#if WITH_X11
#include "x11remoteinput.h"
#endif #endif
#endif #endif
@ -30,21 +28,18 @@ MousepadPlugin::MousepadPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args) : KdeConnectPlugin(parent, args)
, m_impl(nullptr) , m_impl(nullptr)
{ {
#if HAVE_WINDOWS #if defined(Q_OS_WIN)
m_impl = new WindowsRemoteInput(this); m_impl = new WindowsRemoteInput(this);
#elif HAVE_MACOS #elif defined(Q_OS_APPLE)
m_impl = new MacOSRemoteInput(this); m_impl = new MacOSRemoteInput(this);
#else #else
#if HAVE_X11
if (QGuiApplication::platformName() == QLatin1String("xcb")) {
m_impl = new X11RemoteInput(this);
}
#endif
#if HAVE_WAYLAND
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
m_impl = new WaylandRemoteInput(this); m_impl = new WaylandRemoteInput(this);
} }
#if WITH_X11
if (QGuiApplication::platformName() == QLatin1String("xcb")) {
m_impl = new X11RemoteInput(this);
}
#endif #endif
#endif #endif

View file

@ -4,14 +4,11 @@ set(kdeconnect_libraries
kdeconnectcore kdeconnectcore
kdeconnectversion kdeconnectversion
KF5::I18n KF5::I18n
KF5::KIOWidgets
Qt::DBus Qt::DBus
Qt::Network Qt::Network
Qt::Test Qt::Test
) )
if(${KF5KIO_FOUND})
list(APPEND kdeconnect_libraries KF5::KIOWidgets)
endif()
ecm_add_test(pluginloadtest.cpp LINK_LIBRARIES ${kdeconnect_libraries}) ecm_add_test(pluginloadtest.cpp LINK_LIBRARIES ${kdeconnect_libraries})
ecm_add_test(sendfiletest.cpp LINK_LIBRARIES ${kdeconnect_libraries}) ecm_add_test(sendfiletest.cpp LINK_LIBRARIES ${kdeconnect_libraries})