From 69e9cda5e6a8d1a15ed906b2331e6a84344f5abc Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Fri, 18 Mar 2011 14:45:42 -0400 Subject: [PATCH] fix some cmake stuff. add uninstall support change plugin names, load changed names, don't install static libs, etc --- CMakeLists.txt | 12 ++++++++ cmake_uninstall.cmake.in | 21 ++++++++++++++ src/CMakeLists.txt | 2 ++ src/config.h.in | 1 + src/libtomahawk/CMakeLists.txt | 1 + src/sip/SipHandler.cpp | 11 ++++---- src/sip/jabber/CMakeLists.txt | 6 ++-- src/sip/jreen/CMakeLists.txt | 6 ++-- src/sip/twitter/CMakeLists.txt | 6 ++-- src/sip/zeroconf/CMakeLists.txt | 6 ++-- src/tomahawkapp.cpp | 41 ++-------------------------- thirdparty/libportfwd/CMakeLists.txt | 2 +- thirdparty/rtaudio/CMakeLists.txt | 2 ++ 13 files changed, 59 insertions(+), 58 deletions(-) create mode 100644 cmake_uninstall.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index f77ffc6d9..a9077b33c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,6 +85,18 @@ MESSAGE("add checks for libmad, libvorbis and libflac. Make sure they are instal MESSAGE("") MESSAGE("-----------------------------------------------------------------------------") +SET( INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" ) + +# make uninstall support +CONFIGURE_FILE( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) + +ADD_CUSTOM_TARGET(uninstall + "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") + + IF( NOT APPLE ) # Make linking as strict on linux as it is on osx. Then we don't break linking on mac so often SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-undefined" ) diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in new file mode 100644 index 000000000..df95fb9d8 --- /dev/null +++ b/cmake_uninstall.cmake.in @@ -0,0 +1,21 @@ +IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") +ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + +FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +STRING(REGEX REPLACE "\n" ";" files "${files}") +FOREACH(file ${files}) + MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + IF(EXISTS "$ENV{DESTDIR}${file}") + EXEC_PROGRAM( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + IF(NOT "${rm_retval}" STREQUAL 0) + MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + ENDIF(NOT "${rm_retval}" STREQUAL 0) + ELSE(EXISTS "$ENV{DESTDIR}${file}") + MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") + ENDIF(EXISTS "$ENV{DESTDIR}${file}") +ENDFOREACH(file) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8514f7f8d..b3acb3f05 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -232,6 +232,8 @@ IF( APPLE ) INSTALL(DIRECTORY "${SPARKLE}/Versions/Current/Resources" DESTINATION "${CMAKE_BINARY_DIR}/tomahawk.app/Contents/Frameworks/Sparkle.framework") ENDIF(HAVE_SPARKLE) +ELSEIF( APPLE ) + install( TARGETS tomahawk RUNTIME DESTINATION bin ) ENDIF( APPLE ) INCLUDE( "CPack.txt" ) diff --git a/src/config.h.in b/src/config.h.in index f8246a54d..aece46720 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -17,4 +17,5 @@ #cmakedefine LIBLASTFM_FOUND #cmakedefine GLOOX_FOUND +#cmakedefine INSTALL_PREFIX #endif // CONFIG_H_IN diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index 2104605f0..bdf495524 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -305,6 +305,7 @@ set( libUI ${libUI} ) include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.. .. + ${CMAKE_CURRENT_SOURCE_DIR} ${QT_INCLUDE_DIR} ${LIBECHONEST_INCLUDE_DIR} ${LIBECHONEST_INCLUDE_DIR}/.. diff --git a/src/sip/SipHandler.cpp b/src/sip/SipHandler.cpp index b4f5297a8..c72076746 100644 --- a/src/sip/SipHandler.cpp +++ b/src/sip/SipHandler.cpp @@ -11,6 +11,7 @@ #include "sourcelist.h" #include "tomahawksettings.h" +#include "config.h" SipHandler::SipHandler( QObject* parent ) : QObject( parent ) @@ -60,10 +61,8 @@ SipHandler::findPlugins() } #endif - QDir libDir( appDir ); - libDir.cdUp(); - libDir.cd( "lib" ); - + QDir libDir( CMAKE_INSTALL_PREFIX "/lib" ); + QDir lib64Dir( appDir ); lib64Dir.cdUp(); lib64Dir.cd( "lib64" ); @@ -72,9 +71,9 @@ SipHandler::findPlugins() foreach ( const QDir& pluginDir, pluginDirs ) { qDebug() << "Checking directory for plugins:" << pluginDir; - foreach ( QString fileName, pluginDir.entryList( QDir::Files ) ) + foreach ( QString fileName, pluginDir.entryList( QStringList() << "*tomahawk_sip*.so" << "*tomahawk_sip*.dylib" << "*tomahawk_sip*.dll", QDir::Files ) ) { - if ( fileName.startsWith( "libsip_" ) ) + if ( fileName.startsWith( "libtomahawk_sip" ) ) { const QString path = pluginDir.absoluteFilePath( fileName ); if ( !paths.contains( path ) ) diff --git a/src/sip/jabber/CMakeLists.txt b/src/sip/jabber/CMakeLists.txt index d064a3aeb..1b487cb08 100644 --- a/src/sip/jabber/CMakeLists.txt +++ b/src/sip/jabber/CMakeLists.txt @@ -21,7 +21,7 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} .. ) qt4_wrap_cpp( jabberMoc ${jabberHeaders} ) -add_library( sip_jabber SHARED ${jabberSources} ${jabberMoc} ) +add_library( tomahawk_sipjabber SHARED ${jabberSources} ${jabberMoc} ) IF( WIN32 ) SET( OS_SPECIFIC_LINK_LIBRARIES @@ -32,7 +32,7 @@ SET( OS_SPECIFIC_LINK_LIBRARIES ) ENDIF( WIN32 ) -target_link_libraries( sip_jabber +target_link_libraries( tomahawk_sipjabber ${QT_LIBRARIES} ${GLOOX_LIBRARIES} ${OS_SPECIFIC_LINK_LIBRARIES} @@ -43,4 +43,4 @@ IF( APPLE ) # SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" ) ENDIF( APPLE ) -install( TARGETS sip_jabber DESTINATION lib ) +install( TARGETS tomahawk_sipjabber LIBRARY DESTINATION lib ) diff --git a/src/sip/jreen/CMakeLists.txt b/src/sip/jreen/CMakeLists.txt index 177bb6025..3432152e4 100644 --- a/src/sip/jreen/CMakeLists.txt +++ b/src/sip/jreen/CMakeLists.txt @@ -22,7 +22,7 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} .. ) qt4_wrap_cpp( jabberMoc ${jabberHeaders} ) -add_library( sip_jreen SHARED ${jabberSources} ${jabberMoc} ) +add_library( tomahawk_sipjreen SHARED ${jabberSources} ${jabberMoc} ) IF( WIN32 ) SET( OS_SPECIFIC_LINK_LIBRARIES @@ -33,7 +33,7 @@ SET( OS_SPECIFIC_LINK_LIBRARIES ) ENDIF( WIN32 ) -target_link_libraries( sip_jreen +target_link_libraries( tomahawk_sipjreen ${QT_LIBRARIES} ${LIBJREEN_LIBRARY} ${OS_SPECIFIC_LINK_LIBRARIES} @@ -43,4 +43,4 @@ IF( APPLE ) # SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" ) ENDIF( APPLE ) -install( TARGETS sip_jreen DESTINATION lib ) +install( TARGETS tomahawk_sipjreen LIBRARY DESTINATION lib ) diff --git a/src/sip/twitter/CMakeLists.txt b/src/sip/twitter/CMakeLists.txt index f3bc32bd5..82109f0db 100644 --- a/src/sip/twitter/CMakeLists.txt +++ b/src/sip/twitter/CMakeLists.txt @@ -28,7 +28,7 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} .. qt4_wrap_cpp( twitterMoc ${twitterHeaders} ) qt4_wrap_ui( twitterUI_H ${twitterUI} ) -add_library( sip_twitter SHARED ${twitterUI_H} ${twitterSources} ${twitterMoc} ) +add_library( tomahawk_siptwitter SHARED ${twitterUI_H} ${twitterSources} ${twitterMoc} ) IF( WIN32 ) SET( OS_SPECIFIC_LINK_LIBRARIES @@ -40,7 +40,7 @@ SET( OS_SPECIFIC_LINK_LIBRARIES ) ENDIF( WIN32 ) -target_link_libraries( sip_twitter +target_link_libraries( tomahawk_siptwitter ${QT_LIBRARIES} ${OS_SPECIFIC_LINK_LIBRARIES} tomahawklib @@ -50,4 +50,4 @@ IF( APPLE ) SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" ) ENDIF( APPLE ) -install( TARGETS sip_twitter DESTINATION lib ) +install( TARGETS tomahawk_siptwitter LIBRARY DESTINATION lib ) diff --git a/src/sip/zeroconf/CMakeLists.txt b/src/sip/zeroconf/CMakeLists.txt index e203901cf..e8b7814ad 100644 --- a/src/sip/zeroconf/CMakeLists.txt +++ b/src/sip/zeroconf/CMakeLists.txt @@ -20,7 +20,7 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} .. ) qt4_wrap_cpp( zeroconfMoc ${zeroconfHeaders} ) -add_library( sip_zeroconf SHARED ${zeroconfSources} ${zeroconfMoc} ) +add_library( tomahawk_sipzeroconf SHARED ${zeroconfSources} ${zeroconfMoc} ) IF( WIN32 ) SET( OS_SPECIFIC_LINK_LIBRARIES @@ -31,7 +31,7 @@ SET( OS_SPECIFIC_LINK_LIBRARIES ) ENDIF( WIN32 ) -target_link_libraries( sip_zeroconf +target_link_libraries( tomahawk_sipzeroconf ${QT_LIBRARIES} ${OS_SPECIFIC_LINK_LIBRARIES} tomahawklib @@ -41,4 +41,4 @@ IF( APPLE ) # SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" ) ENDIF( APPLE ) -install( TARGETS sip_zeroconf DESTINATION lib ) +install( TARGETS tomahawk_sipzeroconf LIBRARY DESTINATION lib ) diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp index 4aaafc324..bedf2c0fc 100644 --- a/src/tomahawkapp.cpp +++ b/src/tomahawkapp.cpp @@ -34,6 +34,8 @@ #include "audio/audioengine.h" #include "utils/xspfloader.h" +#include "config.h" + #ifndef TOMAHAWK_HEADLESS #include "tomahawkwindow.h" #include "settingsdialog.h" @@ -253,7 +255,6 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] ) setupPipeline(); qDebug() << "Init Servent."; startServent(); - //loadPlugins(); if( arguments().contains( "--http" ) || TomahawkSettings::instance()->value( "network/http", true ).toBool() ) { @@ -454,44 +455,6 @@ TomahawkApp::startServent() } } - -void -TomahawkApp::loadPlugins() -{ - // look in same dir as executable for plugins - QDir dir( TomahawkApp::instance()->applicationDirPath() ); - QStringList filters; - filters << "*.so" << "*.dll" << "*.dylib"; - - QStringList files = dir.entryList( filters ); - foreach( const QString& filename, files ) - { - qDebug() << "Attempting to load" << QString( "%1/%2" ).arg( dir.absolutePath() ).arg( filename ); - - QPluginLoader loader( dir.absoluteFilePath( filename ) ); - if ( QObject* inst = loader.instance() ) - { - TomahawkPlugin* pluginst = qobject_cast(inst); - if ( !pluginst ) - continue; - - PluginAPI* api = new PluginAPI( Pipeline::instance() ); - TomahawkPlugin* plugin = pluginst->factory( api ); - qDebug() << "Loaded Plugin:" << plugin->name(); - qDebug() << plugin->description(); - m_plugins.append( plugin ); - - // plugins responsibility to register itself as a resolver/collection - // all we need to do is create an instance of it. - } - else - { - qDebug() << "PluginLoader failed to create instance:" << filename << " Err:" << loader.errorString(); - } - } -} - - void TomahawkApp::setupSIP() { diff --git a/thirdparty/libportfwd/CMakeLists.txt b/thirdparty/libportfwd/CMakeLists.txt index ad0799f9f..ac1d881ce 100644 --- a/thirdparty/libportfwd/CMakeLists.txt +++ b/thirdparty/libportfwd/CMakeLists.txt @@ -46,6 +46,6 @@ ENDIF() # ) #TARGET_LINK_LIBRARIES(portfwd-demo portfwd) -INSTALL(TARGETS portfwd ARCHIVE DESTINATION lib) +# INSTALL(TARGETS portfwd ARCHIVE DESTINATION lib) #INSTALL(TARGETS portfwd-demo RUNTIME DESTINATION bin) #INSTALL(DIRECTORY include/portfwd DESTINATION include PATTERN "*~" EXCLUDE) diff --git a/thirdparty/rtaudio/CMakeLists.txt b/thirdparty/rtaudio/CMakeLists.txt index 73bfe84d3..4791afbc9 100644 --- a/thirdparty/rtaudio/CMakeLists.txt +++ b/thirdparty/rtaudio/CMakeLists.txt @@ -38,4 +38,6 @@ target_link_libraries( rtaudio ${AUDIO_LIBS} ) +IF(WIN32) INSTALL(TARGETS rtaudio ARCHIVE DESTINATION lib) +ENDIF() \ No newline at end of file