diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d2c3a428f..9314f2392a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,274 +1,277 @@ cmake_minimum_required(VERSION 3.4) project(Amarok) # Remove all warnings, ease the porting to cmake 3.x if (POLICY CMP0028) cmake_policy(SET CMP0028 NEW) endif() ############### find_package(PkgConfig REQUIRED) find_package(ECM 1.7.0 REQUIRED CONFIG) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH}) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(FeatureSummary) include(ECMInstallIcons) include(ECMSetupVersion) include(ECMAddTests) include(ECMAddAppIcon) include(FindPkgConfig) find_package( Qt5 5.8.0 REQUIRED COMPONENTS Core DBus Gui QuickWidgets Qml Script ScriptTools Sql Svg Test Widgets Xml ) find_package( Qt5 5.8.0 COMPONENTS QuickControls2 ) set_package_properties( Qt5QuickControls2 PROPERTIES TYPE RUNTIME PURPOSE "Needed by the player's context area" ) find_package( KF5 REQUIRED COMPONENTS Archive Codecs CoreAddons DBusAddons Declarative DNSSD GlobalAccel GuiAddons I18n IconThemes KCMUtils KIO NewStuff Notifications NotifyConfig Package Solid TextEditor ThreadWeaver WindowSystem ) find_package( KF5 COMPONENTS Kirigami2 ) set_package_properties( KF5Kirigami2 PROPERTIES TYPE RUNTIME PURPOSE "Needed by the player's context area" ) ############### option(WITH_UTILITIES "Enable building of utilities" ON) option(WITH_PLAYER "Enable building of main Amarok player" ON) option(WITH_MP3Tunes "Enable mp3tunes in the Amarok player, requires multiple extra dependencies" ON) option(WITH_IPOD "Enable iPod support in Amarok" ON) option(WITH_MYSQL_EMBEDDED "Build the embedded database library -- highly recommended" ON) option(WITH_PLAYGROUND "Enable building of playground scripts and applets (WARNING: some of them might have legal issues!)" OFF) ############### Taglib set(TAGLIB_MIN_VERSION "1.7") find_package(Taglib REQUIRED) set_package_properties( Taglib PROPERTIES DESCRIPTION "Support for Audio metadata." URL "http://developer.kde.org/~wheeler/taglib.html" TYPE REQUIRED PURPOSE "Required for tag reading" ) # Check if TagLib is built with ASF and MP4 support include(CheckCXXSourceCompiles) set(CMAKE_REQUIRED_INCLUDES "${TAGLIB_INCLUDES}") set(CMAKE_REQUIRED_LIBRARIES "${TAGLIB_LIBRARIES}") check_cxx_source_compiles("#include int main() { TagLib::ASF::Tag tag; return 0;}" TAGLIB_ASF_FOUND) if( NOT TAGLIB_ASF_FOUND ) message(FATAL_ERROR "TagLib does not have ASF support compiled in.") endif() check_cxx_source_compiles("#include int main() { TagLib::MP4::Tag tag(0, 0); return 0;}" TAGLIB_MP4_FOUND) if( NOT TAGLIB_MP4_FOUND ) message(FATAL_ERROR "TagLib does not have MP4 support compiled in.") endif() check_cxx_source_compiles("#include #include #include #include #include using namespace TagLib; int main() { char *s; Mod::Tag tag; Mod::File modfile(s); S3M::File s3mfile(s); IT::File itfile(s); XM::File xmfile(s); return 0; }" TAGLIB_MOD_FOUND) check_cxx_source_compiles("#include int main() { char *s; TagLib::Ogg::Opus::File opusfile(s); return 0;}" TAGLIB_OPUS_FOUND) set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_LIBRARIES) set(TAGLIB-EXTRAS_MIN_VERSION "1.0") find_package(Taglib-Extras) set(TAGLIB_EXTRAS_FOUND ${TAGLIB-EXTRAS_FOUND}) # we need a c-compatible name for the include file include(CheckTagLibFileName) check_taglib_filename(COMPLEX_TAGLIB_FILENAME) ############### #Needed to conditionally build tests and gui if(BUILD_TESTING) add_definitions(-DDEBUG) endif() if(WITH_DESKTOP_UI) add_definitions(-DDESKTOP_UI) endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0") if (CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0") if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--as-needed") endif() endif () include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/shared ${CMAKE_CURRENT_BINARY_DIR}/shared ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # Require C++11 # WORKAROUND for Clang bug: http://llvm.org/bugs/show_bug.cgi?id=15651 if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-delayed-template-parsing") endif () add_definitions(-DQT_NO_URL_CAST_FROM_STRING) find_package(Phonon4Qt5 4.6.60 REQUIRED NO_MODULE) find_package( LibLastFm ) set( LIBLASTFM_MIN_VERSION "1.0.0" ) if( LIBLASTFM_FOUND ) if ( ${LIBLASTFM_MIN_VERSION} VERSION_LESS ${LIBLASTFM_VERSION} ) set( LIBLASTFM_FOUND TRUE ) endif() endif() string( TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_TOLOWER ) if( CMAKE_BUILD_TYPE_TOLOWER MATCHES debug ) set( DEBUG_BUILD_TYPE ON ) add_definitions(-Wall -Wextra) endif() # this needs to be here because also code in shared/ needs config.h. This is also the # reason why various checks are above why they belong under if( WITH_PLAYER ) configure_file( shared/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/shared/config.h ) add_subdirectory( data ) add_subdirectory( images ) add_subdirectory( shared ) if( WITH_PLAYER ) find_package(X11) find_package(Threads REQUIRED) find_package(MySQL REQUIRED) if( WITH_MYSQL_EMBEDDED ) set( BUILD_MYSQLE_COLLECTION TRUE ) set_package_properties( MYSQLD PROPERTIES DESCRIPTION "Embedded MySQL Libraries" URL "http://www.mysql.com" TYPE REQUIRED ) else() add_definitions( "-DNO_MYSQL_EMBEDDED" ) endif() set_package_properties( MYSQL PROPERTIES DESCRIPTION "MySQL Server Libraries" URL "http://www.mysql.com" TYPE REQUIRED ) # zlib is required for mysql embedded find_package(ZLIB REQUIRED) set_package_properties( ZLIB PROPERTIES DESCRIPTION "zlib" TYPE REQUIRED ) # We tell users that we need 1.0.3, but we really check just >= 1.0.0. This is because # upstream forgot to update version in lastfm/global.h, so it looks like 1.0.2. :-( # will be fixed in liblastfm-1.0.4 set( LIBLASTFM_MIN_VERSION "1.0.3" ) set_package_properties( LibLastFm PROPERTIES DESCRIPTION "Enable Last.Fm service, including scrobbling, song submissions, and suggested song dynamic playlists" URL "http://cdn.last.fm/client/liblastfm-${LIBLASTFM_MIN_VERSION}.tar.gz" TYPE OPTIONAL ) find_package(FFmpeg) set_package_properties(FFmpeg PROPERTIES DESCRIPTION "Libraries and tools for handling multimedia data" URL "https://www.ffmpeg.org/" TYPE OPTIONAL PURPOSE "Enable MusicDNS service" ) find_package(LibOFA) set_package_properties(LibOFA PROPERTIES DESCRIPTION "Open-source audio fingerprint by MusicIP" URL "http://code.google.com/p/musicip-libofa/" TYPE OPTIONAL PURPOSE "Enable MusicDNS service" ) ## gpodder Service # Actually it needs the to-be-released 1.10. Or you use 1.0.9 and add the # patches from the following pull requests: # https://github.com/gpodder/libmygpo-qt/pull/12 # -https://github.com/gpodder/libmygpo-qt/pull/13 find_package(Mygpo-qt5 1.0.9 CONFIG) set_package_properties(Mygpo-qt5 PROPERTIES DESCRIPTION "A Qt/C++ library wrapping the gpodder.net Webservice." URL "http://wiki.gpodder.org/wiki/Libmygpo-qt" TYPE OPTIONAL PURPOSE "Synchronize podcast subscriptions with gpodder.net" ) if( WITH_IPOD ) find_package(Ipod) set(IPOD_MIN_VERSION "0.8.2") if( IPOD_FOUND AND NOT WIN32 ) if ( ${IPOD_MIN_VERSION} VERSION_LESS ${IPOD_VERSION} ) set( IPOD_FOUND TRUE ) endif() endif() set_package_properties( Ipod PROPERTIES DESCRIPTION "Support Apple iPod/iPad/iPhone audio devices" URL "http://sourceforge.net/projects/gtkpod/" TYPE OPTIONAL ) find_package(GDKPixBuf) set_package_properties( GDKPixBuf PROPERTIES DESCRIPTION "Support for artwork on iPod audio devices via GDK-PixBuf" URL "http://developer.gnome.org/arch/imaging/gdkpixbuf.html" TYPE OPTIONAL ) endif() - find_package(Mtp) - set_package_properties( Mtp PROPERTIES DESCRIPTION "Enable Support for portable media devices that use the media transfer protocol" URL "http://libmtp.sourceforge.net/" TYPE OPTIONAL ) + find_package(Mtp 1.0.0) + set_package_properties(Mtp PROPERTIES + TYPE OPTIONAL + PURPOSE "Enable Support for portable media devices that use the media transfer protocol" + ) if( WITH_MP3Tunes ) find_package(CURL) set_package_properties( CURL PROPERTIES DESCRIPTION "Used to transfer data with URLs" URL "https://curl.haxx.se/" TYPE OPTIONAL ) find_package(LibXml2) set_package_properties( LibXml2 PROPERTIES DESCRIPTION "LibXML2 is an XML parser required by mp3tunes." URL "http://www.xmlsoft.org" TYPE OPTIONAL ) find_package(OpenSSL) find_package(Libgcrypt) if ( OPENSSL_FOUND OR LIBGCRYPT_FOUND ) set (_mp3tunes_crypto TRUE ) else () message( SEND_ERROR "Building with mp3tunes support REQUIRES either OpenSSL or GNU Libgcrypt" ) endif () set_package_properties( OpenSSL PROPERTIES DESCRIPTION "OpenSSL or GNU Libgcrypt provides cryptographic functions required by mp3tunes." URL "http://www.openssl.org/ or http://www.gnupg.org/download/#libgcrypt" TYPE OPTIONAL ) set_package_properties( Libgcrypt PROPERTIES DESCRIPTION "OpenSSL or GNU Libgcrypt provides cryptographic functions required by mp3tunes." URL "http://www.openssl.org/ or http://www.gnupg.org/download/#libgcrypt" TYPE OPTIONAL ) find_package(Loudmouth) set_package_properties( Loudmouth PROPERTIES DESCRIPTION "Loudmouth is the communication backend needed by mp3tunes for syncing." URL "http://www.loudmouth-project.org" TYPE OPTIONAL ) include(CheckQtGlib) set_package_properties( QT5_GLIB PROPERTIES DESCRIPTION "Qt5 must be compiled with glib support for mp3tunes" URL "http://www.trolltech.com" TYPE OPTIONAL ) endif() if( WITH_IPOD OR WITH_MP3Tunes ) pkg_search_module( GOBJECT REQUIRED gobject-2.0 ) set_package_properties( GOBJECT PROPERTIES DESCRIPTION "Required by libgpod and mp3tunes." URL "http://www.gtk.org" TYPE OPTIONAL ) pkg_search_module( GLIB2 glib-2.0 ) set_package_properties( GLIB2 PROPERTIES DESCRIPTION "Required by libgpod and mp3tunes" URL "http://www.gtk.org" TYPE OPTIONAL ) endif() find_program( CLAMZ_FOUND clamz PATH ) set_package_properties( CLAMZ PROPERTIES DESCRIPTION "Optional requirement to download songs from the Amazon MP3 store. Highly recommended on Linux, as the official downloader from Amazon is quite broken on many systems." URL "https://code.google.com/p/clamz/" TYPE OPTIONAL ) find_package(PythonInterp) set_package_properties( PYTHON PROPERTIES DESCRIPTION "Required for generating the autocompletion file for the script console" URL "https://www.python.org" TYPE OPTIONAL ) find_package(FFTW3 REQUIRED) if( BUILD_TESTING AND NOT WIN32 ) enable_testing() add_subdirectory( tests ) endif() add_subdirectory( src ) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) #Do not remove or modify these. The release script substitutes in for these #comments with appropriate doc and translation directories. #PO_SUBDIR #DOC_SUBDIR endif() if( WITH_UTILITIES ) add_subdirectory( utilities ) endif() if( WITH_PLAYGROUND ) add_subdirectory( playground ) message(STATUS "Included playground subdirectory in configuration") endif() include(CTest) diff --git a/cmake/modules/FindMtp.cmake b/cmake/modules/FindMtp.cmake index 9b91f3ff80..cf3d00b3c7 100644 --- a/cmake/modules/FindMtp.cmake +++ b/cmake/modules/FindMtp.cmake @@ -1,55 +1,53 @@ # - Try to find the libmtp library # Once done this will define # # MTP_FOUND - system has libmtp # MTP_INCLUDE_DIR - the libmtp include directory # MTP_LIBRARIES - Link these to use libmtp # MTP_DEFINITIONS - Compiler switches required for using libmtp # -if (MTP_INCLUDE_DIR AND MTP_LIBRARIES AND MTP_VERSION_OKAY) - - # in cache already - set(MTP_FOUND TRUE) - -else () - if(NOT WIN32) - # use pkg-config to get the directories and then use these values - # in the FIND_PATH() and FIND_LIBRARY() calls - include(FindPkgConfig) - - pkg_check_modules(_MTP libmtp) - - set(MTP_DEFINITIONS ${_MTP_CFLAGS}) - endif() - find_path(MTP_INCLUDE_DIR libmtp.h - ${_MTP_INCLUDE_DIRS} - ) - - find_library(MTP_LIBRARIES NAMES mtp - PATHS - ${_MTP_LIBRARY_DIRS} - ) - - exec_program(${PKG_CONFIG_EXECUTABLE} ARGS --atleast-version=1.0.0 libmtp OUTPUT_VARIABLE _pkgconfigDevNull RETURN_VALUE MTP_VERSION_OKAY) - - if (MTP_INCLUDE_DIR AND MTP_LIBRARIES AND MTP_VERSION_OKAY STREQUAL "0") - set(MTP_FOUND TRUE) - endif () - - if (MTP_FOUND) - if (NOT Mtp_FIND_QUIETLY) - message(STATUS "Found MTP: ${MTP_LIBRARIES}") - endif () - else () - if (MTP_INCLUDE_DIR AND MTP_LIBRARIES AND NOT MTP_VERSION_OKAY STREQUAL "0") - message(STATUS "Found MTP but version requirements not met") - endif () - if (Mtp_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find MTP") - endif () - endif () - - mark_as_advanced(MTP_INCLUDE_DIR MTP_LIBRARIES MTP_VERSION_OKAY) - -endif () +find_package(PkgConfig QUIET) +pkg_check_modules(PC_MTP QUIET libmtp>=${Mtp_FIND_VERSION}) + +set(MTP_DEFINITIONS ${PC_MTP_CFLAGS}) + +find_path(MTP_INCLUDE_DIR + NAMES libmtp.h + HINTS ${PC_MTP__INCLUDEDIR} ${PC_MTP_INCLUDE_DIRS} +) + +find_library(MTP_LIBRARIES + NAMES mtp + HINTS ${PC_MTP_LIBDIR} ${PC_MTP_LIBRARY_DIRS} +) + +if(PC_MTP_VERSION) + set(MTP_VERSION_STRING ${PC_MTP_VERSION}) +elseif(MTP_INCLUDE_DIR AND EXISTS "${MTP_INCLUDE_DIR}/libmtp.h") + file(STRINGS "${MTP_INCLUDE_DIR}/libmtp.h" mtp_version_str + REGEX "^#define[\t ]+LIBMTP_VERSION_STRING[\t ]+\".*\"") + + string(REGEX REPLACE "^#define[\t ]+LIBMTP_VERSION_STRING[\t ]+\"([^\"]*)\".*" "\\1" + MTP_VERSION_STRING "${mtp_version_str}") + unset(mtp_version_str) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Mtp + REQUIRED_VARS MTP_LIBRARIES MTP_INCLUDE_DIR + VERSION_VAR MTP_VERSION_STRING +) + +if(MTP_FOUND AND NOT TARGET Mtp::Mtp) + add_library(Mtp::Mtp UNKNOWN IMPORTED) + set_target_properties(Mtp::Mtp PROPERTIES + IMPORTED_LOCATION "${MTP_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${MTP_INCLUDE_DIR}") +endif() + +mark_as_advanced(MTP_INCLUDE_DIR MTP_LIBRARIES) +set_package_properties(Mtp PROPERTIES + URL "http://libmtp.sourceforge.net/" + DESCRIPTION "An implementation of Microsoft's Media Transfer Protocol (MTP)" +) diff --git a/src/core-impl/collections/mtpcollection/CMakeLists.txt b/src/core-impl/collections/mtpcollection/CMakeLists.txt index 78ccdc3e53..a97c974abc 100644 --- a/src/core-impl/collections/mtpcollection/CMakeLists.txt +++ b/src/core-impl/collections/mtpcollection/CMakeLists.txt @@ -1,51 +1,45 @@ -find_package(Mtp) - - if (MTP_FOUND) include_directories( ${Amarok_SOURCE_DIR}/src ${Amarok_SOURCE_DIR}/src/core-impl/collections ${Amarok_SOURCE_DIR}/src/core-impl/collections/mediadevicecollection ${Amarok_SOURCE_DIR}/src/core-impl/collections/mediadevicecollection/support ${Amarok_SOURCE_DIR}/src/core-impl/collections/mediadevicecollection/handler ${Amarok_SOURCE_DIR}/src/core-impl/collections/mediadevicecollection/handler/capabilities ${Amarok_SOURCE_DIR}/src/core-impl/collections/mtpcollection/handler ${Amarok_SOURCE_DIR}/src/core-impl/collections/mtpcollection/handler/capabilities ${Amarok_SOURCE_DIR}/src/core-impl/collections/mtpcollection/support ${GLIB2_INCLUDE_DIR} - ${MTP_INCLUDE_DIR} ${CMAKE_BINARY_DIR}/src ${AMAROK_COLLECTION_SUPPORT_DIR} - - ) ########### next target ############### set(amarok_collection-mtpcollection_PART_SRCS MtpCollection.cpp handler/MtpHandler.cpp handler/capabilities/MtpPlaylistCapability.cpp handler/capabilities/MtpReadCapability.cpp handler/capabilities/MtpWriteCapability.cpp support/MtpDeviceInfo.cpp support/MtpConnectionAssistant.cpp ) add_library(amarok_collection-mtpcollection MODULE ${amarok_collection-mtpcollection_PART_SRCS}) target_link_libraries(amarok_collection-mtpcollection amarokcore amaroklib KF5::KIOCore KF5::ThreadWeaver Qt5::Gui - ${MTP_LIBRARIES} + Mtp::Mtp ) install(TARGETS amarok_collection-mtpcollection DESTINATION ${KDE_INSTALL_PLUGINDIR} ) kcoreaddons_desktop_to_json(amarok_collection-mtpcollection amarok_collection-mtpcollection.desktop SERVICE_TYPES ${CMAKE_SOURCE_DIR}/src/amarok-plugin.desktop) endif ()