From 864dc8d09606861ad27022af4b4080373283fe4a Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Sat, 21 May 2011 12:12:07 +0200 Subject: [PATCH] Build portfwd dynamically --- CMakeLists.txt | 9 ++++-- src/libtomahawk/CMakeLists.txt | 4 +-- thirdparty/CMakeLists.txt | 1 - thirdparty/libportfwd/CMakeLists.txt | 22 ++++++++----- .../libportfwd/include/portfwd/portfwd.h | 5 ++- .../include/portfwd/portfwddllmacro.h | 32 +++++++++++++++++++ 6 files changed, 59 insertions(+), 14 deletions(-) create mode 100644 thirdparty/libportfwd/include/portfwd/portfwddllmacro.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ac4066dc1..807e8eb32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ macro_log_feature(TAGLIB_FOUND "TagLib" "Audio Meta-Data Library" "http://develo # this installs headers and such and should really be handled in a separate package by packagers IF( INTERNAL_JREEN ) - ADD_SUBDIRECTORY( thirdparty/jreen ) + ADD_SUBDIRECTORY( ${THIRDPARTY_DIR}/jreen ) SET( LIBJREEN_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/include ) SET( LIBJREEN_LIBRARY jreen ) SET( LIBJREEN_LIBRARIES ${LIBJREEN_LIBRARY} ) @@ -72,7 +72,7 @@ macro_log_feature(LIBJREEN_FOUND "Jreen" "Qt XMPP Library" "http://gitorious.org # this installs headers and such and should really be handled in a separate package by packagers IF( INTERNAL_QTWEETLIB ) - ADD_SUBDIRECTORY( thirdparty/qtweetlib ) + ADD_SUBDIRECTORY( ${THIRDPARTY_DIR}/qtweetlib ) # copy headers to build/QTweetLib so we can use proper includes inside the code FILE( COPY ${CMAKE_SOURCE_DIR}/thirdparty/qtweetlib/QTweetLib/src/ DESTINATION ${CMAKE_BINARY_DIR}/QTweetLib ) SET( QTWEETLIB_INCLUDE_DIR ${CMAKE_BINARY_DIR} ) @@ -85,6 +85,11 @@ ELSE( INTERNAL_QTWEETLIB ) ENDIF( INTERNAL_QTWEETLIB ) macro_log_feature(QTWEETLIB_FOUND "QTweetLib" "Qt Twitter Library" "https://github.com/minimoog/QTweetLib" FALSE "" "QTweetLib is needed for the Twitter SIP plugin. \n\n Use -DINTERNAL_QTWEETLIB=ON to build the git submodule inside Tomahawk \n") +### libportfwd +SET( LIBPORTFWD_INCLUDE_DIR ${THIRDPARTY_DIR}/libportfwd/include ) +SET( LIBPORTFWD_LIBRARY tomahawk_portfwd ) +SET( LIBPORTFWD_LIBRARIES ${LIBPORTFWD_LIBRARY} ) +ADD_SUBDIRECTORY( ${THIRDPARTY_DIR}/libportfwd ) # we need pthreads too find_package(Threads) diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index 9cf59c0d2..9d3518143 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -359,7 +359,7 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/. playlist - ${THIRDPARTY_DIR}/libportfwd/include + ${LIBPORTFWD_INCLUDE_DIR} ${THIRDPARTY_DIR}/qxt/qxtweb-standalone/qxtweb ${THIRDPARTY_DIR}/jdns ${THIRDPARTY_DIR}/jdns/jdns @@ -422,7 +422,7 @@ target_link_libraries( tomahawklib tomahawk_jdns # Thirdparty shipped with tomahawk - portfwd + ${LIBPORTFWD_LIBRARIES} # External deps ${QJSON_LIBRARIES} diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index b9f899e14..815a4f5d5 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -1,4 +1,3 @@ ADD_SUBDIRECTORY( jdns ) -ADD_SUBDIRECTORY( libportfwd ) ADD_SUBDIRECTORY( qxt ) ADD_SUBDIRECTORY( liblastfm2 ) diff --git a/thirdparty/libportfwd/CMakeLists.txt b/thirdparty/libportfwd/CMakeLists.txt index e19485414..05883c8df 100644 --- a/thirdparty/libportfwd/CMakeLists.txt +++ b/thirdparty/libportfwd/CMakeLists.txt @@ -6,9 +6,6 @@ SET(CMAKE_VERBOSE_MAKEFILE ON) SET(MINIUPNP_DIR "third-party/miniupnpc-1.4.20100609/") SET(NATPMP_DIR "third-party/libnatpmp-20100202") -SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") -SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") -SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") ADD_DEFINITIONS(-Wall -O2 -DNDEBUG) IF(WIN32) ADD_DEFINITIONS(-DWIN32 -DMINIUPNP_EXPORTS ) @@ -16,10 +13,11 @@ ELSE() ADD_DEFINITIONS(-fPIC) ENDIF() INCLUDE_DIRECTORIES(${MINIUPNP_DIR} include) - SET( CMAKE_C_FLAGS ${CLEAN_C_FLAGS} ) -ADD_LIBRARY(portfwd STATIC +ADD_DEFINITIONS( -DPORTFWDDLLEXPORT_PRO ) + +ADD_LIBRARY(tomahawk_portfwd SHARED # the needed bits of miniupnpc (no python module, no tests, no cli) ${MINIUPNP_DIR}/connecthostport.c @@ -29,8 +27,8 @@ ADD_LIBRARY(portfwd STATIC ${MINIUPNP_DIR}/miniupnpc.c ${MINIUPNP_DIR}/miniwget.c ${MINIUPNP_DIR}/minixml.c - ${MINIUPNP_DIR}/minixmlvalid.c - ${MINIUPNP_DIR}/upnpc.c + #${MINIUPNP_DIR}/minixmlvalid.c - contains main() like upnp.c, so building a shared lib fails + #${MINIUPNP_DIR}/upnpc.c ${MINIUPNP_DIR}/upnpcommands.c ${MINIUPNP_DIR}/upnperrors.c ${MINIUPNP_DIR}/upnpreplyparse.c @@ -40,9 +38,17 @@ ADD_LIBRARY(portfwd STATIC ) IF(WIN32) - TARGET_LINK_LIBRARIES( portfwd "ws2_32.dll" "iphlpapi.a" ) + TARGET_LINK_LIBRARIES( tomahawk_portfwd "ws2_32.dll" "iphlpapi.a" ) ENDIF() +INSTALL( TARGETS tomahawk_portfwd + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib${LIB_SUFFIX} + ARCHIVE DESTINATION lib${LIB_SUFFIX} + BUNDLE DESTINATION library +) +#INSTALL(FILES include/portfwd/portfwddllmacro.h include/portfwd/portfwd.h DESTINATION include/portfwd) + #ADD_EXECUTABLE(portfwd-demo # src/main.cpp # ) diff --git a/thirdparty/libportfwd/include/portfwd/portfwd.h b/thirdparty/libportfwd/include/portfwd/portfwd.h index e54a00f0b..0b6103192 100644 --- a/thirdparty/libportfwd/include/portfwd/portfwd.h +++ b/thirdparty/libportfwd/include/portfwd/portfwd.h @@ -17,6 +17,9 @@ #ifndef LIBPORTFWD_PORTFWD_H #define LIBPORTFWD_PORTFWD_H true + +#include "portfwddllmacro.h" + #include #include #include @@ -26,7 +29,7 @@ struct UPNPUrls; struct IGDdatas; -class Portfwd +class PORTFWDDLLEXPORT Portfwd { public: Portfwd(); diff --git a/thirdparty/libportfwd/include/portfwd/portfwddllmacro.h b/thirdparty/libportfwd/include/portfwd/portfwddllmacro.h new file mode 100644 index 000000000..7faddc3d3 --- /dev/null +++ b/thirdparty/libportfwd/include/portfwd/portfwddllmacro.h @@ -0,0 +1,32 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2011, Dominik Schmidt + * + * 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 PORTFWDDLLMACRO_H +#define PORTFWDDLLMACRO_H + +#include + +#ifndef PORTFWDDLLEXPORT +# if defined (PORTFWDDLLEXPORT_PRO) +# define PORTFWDDLLEXPORT Q_DECL_EXPORT +# else +# define PORTFWDDLLEXPORT Q_DECL_IMPORT +# endif +#endif + +#endif \ No newline at end of file