From 5c9d3a9d428eea9a5c5def44ee45a5ad965c19b5 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Sat, 14 Jun 2014 14:31:31 +0200 Subject: [PATCH] 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 --- CMakeLists.txt | 3 +++ kded/CMakeLists.txt | 23 +++++++++++------- kded/daemon.h | 3 ++- kded/device.h | 2 +- kded/kdebugnamespace.h | 2 +- kded/networkpackage.h | 4 ++-- kded/plugins/battery/CMakeLists.txt | 28 +--------------------- kded/plugins/clipboard/CMakeLists.txt | 28 +--------------------- kded/plugins/kdeconnectplugin.cpp | 4 ++++ kded/plugins/kdeconnectplugin.h | 2 ++ kded/plugins/mpriscontrol/CMakeLists.txt | 28 +--------------------- kded/plugins/notifications/CMakeLists.txt | 28 +--------------------- kded/plugins/pausemusic/CMakeLists.txt | 13 ---------- kded/plugins/ping/CMakeLists.txt | 23 +----------------- kded/plugins/sftp/CMakeLists.txt | 29 +---------------------- kded/plugins/share/CMakeLists.txt | 28 +--------------------- kded/plugins/telephony/CMakeLists.txt | 22 +---------------- tests/CMakeLists.txt | 20 ++++------------ 18 files changed, 42 insertions(+), 248 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd7c82d07..151375e96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,11 +3,14 @@ project(kdeconnect) cmake_minimum_required(VERSION 2.6) find_package(KDE4 REQUIRED) +find_package(QJSON REQUIRED) +find_package(QCA2 REQUIRED) #if(CMAKE_COMPILER_IS_GNUCXX) # add_definitions(-std=gnu++0x) #endif() +include(GenerateExportHeader) include(KDE4Defaults) include_directories(${KDE4_INCLUDES}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/kded/CMakeLists.txt b/kded/CMakeLists.txt index 4317e7449..5904ffd85 100644 --- a/kded/CMakeLists.txt +++ b/kded/CMakeLists.txt @@ -1,14 +1,14 @@ -add_subdirectory(plugins) - -find_package (QJSON 0.8.1 REQUIRED) -find_package (QCA2 REQUIRED) +project(KDEConnectCore) include_directories( ${KDE4_KIO_LIBS} ${QJSON_INCLUDE_DIR} ${QCA2_INCLUDE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} ) +add_subdirectory(plugins) + add_subdirectory(backends/lan) add_subdirectory(backends/loopback) @@ -28,16 +28,21 @@ set(kded_kdeconnect_SRCS kdebugnamespace.cpp ) -kde4_add_executable(kdeconnectd kdeconnectd.cpp ${kded_kdeconnect_SRCS}) - -target_link_libraries(kdeconnectd +kde4_add_library(kdeconnectcore SHARED ${kded_kdeconnect_SRCS}) +target_link_libraries(kdeconnectcore +PUBLIC ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} + +PRIVATE ${KDE4_KIO_LIBS} - ${QT_QTNETWORK_LIBRARY} ${QJSON_LIBRARIES} + ${QT_QTNETWORK_LIBRARY} ${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) diff --git a/kded/daemon.h b/kded/daemon.h index 686c393c1..c7a394ca6 100644 --- a/kded/daemon.h +++ b/kded/daemon.h @@ -28,13 +28,14 @@ #include #include +#include "kdeconnectcore_export.h" #include "device.h" #include "networkpackage.h" #include "backends/devicelink.h" #include "backends/linkprovider.h" -class Daemon +class KDECONNECTCORE_EXPORT Daemon : public QObject { Q_OBJECT diff --git a/kded/device.h b/kded/device.h index 3f97b1956..7ebb5afbb 100644 --- a/kded/device.h +++ b/kded/device.h @@ -33,7 +33,7 @@ class DeviceLink; class KdeConnectPlugin; -class Device +class KDECONNECTCORE_EXPORT Device : public QObject { Q_OBJECT diff --git a/kded/kdebugnamespace.h b/kded/kdebugnamespace.h index 4b23d6683..60c733dab 100644 --- a/kded/kdebugnamespace.h +++ b/kded/kdebugnamespace.h @@ -23,7 +23,7 @@ #include -int kdeconnect_kded(); +KDE_EXPORT int kdeconnect_kded(); #endif diff --git a/kded/networkpackage.h b/kded/networkpackage.h index 14c5cc43c..ed26676de 100644 --- a/kded/networkpackage.h +++ b/kded/networkpackage.h @@ -31,15 +31,15 @@ #include #include #include - #include +#include "kdeconnectcore_export.h" #include "kdebugnamespace.h" #include "default_args.h" class FileTransferJob; -class NetworkPackage : public QObject +class KDECONNECTCORE_EXPORT NetworkPackage : public QObject { Q_OBJECT Q_PROPERTY( QString id READ id WRITE setId ) diff --git a/kded/plugins/battery/CMakeLists.txt b/kded/plugins/battery/CMakeLists.txt index d623141ef..482d0aa62 100644 --- a/kded/plugins/battery/CMakeLists.txt +++ b/kded/plugins/battery/CMakeLists.txt @@ -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 batteryplugin.cpp batterydbusinterface.cpp - ../kdeconnectplugin.cpp - ../pluginloader.cpp - ../../networkpackage.cpp - ../../filetransferjob.cpp - ../../device.cpp - ../../kdebugnamespace.cpp ) kde4_add_plugin(kdeconnect_battery ${kdeconnect_battery_SRCS}) -target_link_libraries(kdeconnect_battery - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${QT_QTNETWORK_LIBRARY} - ${QJSON_LIBRARIES} - ${QCA2_LIBRARIES} -) +target_link_libraries(kdeconnect_battery kdeconnectcore ${KDE4_KDEUI_LIBS}) install(TARGETS kdeconnect_battery DESTINATION ${PLUGIN_INSTALL_DIR} ) install(FILES kdeconnect_battery.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/kded/plugins/clipboard/CMakeLists.txt b/kded/plugins/clipboard/CMakeLists.txt index 426cfef2c..b6624a03c 100644 --- a/kded/plugins/clipboard/CMakeLists.txt +++ b/kded/plugins/clipboard/CMakeLists.txt @@ -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 clipboardplugin.cpp - ../kdeconnectplugin.cpp - ../pluginloader.cpp - ../../networkpackage.cpp - ../../filetransferjob.cpp - ../../device.cpp - ../../kdebugnamespace.cpp ) kde4_add_plugin(kdeconnect_clipboard ${kdeconnect_clipboard_SRCS}) -target_link_libraries(kdeconnect_clipboard - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${QT_QTNETWORK_LIBRARY} - ${QJSON_LIBRARIES} - ${QCA2_LIBRARIES} -) +target_link_libraries(kdeconnect_clipboard kdeconnectcore ${QT_QTGUI_LIBRARY}) install(TARGETS kdeconnect_clipboard DESTINATION ${PLUGIN_INSTALL_DIR} ) install(FILES kdeconnect_clipboard.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/kded/plugins/kdeconnectplugin.cpp b/kded/plugins/kdeconnectplugin.cpp index 4971c4992..d73fb20b3 100644 --- a/kded/plugins/kdeconnectplugin.cpp +++ b/kded/plugins/kdeconnectplugin.cpp @@ -28,6 +28,10 @@ KdeConnectPlugin::KdeConnectPlugin(QObject* parent, const QVariantList& args) mDevice = qvariant_cast< Device* >(args.first()); } +KdeConnectPlugin::~KdeConnectPlugin() +{ +} + Device* KdeConnectPlugin::device() { return mDevice; diff --git a/kded/plugins/kdeconnectplugin.h b/kded/plugins/kdeconnectplugin.h index e8ff01777..d17f3dfe6 100644 --- a/kded/plugins/kdeconnectplugin.h +++ b/kded/plugins/kdeconnectplugin.h @@ -38,6 +38,8 @@ class KDE_EXPORT KdeConnectPlugin public: KdeConnectPlugin(QObject* parent, const QVariantList& args); + virtual ~KdeConnectPlugin(); + Device* device(); Device const* device() const; diff --git a/kded/plugins/mpriscontrol/CMakeLists.txt b/kded/plugins/mpriscontrol/CMakeLists.txt index dd2a2a3e1..d5332fab6 100644 --- a/kded/plugins/mpriscontrol/CMakeLists.txt +++ b/kded/plugins/mpriscontrol/CMakeLists.txt @@ -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 mpriscontrolplugin.cpp - ../kdeconnectplugin.cpp - ../pluginloader.cpp - ../../networkpackage.cpp - ../../filetransferjob.cpp - ../../device.cpp - ../../kdebugnamespace.cpp ) qt4_add_dbus_interface( @@ -35,14 +16,7 @@ qt4_add_dbus_interface( kde4_add_plugin(kdeconnect_mpriscontrol ${kdeconnect_mpriscontrol_SRCS}) -target_link_libraries(kdeconnect_mpriscontrol - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${QT_QTNETWORK_LIBRARY} - ${QJSON_LIBRARIES} - ${QCA2_LIBRARIES} -) +target_link_libraries(kdeconnect_mpriscontrol kdeconnectcore) install(TARGETS kdeconnect_mpriscontrol DESTINATION ${PLUGIN_INSTALL_DIR} ) install(FILES kdeconnect_mpriscontrol.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/kded/plugins/notifications/CMakeLists.txt b/kded/plugins/notifications/CMakeLists.txt index a6ed32a60..97d95eed6 100644 --- a/kded/plugins/notifications/CMakeLists.txt +++ b/kded/plugins/notifications/CMakeLists.txt @@ -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 notification.cpp notificationsplugin.cpp notificationsdbusinterface.cpp - ../kdeconnectplugin.cpp - ../pluginloader.cpp - ../../networkpackage.cpp - ../../filetransferjob.cpp - ../../device.cpp - ../../kdebugnamespace.cpp ) kde4_add_plugin(kdeconnect_notifications ${kdeconnect_notifications_SRCS}) -target_link_libraries(kdeconnect_notifications - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${QT_QTNETWORK_LIBRARY} - ${QJSON_LIBRARIES} - ${QCA2_LIBRARIES} -) +target_link_libraries(kdeconnect_notifications kdeconnectcore ${KDE4_KDEUI_LIBS}) install(TARGETS kdeconnect_notifications DESTINATION ${PLUGIN_INSTALL_DIR} ) install(FILES kdeconnect_notifications.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/kded/plugins/pausemusic/CMakeLists.txt b/kded/plugins/pausemusic/CMakeLists.txt index dc4927290..c5254222e 100644 --- a/kded/plugins/pausemusic/CMakeLists.txt +++ b/kded/plugins/pausemusic/CMakeLists.txt @@ -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 pausemusicplugin.cpp ../kdeconnectplugin.cpp diff --git a/kded/plugins/ping/CMakeLists.txt b/kded/plugins/ping/CMakeLists.txt index f8093a817..0f6f0ac3e 100644 --- a/kded/plugins/ping/CMakeLists.txt +++ b/kded/plugins/ping/CMakeLists.txt @@ -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 pingplugin.cpp - ../kdeconnectplugin.cpp - ../../kdebugnamespace.cpp ) kde4_add_plugin(kdeconnect_ping ${kdeconnect_ping_SRCS}) -target_link_libraries(kdeconnect_ping - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${QT_QTNETWORK_LIBRARY} - ${QJSON_LIBRARIES} - ${QCA2_LIBRARIES} -) +target_link_libraries(kdeconnect_ping kdeconnectcore ${KDE4_KDEUI_LIBS}) install(TARGETS kdeconnect_ping DESTINATION ${PLUGIN_INSTALL_DIR} ) install(FILES kdeconnect_ping.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/kded/plugins/sftp/CMakeLists.txt b/kded/plugins/sftp/CMakeLists.txt index fa8f082f1..026f4df17 100644 --- a/kded/plugins/sftp/CMakeLists.txt +++ b/kded/plugins/sftp/CMakeLists.txt @@ -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 mounter.cpp mountloop.cpp sftpplugin.cpp - ../kdeconnectplugin.cpp - ../pluginloader.cpp - ../../networkpackage.cpp - ../../filetransferjob.cpp - ../../device.cpp - ../../kdebugnamespace.cpp ) kde4_add_plugin(kdeconnect_sftp ${kdeconnect_sftp_SRCS}) -target_link_libraries(kdeconnect_sftp - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_KFILE_LIBS} - ${QT_QTNETWORK_LIBRARY} - ${QJSON_LIBRARIES} - ${QCA2_LIBRARIES} -) +target_link_libraries(kdeconnect_sftp kdeconnectcore ${KDE4_KFILE_LIBS}) install(TARGETS kdeconnect_sftp DESTINATION ${PLUGIN_INSTALL_DIR} ) install(FILES kdeconnect_sftp.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/kded/plugins/share/CMakeLists.txt b/kded/plugins/share/CMakeLists.txt index ae4e18f63..ab91134c4 100644 --- a/kded/plugins/share/CMakeLists.txt +++ b/kded/plugins/share/CMakeLists.txt @@ -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 shareplugin.cpp autoclosingqfile.cpp - ../kdeconnectplugin.cpp - ../pluginloader.cpp - ../../filetransferjob.cpp - ../../networkpackage.cpp - ../../device.cpp - ../../kdebugnamespace.cpp ) kde4_add_plugin(kdeconnect_share ${kdeconnect_share_SRCS}) -target_link_libraries(kdeconnect_share - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${QT_QTNETWORK_LIBRARY} - ${QJSON_LIBRARIES} - ${QCA2_LIBRARIES} -) +target_link_libraries(kdeconnect_share kdeconnectcore ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS}) install(TARGETS kdeconnect_share DESTINATION ${PLUGIN_INSTALL_DIR} ) install(FILES kdeconnect_share.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/kded/plugins/telephony/CMakeLists.txt b/kded/plugins/telephony/CMakeLists.txt index 2be4afb4e..01b2f9a86 100644 --- a/kded/plugins/telephony/CMakeLists.txt +++ b/kded/plugins/telephony/CMakeLists.txt @@ -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 telephonyplugin.cpp - ../kdeconnectplugin.cpp - ../../kdebugnamespace.cpp ) kde4_add_plugin(kdeconnect_telephony ${kdeconnect_telephony_SRCS}) -target_link_libraries(kdeconnect_telephony - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${QT_QTNETWORK_LIBRARY} - ${QJSON_LIBRARIES} - ${QCA2_LIBRARIES} -) +target_link_libraries(kdeconnect_telephony kdeconnectcore ${KDE4_KDEUI_LIBS}) install(TARGETS kdeconnect_telephony DESTINATION ${PLUGIN_INSTALL_DIR} ) install(FILES kdeconnect_telephony.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 68a8872a1..d6215c582 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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( ${QJSON_INCLUDE_DIR} ${QCA2_INCLUDE_DIR} ${KDE4_INCLUDES} - ${CMAKE_SOURCE_DIR} + ${KDEConnectCore_BINARY_DIR} ) set(kdeconnect_libraries @@ -21,15 +13,13 @@ set(kdeconnect_libraries ${QJSON_LIBRARIES} ${QCA2_LIBRARIES} ${QT_QTTEST_LIBRARY} + kdeconnectcore ) #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}) #Socketlinereader -set(_testname testsocketlinereader) -qt4_generate_moc(${_testname}.cpp ${CMAKE_CURRENT_BINARY_DIR}/${_testname}.moc) -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}) +kde4_add_unit_test(testsocketlinereader testsocketlinereader.cpp ../kded/backends/lan/socketlinereader.cpp) +target_link_libraries(testsocketlinereader ${kdeconnect_libraries})