From a340be767da2764953e90c380ffa2936697c39d7 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Sat, 24 Aug 2013 14:19:24 +0200 Subject: [PATCH] Move Playdar API into its own library --- CMakeLists.txt | 1 + TomahawkAddLibrary.cmake | 5 ++- src/CMakeLists.txt | 1 + .../web => libtomahawk-playdarapi}/Api_v1.cpp | 0 .../web => libtomahawk-playdarapi}/Api_v1.h | 4 ++- src/libtomahawk-playdarapi/CMakeLists.txt | 20 +++++++++++ .../PlaydarAPIDllMacro.h | 33 +++++++++++++++++++ src/tomahawk/CMakeLists.txt | 9 ++--- src/tomahawk/TomahawkApp.cpp | 2 +- 9 files changed, 66 insertions(+), 9 deletions(-) rename src/{tomahawk/web => libtomahawk-playdarapi}/Api_v1.cpp (100%) rename src/{tomahawk/web => libtomahawk-playdarapi}/Api_v1.h (96%) create mode 100644 src/libtomahawk-playdarapi/CMakeLists.txt create mode 100644 src/libtomahawk-playdarapi/PlaydarAPIDllMacro.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f345519d..27cb3ce8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -356,6 +356,7 @@ file(COPY TomahawkAddLibrary.cmake DESTINATION "${PROJECT_BINARY_DIR}") SET( TOMAHAWK_LIBRARIES tomahawklib ) SET( TOMAHAWK_WIDGETS_LIBRARIES tomahawk-widgets ) +SET( TOMAHAWK_PLAYDARAPI_LIBRARIES tomahawk-playdarapi ) ADD_SUBDIRECTORY( thirdparty ) ADD_SUBDIRECTORY( src ) diff --git a/TomahawkAddLibrary.cmake b/TomahawkAddLibrary.cmake index f8c551236..274f82059 100644 --- a/TomahawkAddLibrary.cmake +++ b/TomahawkAddLibrary.cmake @@ -5,7 +5,7 @@ function(tomahawk_add_library) set(NAME ${ARGV0}) set(options NO_INSTALL NO_VERSION) set(oneValueArgs NAME TYPE EXPORT_MACRO TARGET TARGET_TYPE EXPORT VERSION SOVERSION INSTALL_BINDIR) - set(multiValueArgs SOURCES UI LINK_LIBRARIES COMPILE_DEFINITIONS QT5_MODULES) + set(multiValueArgs SOURCES UI LINK_LIBRARIES LINK_PRIVATE_LIBRARIES COMPILE_DEFINITIONS QT5_MODULES) cmake_parse_arguments(LIBRARY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) set(LIBRARY_NAME ${NAME}) @@ -71,6 +71,9 @@ function(tomahawk_add_library) if(LIBRARY_LINK_LIBRARIES) target_link_libraries(${target} ${LIBRARY_LINK_LIBRARIES}) endif() + if(LIBRARY_LINK_PRIVATE_LIBRARIES) + target_link_libraries(${target} LINK_PRIVATE ${LIBRARY_LINK_PRIVATE_LIBRARIES}) + endif() # add soversion if(NOT LIBRARY_NO_VERSION) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 18fd51f8e..2373c4b8f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,6 +11,7 @@ include_directories( ${CMAKE_CURRENT_LIST_DIR} ) # library add_subdirectory( libtomahawk ) add_subdirectory( libtomahawk-widgets ) +add_subdirectory( libtomahawk-playdarapi ) # plugins add_subdirectory( accounts ) diff --git a/src/tomahawk/web/Api_v1.cpp b/src/libtomahawk-playdarapi/Api_v1.cpp similarity index 100% rename from src/tomahawk/web/Api_v1.cpp rename to src/libtomahawk-playdarapi/Api_v1.cpp diff --git a/src/tomahawk/web/Api_v1.h b/src/libtomahawk-playdarapi/Api_v1.h similarity index 96% rename from src/tomahawk/web/Api_v1.h rename to src/libtomahawk-playdarapi/Api_v1.h index a8f4a6c8a..87f3d2989 100644 --- a/src/tomahawk/web/Api_v1.h +++ b/src/libtomahawk-playdarapi/Api_v1.h @@ -23,6 +23,8 @@ // See: http://doc.libqxt.org/tip/qxtweb.html +#include "PlaydarAPIDllMacro.h" + #include #include #include @@ -43,7 +45,7 @@ namespace Tomahawk typedef QSharedPointer< Result > result_ptr; } -class Api_v1 : public QxtWebSlotService +class TOMAHAWK_PLAYDARAPI_EXPORT Api_v1 : public QxtWebSlotService { Q_OBJECT diff --git a/src/libtomahawk-playdarapi/CMakeLists.txt b/src/libtomahawk-playdarapi/CMakeLists.txt new file mode 100644 index 000000000..c289f406a --- /dev/null +++ b/src/libtomahawk-playdarapi/CMakeLists.txt @@ -0,0 +1,20 @@ + +set(TOMAHAWK_PLAYDARAPI_LIBRARY_TARGET tomahawk-playdarapi) + +list(APPEND ${TOMAHAWK_PLAYDARAPI_LIBRARY_TARGET}_SOURCES + Api_v1.cpp + ) + +list(APPEND ${TOMAHAWK_PLAYDARAPI_LIBRARY_TARGET}_UI + ) + +include_directories(${QXTWEB_INCLUDE_DIRS}) + +tomahawk_add_library(${TOMAHAWK_PLAYDARAPI_LIBRARY_TARGET} + SOURCES ${${TOMAHAWK_PLAYDARAPI_LIBRARY_TARGET}_SOURCES} + UI ${${TOMAHAWK_PLAYDARAPI_LIBRARY_TARGET}_UI} + LINK_PRIVATE_LIBRARIES ${QXTWEB_LIBRARIES} + EXPORT TomahawkLibraryDepends + VERSION ${TOMAHAWK_VERSION_SHORT} + ) + diff --git a/src/libtomahawk-playdarapi/PlaydarAPIDllMacro.h b/src/libtomahawk-playdarapi/PlaydarAPIDllMacro.h new file mode 100644 index 000000000..b72aaa85c --- /dev/null +++ b/src/libtomahawk-playdarapi/PlaydarAPIDllMacro.h @@ -0,0 +1,33 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2010-2011, Christian Muehlhaeuser + * Copyright 2010-2011, Jeff Mitchell + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#ifndef PLAYDARAPIDLLMACRO_H +#define PLAYDARAPISDLLMACRO_H + +#include + +#ifndef TOMAHAWK_PLAYDARAPI_EXPORT +# if defined (tomahawk_playdarapi_EXPORTS) +# define TOMAHAWK_PLAYDARAPI_EXPORT Q_DECL_EXPORT +# else +# define TOMAHAWK_PLAYDARAPI_EXPORT Q_DECL_IMPORT +# endif +#endif + +#endif // PLAYDARAPIDLLMACRO_H diff --git a/src/tomahawk/CMakeLists.txt b/src/tomahawk/CMakeLists.txt index fe82e5ffe..1256db3b8 100644 --- a/src/tomahawk/CMakeLists.txt +++ b/src/tomahawk/CMakeLists.txt @@ -97,6 +97,7 @@ INCLUDE_DIRECTORIES( ${THIRDPARTY_DIR}/breakpad + ${QXTWEB_INCLUDE_DIRS} ${TAGLIB_INCLUDES} ${QJSON_INCLUDE_DIR} ${LIBATTICA_INCLUDE_DIR} @@ -105,12 +106,6 @@ INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} ) -IF( QXTWEB_FOUND ) - LIST(APPEND tomahawkSources web/Api_v1.cpp) - LIST(APPEND LINK_LIBRARIES ${QXTWEB_LIBRARIES}) - INCLUDE_DIRECTORIES(${QXTWEB_INCLUDE_DIRS}) -ENDIF() - SET( OS_SPECIFIC_LINK_LIBRARIES "" ) IF( WIN32 ) @@ -183,11 +178,13 @@ ENDIF() TARGET_LINK_LIBRARIES( tomahawk_bin ${LINK_LIBRARIES} ${TOMAHAWK_WIDGETS_LIBRARIES} + ${TOMAHAWK_PLAYDARAPI_LIBRARIES} ${TOMAHAWK_LIBRARIES} ${OS_SPECIFIC_LINK_LIBRARIES} ${QT_LIBRARIES} ${MAC_EXTRA_LIBS} ${ECHONEST_LIBRARIES} + ${QXTWEB_LIBRARIES} ${QJSON_LIBRARIES} ${TAGLIB_LIBRARIES} ) diff --git a/src/tomahawk/TomahawkApp.cpp b/src/tomahawk/TomahawkApp.cpp index d7a9d9db8..a351f7922 100644 --- a/src/tomahawk/TomahawkApp.cpp +++ b/src/tomahawk/TomahawkApp.cpp @@ -37,7 +37,6 @@ #include "playlist/XspfUpdater.h" #include "network/Servent.h" #include "network/DbSyncConnection.h" -#include "web/Api_v1.h" #include "SourceList.h" #include "ViewManager.h" #include "ShortcutHandler.h" @@ -65,6 +64,7 @@ #include "jobview/ErrorStatusMessage.h" #include "jobview/JobStatusModel.h" #include "jobview/JobStatusView.h" +#include "libtomahawk-playdarapi/Api_v1.h" #include "utils/XspfLoader.h" #include "utils/JspfLoader.h" #include "utils/Logger.h"