Warning, /multimedia/kid3/src/plugins/acoustidimport/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 if(WITH_CHROMAPRINT)
0002
0003 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
0004 find_package(Chromaprint REQUIRED)
0005 if(CHROMAPRINT_INCLUDE_DIR AND CHROMAPRINT_LIBRARIES)
0006 set(HAVE_CHROMAPRINT 1)
0007 endif()
0008 if(WITH_FFMPEG)
0009 find_package(FFmpeg COMPONENTS avformat avcodec avutil REQUIRED)
0010 elseif(WITH_GSTREAMER)
0011 find_package(GStreamer REQUIRED)
0012 if(NOT GSTREAMER_FOUND)
0013 message(FATAL_ERROR "Could not find GStreamer")
0014 endif()
0015 elseif(WITH_QAUDIODECODER)
0016 message(STATUS "QAudioDecoder selected for decoding.")
0017 else()
0018 # Neither FFmpeg nor GStreamer is forced, select FFmpeg if Chromaprint
0019 # depends on it or if on Windows or Mac OS X.
0020 include(GetPrerequisites)
0021 get_prerequisites(${CHROMAPRINT_LIBRARIES} _chromaprintDeps 0 0 "" "")
0022 if(_chromaprintDeps MATCHES "libavcodec" OR APPLE OR WIN32)
0023 message(STATUS "FFmpeg selected for decoding, use WITH_GSTREAMER=ON to use GStreamer instead.")
0024 find_package(FFmpeg COMPONENTS avformat avcodec avutil REQUIRED)
0025 else()
0026 message(STATUS "GStreamer selected for decoding, use WITH_FFMPEG=ON to use FFmpeg instead.")
0027 find_package(GStreamer REQUIRED)
0028 endif()
0029 endif()
0030 if(GSTREAMER_FOUND)
0031 set(HAVE_GSTREAMER 1)
0032 elseif(FFMPEG_FOUND)
0033 set(HAVE_FFMPEG 1)
0034 endif()
0035
0036 set(plugin_NAME AcoustidImport)
0037
0038 string(TOLOWER ${plugin_NAME} plugin_TARGET)
0039
0040 add_library(${plugin_TARGET}
0041 abstractfingerprintdecoder.cpp
0042 fingerprintcalculator.cpp
0043 musicbrainzclient.cpp
0044 acoustidimportplugin.cpp
0045 )
0046
0047 if(HAVE_GSTREAMER)
0048 target_sources(${plugin_TARGET} PRIVATE gstfingerprintdecoder.cpp)
0049 elseif(HAVE_FFMPEG)
0050 target_sources(${plugin_TARGET} PRIVATE ffmpegfingerprintdecoder.cpp)
0051 else()
0052 target_sources(${plugin_TARGET} PRIVATE qtfingerprintdecoder.cpp)
0053 endif()
0054
0055 qt_wrap_cpp(plugin_GEN_MOC_SRCS
0056 abstractfingerprintdecoder.h
0057 fingerprintcalculator.h
0058 musicbrainzclient.h
0059 acoustidimportplugin.h
0060 TARGET ${plugin_TARGET}
0061 )
0062 target_sources(${plugin_TARGET} PRIVATE ${plugin_GEN_MOC_SRCS})
0063
0064 if(NOT HAVE_GSTREAMER AND NOT HAVE_FFMPEG)
0065 qt_wrap_cpp(qtfp_GEN_MOC_SRCS qtfingerprintdecoder.h TARGET ${plugin_TARGET})
0066 target_sources(${plugin_TARGET} PRIVATE ${qtfp_GEN_MOC_SRCS})
0067 endif()
0068
0069 target_include_directories(${plugin_TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
0070 target_link_libraries(${plugin_TARGET} PRIVATE kid3-core Chromaprint::Chromaprint Kid3Plugin)
0071
0072 if(HAVE_GSTREAMER)
0073 target_link_libraries(${plugin_TARGET} PRIVATE GStreamer::GStreamer)
0074 elseif(HAVE_FFMPEG)
0075 if(FFmpeg_avformat_FOUND AND FFmpeg_avcodec_FOUND AND FFmpeg_avutil_FOUND)
0076 if(FFmpeg_swresample_FOUND)
0077 set(HAVE_SWRESAMPLE 1)
0078 target_link_libraries(${plugin_TARGET} PRIVATE FFmpeg::swresample)
0079 elseif(FFmpeg_avresample_FOUND)
0080 set(HAVE_AVRESAMPLE 1)
0081 target_link_libraries(${plugin_TARGET} PRIVATE FFmpeg::avresample)
0082 else()
0083 include(CheckFunctionExists)
0084 set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES})
0085 set(CMAKE_REQUIRED_LIBRARIES FFmpeg::avformat FFmpeg::avcodec FFmpeg::avutil)
0086 check_function_exists(av_audio_convert HAVE_AV_AUDIO_CONVERT)
0087 set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP})
0088 endif()
0089 endif()
0090
0091 target_link_libraries(${plugin_TARGET} PRIVATE FFmpeg::avformat FFmpeg::avcodec FFmpeg::avutil)
0092 if(WIN32 OR APPLE)
0093 target_link_libraries(${plugin_TARGET} PRIVATE ${ZLIB_LIBRARIES})
0094 endif()
0095 if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT MSVC)
0096 # With MinGW64, FFmpeg 4 is used, which requires bcrypt
0097 target_link_libraries(${plugin_TARGET} PRIVATE "-lbcrypt")
0098 endif()
0099 else()
0100 target_link_libraries(${plugin_TARGET} PRIVATE Qt${QT_VERSION_MAJOR}::Multimedia)
0101 endif()
0102
0103 if(APPLE)
0104 find_library(ACCELERATE_LIBRARIES Accelerate)
0105 target_link_libraries(${plugin_TARGET} PRIVATE ${ACCELERATE_LIBRARIES})
0106 endif()
0107
0108 configure_file(acoustidconfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/acoustidconfig.h)
0109
0110 if(APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386")
0111 # To suppress linker error
0112 # ld: illegal text-relocation to non_lazy_ptr in ../libavformat.a
0113 # (allformats.o) from _av_register_all in ../libavformat.a(allformats.o)
0114 # for architecture i386
0115 # ld: illegal text-relocation to _cpy8 in /usr/local/lib/libswresample.a
0116 # (audioconvert.o) from _swri_audio_convert_alloc in
0117 # /usr/local/lib/libswresample.a(audioconvert.o) for architecture i386
0118 set_target_properties(${plugin_TARGET} PROPERTIES LINK_FLAGS -Wl,-read_only_relocs,suppress)
0119 endif()
0120
0121 if(LINUX_SELF_CONTAINED)
0122 # To avoid linker error
0123 # relocation R_X86_64_PC32 against symbol `ff_pw_9' can not be used when
0124 # making a shared object; recompile with -fPIC
0125 # see https://www.ffmpeg.org/platform.html#Advanced-linking-configuration
0126 set_target_properties(${plugin_TARGET} PROPERTIES LINK_FLAGS -Wl,-Bsymbolic)
0127 endif()
0128
0129 INSTALL_KID3_PLUGIN(${plugin_TARGET} ${plugin_NAME})
0130 endif()