Make a new kdeconnectcore library

Solves the need of compiling device.cpp against all plugins. Also
networkpackage and others don't need to either.

REVIEW: 118742
This commit is contained in:
Aleix Pol 2014-06-14 14:31:31 +02:00
parent 1bda8043cd
commit 5c9d3a9d42
18 changed files with 42 additions and 248 deletions

View file

@ -3,11 +3,14 @@ project(kdeconnect)
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
find_package(KDE4 REQUIRED) find_package(KDE4 REQUIRED)
find_package(QJSON REQUIRED)
find_package(QCA2 REQUIRED)
#if(CMAKE_COMPILER_IS_GNUCXX) #if(CMAKE_COMPILER_IS_GNUCXX)
# add_definitions(-std=gnu++0x) # add_definitions(-std=gnu++0x)
#endif() #endif()
include(GenerateExportHeader)
include(KDE4Defaults) include(KDE4Defaults)
include_directories(${KDE4_INCLUDES}) include_directories(${KDE4_INCLUDES})
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})

View file

@ -1,14 +1,14 @@
add_subdirectory(plugins) project(KDEConnectCore)
find_package (QJSON 0.8.1 REQUIRED)
find_package (QCA2 REQUIRED)
include_directories( include_directories(
${KDE4_KIO_LIBS} ${KDE4_KIO_LIBS}
${QJSON_INCLUDE_DIR} ${QJSON_INCLUDE_DIR}
${QCA2_INCLUDE_DIR} ${QCA2_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
) )
add_subdirectory(plugins)
add_subdirectory(backends/lan) add_subdirectory(backends/lan)
add_subdirectory(backends/loopback) add_subdirectory(backends/loopback)
@ -28,16 +28,21 @@ set(kded_kdeconnect_SRCS
kdebugnamespace.cpp kdebugnamespace.cpp
) )
kde4_add_executable(kdeconnectd kdeconnectd.cpp ${kded_kdeconnect_SRCS}) kde4_add_library(kdeconnectcore SHARED ${kded_kdeconnect_SRCS})
target_link_libraries(kdeconnectcore
target_link_libraries(kdeconnectd PUBLIC
${KDE4_KDECORE_LIBS} ${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
PRIVATE
${KDE4_KIO_LIBS} ${KDE4_KIO_LIBS}
${QT_QTNETWORK_LIBRARY}
${QJSON_LIBRARIES} ${QJSON_LIBRARIES}
${QT_QTNETWORK_LIBRARY}
${QCA2_LIBRARIES} ${QCA2_LIBRARIES}
) )
generate_export_header(kdeconnectcore EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/kdeconnectcore_export.h BASE_NAME KDEConnectCore)
kde4_add_executable(kdeconnectd kdeconnectd.cpp)
target_link_libraries(kdeconnectd kdeconnectcore ${KDE4_KDEUI_LIBS})
kde4_add_plugin(kded_kdeconnect kded.cpp) kde4_add_plugin(kded_kdeconnect kded.cpp)

View file

@ -28,13 +28,14 @@
#include <KDEDModule> #include <KDEDModule>
#include <KPluginFactory> #include <KPluginFactory>
#include "kdeconnectcore_export.h"
#include "device.h" #include "device.h"
#include "networkpackage.h" #include "networkpackage.h"
#include "backends/devicelink.h" #include "backends/devicelink.h"
#include "backends/linkprovider.h" #include "backends/linkprovider.h"
class Daemon class KDECONNECTCORE_EXPORT Daemon
: public QObject : public QObject
{ {
Q_OBJECT Q_OBJECT

View file

@ -33,7 +33,7 @@
class DeviceLink; class DeviceLink;
class KdeConnectPlugin; class KdeConnectPlugin;
class Device class KDECONNECTCORE_EXPORT Device
: public QObject : public QObject
{ {
Q_OBJECT Q_OBJECT

View file

@ -23,7 +23,7 @@
#include <KDebug> #include <KDebug>
int kdeconnect_kded(); KDE_EXPORT int kdeconnect_kded();
#endif #endif

View file

@ -31,15 +31,15 @@
#include <QtCrypto> #include <QtCrypto>
#include <QSharedPointer> #include <QSharedPointer>
#include <qjson/parser.h> #include <qjson/parser.h>
#include <KUrl> #include <KUrl>
#include "kdeconnectcore_export.h"
#include "kdebugnamespace.h" #include "kdebugnamespace.h"
#include "default_args.h" #include "default_args.h"
class FileTransferJob; class FileTransferJob;
class NetworkPackage : public QObject class KDECONNECTCORE_EXPORT NetworkPackage : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY( QString id READ id WRITE setId ) Q_PROPERTY( QString id READ id WRITE setId )

View file

@ -1,37 +1,11 @@
find_package(KDE4 REQUIRED)
find_package(QJSON REQUIRED)
find_package(QCA2 REQUIRED)
include(KDE4Defaults)
include_directories(
${QJSON_INCLUDE_DIR}
${QCA2_INCLUDE_DIR}
${KDE4_INCLUDES}
${CMAKE_SOURCE_DIR}
)
set(kdeconnect_battery_SRCS set(kdeconnect_battery_SRCS
batteryplugin.cpp batteryplugin.cpp
batterydbusinterface.cpp batterydbusinterface.cpp
../kdeconnectplugin.cpp
../pluginloader.cpp
../../networkpackage.cpp
../../filetransferjob.cpp
../../device.cpp
../../kdebugnamespace.cpp
) )
kde4_add_plugin(kdeconnect_battery ${kdeconnect_battery_SRCS}) kde4_add_plugin(kdeconnect_battery ${kdeconnect_battery_SRCS})
target_link_libraries(kdeconnect_battery target_link_libraries(kdeconnect_battery kdeconnectcore ${KDE4_KDEUI_LIBS})
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
${QT_QTNETWORK_LIBRARY}
${QJSON_LIBRARIES}
${QCA2_LIBRARIES}
)
install(TARGETS kdeconnect_battery DESTINATION ${PLUGIN_INSTALL_DIR} ) install(TARGETS kdeconnect_battery DESTINATION ${PLUGIN_INSTALL_DIR} )
install(FILES kdeconnect_battery.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) install(FILES kdeconnect_battery.desktop DESTINATION ${SERVICES_INSTALL_DIR} )

View file

@ -1,36 +1,10 @@
find_package(KDE4 REQUIRED)
find_package(QJSON REQUIRED)
find_package(QCA2 REQUIRED)
include(KDE4Defaults)
include_directories(
${QJSON_INCLUDE_DIR}
${QCA2_INCLUDE_DIR}
${KDE4_INCLUDES}
${CMAKE_SOURCE_DIR}
)
set(kdeconnect_clipboard_SRCS set(kdeconnect_clipboard_SRCS
clipboardplugin.cpp clipboardplugin.cpp
../kdeconnectplugin.cpp
../pluginloader.cpp
../../networkpackage.cpp
../../filetransferjob.cpp
../../device.cpp
../../kdebugnamespace.cpp
) )
kde4_add_plugin(kdeconnect_clipboard ${kdeconnect_clipboard_SRCS}) kde4_add_plugin(kdeconnect_clipboard ${kdeconnect_clipboard_SRCS})
target_link_libraries(kdeconnect_clipboard target_link_libraries(kdeconnect_clipboard kdeconnectcore ${QT_QTGUI_LIBRARY})
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
${QT_QTNETWORK_LIBRARY}
${QJSON_LIBRARIES}
${QCA2_LIBRARIES}
)
install(TARGETS kdeconnect_clipboard DESTINATION ${PLUGIN_INSTALL_DIR} ) install(TARGETS kdeconnect_clipboard DESTINATION ${PLUGIN_INSTALL_DIR} )
install(FILES kdeconnect_clipboard.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) install(FILES kdeconnect_clipboard.desktop DESTINATION ${SERVICES_INSTALL_DIR} )

View file

@ -28,6 +28,10 @@ KdeConnectPlugin::KdeConnectPlugin(QObject* parent, const QVariantList& args)
mDevice = qvariant_cast< Device* >(args.first()); mDevice = qvariant_cast< Device* >(args.first());
} }
KdeConnectPlugin::~KdeConnectPlugin()
{
}
Device* KdeConnectPlugin::device() Device* KdeConnectPlugin::device()
{ {
return mDevice; return mDevice;

View file

@ -38,6 +38,8 @@ class KDE_EXPORT KdeConnectPlugin
public: public:
KdeConnectPlugin(QObject* parent, const QVariantList& args); KdeConnectPlugin(QObject* parent, const QVariantList& args);
virtual ~KdeConnectPlugin();
Device* device(); Device* device();
Device const* device() const; Device const* device() const;

View file

@ -1,24 +1,5 @@
find_package(KDE4 REQUIRED)
find_package(QJSON REQUIRED)
find_package(QCA2 REQUIRED)
include(KDE4Defaults)
include_directories(
${QJSON_INCLUDE_DIR}
${QCA2_INCLUDE_DIR}
${KDE4_INCLUDES}
${CMAKE_SOURCE_DIR}
)
set(kdeconnect_mpriscontrol_SRCS set(kdeconnect_mpriscontrol_SRCS
mpriscontrolplugin.cpp mpriscontrolplugin.cpp
../kdeconnectplugin.cpp
../pluginloader.cpp
../../networkpackage.cpp
../../filetransferjob.cpp
../../device.cpp
../../kdebugnamespace.cpp
) )
qt4_add_dbus_interface( qt4_add_dbus_interface(
@ -35,14 +16,7 @@ qt4_add_dbus_interface(
kde4_add_plugin(kdeconnect_mpriscontrol ${kdeconnect_mpriscontrol_SRCS}) kde4_add_plugin(kdeconnect_mpriscontrol ${kdeconnect_mpriscontrol_SRCS})
target_link_libraries(kdeconnect_mpriscontrol target_link_libraries(kdeconnect_mpriscontrol kdeconnectcore)
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
${QT_QTNETWORK_LIBRARY}
${QJSON_LIBRARIES}
${QCA2_LIBRARIES}
)
install(TARGETS kdeconnect_mpriscontrol DESTINATION ${PLUGIN_INSTALL_DIR} ) install(TARGETS kdeconnect_mpriscontrol DESTINATION ${PLUGIN_INSTALL_DIR} )
install(FILES kdeconnect_mpriscontrol.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) install(FILES kdeconnect_mpriscontrol.desktop DESTINATION ${SERVICES_INSTALL_DIR} )

View file

@ -1,38 +1,12 @@
find_package(KDE4 REQUIRED)
find_package(QJSON REQUIRED)
find_package(QCA2 REQUIRED)
include(KDE4Defaults)
include_directories(
${QJSON_INCLUDE_DIR}
${QCA2_INCLUDE_DIR}
${KDE4_INCLUDES}
${CMAKE_SOURCE_DIR}
)
set(kdeconnect_notifications_SRCS set(kdeconnect_notifications_SRCS
notification.cpp notification.cpp
notificationsplugin.cpp notificationsplugin.cpp
notificationsdbusinterface.cpp notificationsdbusinterface.cpp
../kdeconnectplugin.cpp
../pluginloader.cpp
../../networkpackage.cpp
../../filetransferjob.cpp
../../device.cpp
../../kdebugnamespace.cpp
) )
kde4_add_plugin(kdeconnect_notifications ${kdeconnect_notifications_SRCS}) kde4_add_plugin(kdeconnect_notifications ${kdeconnect_notifications_SRCS})
target_link_libraries(kdeconnect_notifications target_link_libraries(kdeconnect_notifications kdeconnectcore ${KDE4_KDEUI_LIBS})
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
${QT_QTNETWORK_LIBRARY}
${QJSON_LIBRARIES}
${QCA2_LIBRARIES}
)
install(TARGETS kdeconnect_notifications DESTINATION ${PLUGIN_INSTALL_DIR} ) install(TARGETS kdeconnect_notifications DESTINATION ${PLUGIN_INSTALL_DIR} )
install(FILES kdeconnect_notifications.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) install(FILES kdeconnect_notifications.desktop DESTINATION ${SERVICES_INSTALL_DIR} )

View file

@ -1,16 +1,3 @@
find_package(KDE4 REQUIRED)
find_package(QJSON REQUIRED)
find_package(QCA2 REQUIRED)
include(KDE4Defaults)
include_directories(
${QJSON_INCLUDE_DIR}
${QCA2_INCLUDE_DIR}
${KDE4_INCLUDES}
${CMAKE_SOURCE_DIR}
)
set(kdeconnect_pausemusic_SRCS set(kdeconnect_pausemusic_SRCS
pausemusicplugin.cpp pausemusicplugin.cpp
../kdeconnectplugin.cpp ../kdeconnectplugin.cpp

View file

@ -1,31 +1,10 @@
find_package(KDE4 REQUIRED)
find_package(QJSON REQUIRED)
find_package(QCA2 REQUIRED)
include(KDE4Defaults)
include_directories(
${QJSON_INCLUDE_DIR}
${QCA2_INCLUDE_DIR}
${KDE4_INCLUDES}
${CMAKE_SOURCE_DIR}
)
set(kdeconnect_ping_SRCS set(kdeconnect_ping_SRCS
pingplugin.cpp pingplugin.cpp
../kdeconnectplugin.cpp
../../kdebugnamespace.cpp
) )
kde4_add_plugin(kdeconnect_ping ${kdeconnect_ping_SRCS}) kde4_add_plugin(kdeconnect_ping ${kdeconnect_ping_SRCS})
target_link_libraries(kdeconnect_ping target_link_libraries(kdeconnect_ping kdeconnectcore ${KDE4_KDEUI_LIBS})
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${QT_QTNETWORK_LIBRARY}
${QJSON_LIBRARIES}
${QCA2_LIBRARIES}
)
install(TARGETS kdeconnect_ping DESTINATION ${PLUGIN_INSTALL_DIR} ) install(TARGETS kdeconnect_ping DESTINATION ${PLUGIN_INSTALL_DIR} )
install(FILES kdeconnect_ping.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) install(FILES kdeconnect_ping.desktop DESTINATION ${SERVICES_INSTALL_DIR} )

View file

@ -1,39 +1,12 @@
find_package(KDE4 REQUIRED)
find_package(QJSON REQUIRED)
find_package(QCA2 REQUIRED)
include(KDE4Defaults)
include_directories(
${QJSON_INCLUDE_DIR}
${QCA2_INCLUDE_DIR}
${KDE4_INCLUDES}
${CMAKE_SOURCE_DIR}
)
set(kdeconnect_sftp_SRCS set(kdeconnect_sftp_SRCS
mounter.cpp mounter.cpp
mountloop.cpp mountloop.cpp
sftpplugin.cpp sftpplugin.cpp
../kdeconnectplugin.cpp
../pluginloader.cpp
../../networkpackage.cpp
../../filetransferjob.cpp
../../device.cpp
../../kdebugnamespace.cpp
) )
kde4_add_plugin(kdeconnect_sftp ${kdeconnect_sftp_SRCS}) kde4_add_plugin(kdeconnect_sftp ${kdeconnect_sftp_SRCS})
target_link_libraries(kdeconnect_sftp target_link_libraries(kdeconnect_sftp kdeconnectcore ${KDE4_KFILE_LIBS})
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
${KDE4_KFILE_LIBS}
${QT_QTNETWORK_LIBRARY}
${QJSON_LIBRARIES}
${QCA2_LIBRARIES}
)
install(TARGETS kdeconnect_sftp DESTINATION ${PLUGIN_INSTALL_DIR} ) install(TARGETS kdeconnect_sftp DESTINATION ${PLUGIN_INSTALL_DIR} )
install(FILES kdeconnect_sftp.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) install(FILES kdeconnect_sftp.desktop DESTINATION ${SERVICES_INSTALL_DIR} )

View file

@ -1,37 +1,11 @@
find_package(KDE4 REQUIRED)
find_package(QJSON REQUIRED)
find_package(QCA2 REQUIRED)
include(KDE4Defaults)
include_directories(
${QJSON_INCLUDE_DIR}
${QCA2_INCLUDE_DIR}
${KDE4_INCLUDES}
${CMAKE_SOURCE_DIR}
)
set(kdeconnect_share_SRCS set(kdeconnect_share_SRCS
shareplugin.cpp shareplugin.cpp
autoclosingqfile.cpp autoclosingqfile.cpp
../kdeconnectplugin.cpp
../pluginloader.cpp
../../filetransferjob.cpp
../../networkpackage.cpp
../../device.cpp
../../kdebugnamespace.cpp
) )
kde4_add_plugin(kdeconnect_share ${kdeconnect_share_SRCS}) kde4_add_plugin(kdeconnect_share ${kdeconnect_share_SRCS})
target_link_libraries(kdeconnect_share target_link_libraries(kdeconnect_share kdeconnectcore ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS})
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
${QT_QTNETWORK_LIBRARY}
${QJSON_LIBRARIES}
${QCA2_LIBRARIES}
)
install(TARGETS kdeconnect_share DESTINATION ${PLUGIN_INSTALL_DIR} ) install(TARGETS kdeconnect_share DESTINATION ${PLUGIN_INSTALL_DIR} )
install(FILES kdeconnect_share.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) install(FILES kdeconnect_share.desktop DESTINATION ${SERVICES_INSTALL_DIR} )

View file

@ -1,30 +1,10 @@
find_package(KDE4 REQUIRED)
find_package(QJSON REQUIRED)
find_package(QCA2 REQUIRED)
include_directories(
${QJSON_INCLUDE_DIR}
${QCA2_INCLUDE_DIR}
)
include(KDE4Defaults)
include_directories(${KDE4_INCLUDES})
set(kdeconnect_telephony_SRCS set(kdeconnect_telephony_SRCS
telephonyplugin.cpp telephonyplugin.cpp
../kdeconnectplugin.cpp
../../kdebugnamespace.cpp
) )
kde4_add_plugin(kdeconnect_telephony ${kdeconnect_telephony_SRCS}) kde4_add_plugin(kdeconnect_telephony ${kdeconnect_telephony_SRCS})
target_link_libraries(kdeconnect_telephony target_link_libraries(kdeconnect_telephony kdeconnectcore ${KDE4_KDEUI_LIBS})
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${QT_QTNETWORK_LIBRARY}
${QJSON_LIBRARIES}
${QCA2_LIBRARIES}
)
install(TARGETS kdeconnect_telephony DESTINATION ${PLUGIN_INSTALL_DIR} ) install(TARGETS kdeconnect_telephony DESTINATION ${PLUGIN_INSTALL_DIR} )
install(FILES kdeconnect_telephony.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) install(FILES kdeconnect_telephony.desktop DESTINATION ${SERVICES_INSTALL_DIR} )

View file

@ -1,16 +1,8 @@
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
include(KDE4Defaults)
find_package(KDE4 REQUIRED)
find_package(QJSON 0.8.1 REQUIRED)
find_package(QCA2 REQUIRED)
include_directories( include_directories(
${QJSON_INCLUDE_DIR} ${QJSON_INCLUDE_DIR}
${QCA2_INCLUDE_DIR} ${QCA2_INCLUDE_DIR}
${KDE4_INCLUDES} ${KDE4_INCLUDES}
${CMAKE_SOURCE_DIR} ${KDEConnectCore_BINARY_DIR}
) )
set(kdeconnect_libraries set(kdeconnect_libraries
@ -21,15 +13,13 @@ set(kdeconnect_libraries
${QJSON_LIBRARIES} ${QJSON_LIBRARIES}
${QCA2_LIBRARIES} ${QCA2_LIBRARIES}
${QT_QTTEST_LIBRARY} ${QT_QTTEST_LIBRARY}
kdeconnectcore
) )
#NetworkPackage #NetworkPackage
kde4_add_unit_test(kdeconnect_tests ../kded/networkpackage.cpp ../kded/kdebugnamespace.cpp ../kded/filetransferjob.cpp networkpackagetests.cpp) kde4_add_unit_test(kdeconnect_tests networkpackagetests.cpp)
target_link_libraries(kdeconnect_tests ${kdeconnect_libraries}) target_link_libraries(kdeconnect_tests ${kdeconnect_libraries})
#Socketlinereader #Socketlinereader
set(_testname testsocketlinereader) kde4_add_unit_test(testsocketlinereader testsocketlinereader.cpp ../kded/backends/lan/socketlinereader.cpp)
qt4_generate_moc(${_testname}.cpp ${CMAKE_CURRENT_BINARY_DIR}/${_testname}.moc) target_link_libraries(testsocketlinereader ${kdeconnect_libraries})
include_directories(${QT_INCLUDES} ${KDE4_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
kde4_add_unit_test(${_testname} ${_testname}.cpp ${_testname}.moc ../kded/backends/lan/socketlinereader.cpp ../kded/kdebugnamespace.cpp)
target_link_libraries(${_testname} ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY})