Warning, /multimedia/k3b/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 cmake_minimum_required(VERSION 3.16)
0002 
0003 # KDE Application Version, managed by release script
0004 set (RELEASE_SERVICE_VERSION_MAJOR "24")
0005 set (RELEASE_SERVICE_VERSION_MINOR "01")
0006 set (RELEASE_SERVICE_VERSION_MICRO "95")
0007 set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}")
0008 
0009 project(k3b VERSION ${RELEASE_SERVICE_VERSION})
0010 
0011 set(QT_MIN_VERSION "5.15.2")
0012 set(KF5_MIN_VERSION "5.96.0")
0013 
0014 set (KDE_COMPILERSETTINGS_LEVEL "5.84")
0015 
0016 find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
0017 set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" "${ECM_MODULE_PATH}")
0018 
0019 ##################  K3b version  ################################
0020 set(K3B_VERSION_STRING ${RELEASE_SERVICE_VERSION})
0021 
0022 # increase on BC breakage
0023 set(K3B_LIB_VERSION_MAJOR 8)
0024 
0025 # increase after adding functionality
0026 set(K3B_LIB_VERSION_MINOR 0)
0027 set(K3B_LIB_VERSION_RELEASE 0)
0028 
0029 
0030 ##################  K3b options #################################
0031 option(K3B_DEBUG "K3b additional debugging support" OFF)
0032 if(K3B_DEBUG)
0033     add_definitions(-g)
0034 endif()
0035 option(K3B_ENABLE_MUSICBRAINZ "Support for querying metadata about audio tracks from Musicbrainz." ON)
0036 option(K3B_ENABLE_DVD_RIPPING "Support for ripping Video DVDs with optional decryption." ON)
0037 option(K3B_ENABLE_TAGLIB "Support for reading audio file metadata using Taglib." ON)
0038 option(K3B_BUILD_API_DOCS "Build the API documentation for the K3b libs." OFF)
0039 
0040 # plugin options
0041 option(K3B_BUILD_FFMPEG_DECODER_PLUGIN "Build FFmpeg decoder plugin" ON)
0042 option(K3B_BUILD_OGGVORBIS_DECODER_PLUGIN "Build Ogg-Vorbis decoder plugin" ON)
0043 option(K3B_BUILD_OGGVORBIS_ENCODER_PLUGIN "Build Ogg-Vorbis encoder plugin" ON)
0044 option(K3B_BUILD_MAD_DECODER_PLUGIN "Build MAD mp3 decoder plugin" ON)
0045 option(K3B_BUILD_MUSE_DECODER_PLUGIN "Build Musepack decoder plugin" ON)
0046 option(K3B_BUILD_FLAC_DECODER_PLUGIN "Build Flac decoder plugin" ON)
0047 option(K3B_BUILD_SNDFILE_DECODER_PLUGIN "Build libsndfile decoder plugin" ON)
0048 option(K3B_BUILD_LAME_ENCODER_PLUGIN "Build Lame encoder plugin" ON)
0049 option(K3B_BUILD_SOX_ENCODER_PLUGIN "Build Sox encoder plugin" ON)
0050 option(K3B_BUILD_EXTERNAL_ENCODER_PLUGIN "Build external app encoder plugin" ON)
0051 option(K3B_BUILD_WAVE_DECODER_PLUGIN "Build Wave decoder plugin" ON)
0052 
0053 ##################  K3b requirements #################################
0054 include(KDEInstallDirs)
0055 include(KDECompilerSettings NO_POLICY_SCOPE)
0056 include(KDECMakeSettings)
0057 
0058 include(FeatureSummary)
0059 include(GenerateExportHeader)
0060 include(ECMInstallIcons)
0061 include(ECMEnableSanitizers)
0062 include(ECMSetupQtPluginMacroNames)
0063 include(ECMQtDeclareLoggingCategory)
0064 if (QT_MAJOR_VERSION STREQUAL "6")
0065     set(QT_REQUIRED_VERSION "6.4.0")
0066     set(KF_MIN_VERSION "5.240.0")
0067     set(KF_MAJOR_VERSION "6")
0068 else()
0069     set(KF_MAJOR_VERSION "5")
0070 endif()
0071 
0072 find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS Core DBus Gui)
0073 find_package(KF${KF_MAJOR_VERSION} ${KF5_MIN_VERSION} REQUIRED COMPONENTS Archive Auth Config CoreAddons DocTools FileMetaData I18n IconThemes JobWidgets
0074                                      KCMUtils KIO Notifications NewStuff NotifyConfig Solid WidgetsAddons XmlGui)
0075 if (QT_MAJOR_VERSION STREQUAL "6")
0076     find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core5Compat)
0077 endif()
0078 
0079 find_package(Qt${QT_MAJOR_VERSION}WebEngineWidgets)
0080 set_package_properties(Qt${QT_MAJOR_VERSION}WebEngineWidgets PROPERTIES
0081     DESCRIPTION "QtWebEngineWidgets is used for prettier k3bdiskinfoview."
0082     TYPE OPTIONAL)
0083 if(Qt${QT_MAJOR_VERSION}WebEngineWidgets_FOUND)
0084     add_definitions(-DHAVE_QTWEBENGINEWIDGETS)
0085 endif()
0086 
0087 add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
0088 
0089 option(WITH_NEW_SOLID_JOB "WIP: base Job class" Off)
0090 add_feature_info(Solid::Job WITH_NEW_SOLID_JOB "WIP: Base class for Solid Asynchronous apis")
0091 if(WITH_NEW_SOLID_JOB)
0092     add_definitions(-DWITH_NEW_SOLID_JOB)
0093 endif()
0094 
0095 find_package(Iconv)
0096 set(HAVE_ICONV "${ICONV_FOUND}")
0097 
0098 find_package(Samplerate)
0099 set_package_properties(Samplerate PROPERTIES
0100     DESCRIPTION "Audio sampling rate conversion."
0101     URL "http://www.mega-nerd.com/SRC"
0102     TYPE REQUIRED)
0103 
0104 if (KF_MAJOR_VERSION STREQUAL "5")
0105     set(KCDDB_TARGET_NAME KF5::Cddb)
0106     find_package(KF5Cddb 5.1 REQUIRED)
0107 else()
0108     set(KCDDB_TARGET_NAME KCddb6)
0109     find_package(KCddb6 5.1 REQUIRED)
0110 endif()
0111 set_package_properties(${KCDDB_TARGET_NAME} PROPERTIES
0112     DESCRIPTION "Latest branch for CDDB library"
0113     URL "https://commits.kde.org/libkcddb"
0114     TYPE REQUIRED
0115     PURPOSE "libkcddb is used to retrieve audio CD meta data from the internet.")
0116 
0117 if(K3B_ENABLE_DVD_RIPPING)
0118     find_package(DvdRead)
0119     set_package_properties(DvdRead PROPERTIES
0120         DESCRIPTION "Libdvdread provides a simple foundation for reading DVD video disks."
0121         URL "https://www.videolan.org/developers/libdvdnav.html"
0122         TYPE OPTIONAL)
0123 
0124     set(ENABLE_DVD_RIPPING "${DVDREAD_FOUND}")
0125 endif()
0126 
0127 if(K3B_ENABLE_TAGLIB)
0128     find_package(Taglib)
0129     set_package_properties(Taglib PROPERTIES
0130         DESCRIPTION "Read and write tags in audio files"
0131         URL "https://taglib.org/"
0132         TYPE OPTIONAL)
0133 
0134     set(ENABLE_TAGLIB "${TAGLIB_FOUND}")
0135 endif()
0136 
0137 if(K3B_ENABLE_MUSICBRAINZ)
0138     find_package(MusicBrainz)
0139     set_package_properties(MusicBrainz PROPERTIES
0140         DESCRIPTION "Provide information about the CD, about the artist or about related information"
0141         URL "https://musicbrainz.org/"
0142         TYPE OPTIONAL)
0143 
0144     set(ENABLE_MUSICBRAINZ "${MUSICBRAINZ_FOUND}")
0145 endif()
0146 
0147 if(K3B_BUILD_FFMPEG_DECODER_PLUGIN)
0148     find_package(FFmpeg 4.4.0)
0149     set_package_properties(FFmpeg PROPERTIES
0150         PURPOSE "Needed for the K3b FFmpeg decoder plugin which can decode virtually all audio types."
0151         URL "https://ffmpeg.org/"
0152         TYPE OPTIONAL)
0153 
0154     if(FFMPEG_FOUND)
0155         include(CheckSymbolExists)
0156         include(CMakePushCheckState)
0157         cmake_push_check_state()
0158 
0159         if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
0160             # FindKDE4Internal.cmake screws things up
0161             set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -std=c99)
0162         endif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
0163 
0164         if(FFMPEG_INCLUDE_DIR_OLD_STYLE)
0165             set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${FFMPEG_INCLUDE_DIR_OLD_STYLE})
0166             set(FFMPEG_HEADERS ffmpeg/avcodec.h ffmpeg/avformat.h)
0167         else(FFMPEG_INCLUDE_DIR_OLD_STYLE)
0168             set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${FFMPEG_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS})
0169             set(FFMPEG_HEADERS libavcodec/avcodec.h libavformat/avformat.h)
0170             set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DNEWFFMPEGAVCODECPATH)
0171         endif(FFMPEG_INCLUDE_DIR_OLD_STYLE)
0172         set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${FFMPEG_LIBRARIES})
0173 
0174         check_symbol_exists(avformat_open_input "${FFMPEG_HEADERS}" HAVE_FFMPEG_AVFORMAT_OPEN_INPUT)
0175         check_symbol_exists(av_dump_format "${FFMPEG_HEADERS}" HAVE_FFMPEG_AV_DUMP_FORMAT)
0176         check_symbol_exists(avformat_find_stream_info "${FFMPEG_HEADERS}" HAVE_FFMPEG_AVFORMAT_FIND_STREAM_INFO)
0177         check_symbol_exists(avformat_close_input "${FFMPEG_HEADERS}" HAVE_FFMPEG_AVFORMAT_CLOSE_INPUT)
0178         check_symbol_exists(avcodec_open2 "${FFMPEG_HEADERS}" HAVE_FFMPEG_AVCODEC_OPEN2)
0179         include(CheckCSourceCompiles)
0180         check_c_source_compiles("
0181             #ifdef NEWFFMPEGAVCODECPATH
0182             #include <libavcodec/avcodec.h>
0183             #else
0184             #include <ffmpeg/avcodec.h>
0185             #endif
0186             int main() { enum AVMediaType t = AVMEDIA_TYPE_UNKNOWN; return 0; }
0187             " HAVE_FFMPEG_AVMEDIA_TYPE)
0188         check_c_source_compiles("
0189             #ifdef NEWFFMPEGAVCODECPATH
0190             #include <libavcodec/avcodec.h>
0191             #else
0192             #include <ffmpeg/avcodec.h>
0193             #endif
0194             int main() {
0195             #if LIBAVCODEC_BUILD >= AV_VERSION_INT(54,25,0)
0196             # Not needed here. AV_CODEC_ID_MP3 exists.
0197             #else
0198             enum CodecID t = CODEC_ID_MP3;
0199             #endif
0200             return 0;
0201             }
0202             " HAVE_FFMPEG_CODEC_MP3)
0203 
0204         cmake_pop_check_state()
0205     endif(FFMPEG_FOUND)
0206 
0207     set(BUILD_FFMPEG_DECODER_PLUGIN "${FFMPEG_FOUND}")
0208 endif(K3B_BUILD_FFMPEG_DECODER_PLUGIN)
0209 
0210 if(K3B_BUILD_FLAC_DECODER_PLUGIN)
0211     find_package(Flac)
0212     set_package_properties(Flac PROPERTIES
0213         PURPOSE "Needed for the Flac audio decoder plugin."
0214         URL "https://xiph.org/flac/"
0215         TYPE OPTIONAL)
0216 
0217     find_package(Flac++)
0218     set_package_properties(Flac++ PROPERTIES
0219         PURPOSE "Needed for the Flac audio decoder plugin."
0220         URL "https://xiph.org/flac/"
0221         TYPE OPTIONAL)
0222 
0223     if(FLAC_FOUND AND FLAC++_FOUND)
0224         set(BUILD_FLAC_DECODER_PLUGIN 1)
0225     endif()
0226 endif()
0227 
0228 if(K3B_BUILD_MAD_DECODER_PLUGIN)
0229     find_package(Mad)
0230     set_package_properties(Mad PROPERTIES
0231         PURPOSE "Needed for the mp3 audio decoder plugin."
0232         URL "https://www.underbit.com/products/mad"
0233         TYPE OPTIONAL)
0234 
0235     set(BUILD_MAD_DECODER_PLUGIN "${MAD_FOUND}")
0236 endif()
0237 
0238 if(K3B_BUILD_MUSE_DECODER_PLUGIN)
0239     find_package(Muse)
0240     set_package_properties(Muse PROPERTIES
0241         PURPOSE "Needed for the Musepack audio decoder plugin"
0242         URL "https://www.musepack.net/"
0243         TYPE OPTIONAL)
0244 
0245     set(BUILD_MUSE_DECODER_PLUGIN "${Muse_FOUND}")
0246 endif()
0247 
0248 if(K3B_BUILD_SNDFILE_DECODER_PLUGIN)
0249     find_package(Sndfile)
0250     set_package_properties(Sndfile PROPERTIES
0251         PURPOSE "Needed for the libsndfile audio decoder plugin."
0252         URL "http://www.mega-nerd.com/libsndfile"
0253         TYPE OPTIONAL)
0254 
0255     set(BUILD_SNDFILE_DECODER_PLUGIN "${SNDFILE_FOUND}")
0256 endif()
0257 
0258 if(K3B_BUILD_LAME_ENCODER_PLUGIN)
0259     find_package(Lame)
0260     set_package_properties(Lame PROPERTIES
0261         DESCRIPTION "Lame mp3 encoder"
0262         PURPOSE "Needed for the lame mpf encoder encoder plugin."
0263         URL "https://lame.sourceforge.io/"
0264         TYPE OPTIONAL)
0265 
0266     set(BUILD_LAME_ENCODER_PLUGIN "${LAME_FOUND}")
0267 endif()
0268 
0269 if(K3B_BUILD_OGGVORBIS_DECODER_PLUGIN OR K3B_BUILD_OGGVORBIS_ENCODER_PLUGIN)
0270     find_package(OggVorbis)
0271     set_package_properties(OggVorbis PROPERTIES
0272         DESCRIPTION "Ogg Vorbis"
0273         PURPOSE "Needed for the K3b Ogg Vorbis decoder and encoder plugins."
0274         URL "https://xiph.org/vorbis/"
0275         TYPE OPTIONAL)
0276 
0277     set(BUILD_OGGVORBIS_DECODER_PLUGIN "${OGGVORBIS_FOUND}")
0278     set(BUILD_OGGVORBIS_ENCODER_PLUGIN "${OGGVORBIS_FOUND}")
0279 endif()
0280 
0281 ###################  K3b build settings #################################
0282 include(ConfigureChecks)
0283 
0284 set(BUILD_WAVE_DECODER_PLUGIN "${K3B_BUILD_WAVE_DECODER_PLUGIN}")
0285 set(BUILD_SOX_ENCODER_PLUGIN "${K3B_BUILD_SOX_ENCODER_PLUGIN}")
0286 set(BUILD_EXTERNAL_ENCODER_PLUGIN "${K3B_BUILD_EXTERNAL_ENCODER_PLUGIN}")
0287 
0288 set(ENABLE_HAL_SUPPORT "${K3B_ENABLE_HAL_SUPPORT}")
0289 set(ENABLE_AUDIO_PLAYER "${QT_QTMULTIMEDIA_FOUND}")
0290 
0291 if(IS_ABSOLUTE ${KDE_INSTALL_DATADIR})
0292   set(K3B_DATA_INSTALL_DIR ${KDE_INSTALL_DATADIR}/k3b)
0293 else()
0294   set(K3B_DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${KDE_INSTALL_DATADIR}/k3b)
0295 endif()
0296 
0297 configure_file(config-k3b.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-k3b.h)
0298 include_directories(${CMAKE_BINARY_DIR})
0299 
0300 ecm_setup_qtplugin_macro_names(
0301     JSON_NONE
0302         K3B_EXPORT_PLUGIN
0303         K3B_EXPORT_PLUGIN_CONFIG_WIDGET
0304 )
0305 
0306 ##################  K3b apidox ################################
0307 if(K3B_BUILD_API_DOCS)
0308     find_package(Doxygen)
0309 
0310     if(DOXYGEN_EXECUTABLE)
0311         configure_file(${CMAKE_SOURCE_DIR}/Doxyfile.cmake ${CMAKE_BINARY_DIR}/Doxyfile)
0312 
0313         if(EXISTS ${QT_DOC_DIR}/html)
0314             set(QTDOCS "${QT_DOC_DIR}/html")
0315         else()
0316             set(QTDOCS "https://doc.qt.io/qt-5/")
0317         endif()
0318 
0319         add_custom_target(apidox
0320             COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
0321             COMMAND docs/html/installdox -l qt${QT_MAJOR_VERSION}.tag@${QTDOCS} docs/html/*.html)
0322     endif()
0323 endif(K3B_BUILD_API_DOCS)
0324 
0325 ##################  K3b build environment ################################
0326 add_subdirectory( libk3bdevice )
0327 add_subdirectory( libk3b )
0328 add_subdirectory( src )
0329 add_subdirectory( kioworkers )
0330 add_subdirectory( plugins )
0331 add_subdirectory( doc )
0332 if(BUILD_TESTING)
0333     find_package(Qt${QT_MAJOR_VERSION}Test REQUIRED)
0334     find_package(LibFuzzer)
0335     set_package_properties(LibFuzzer PROPERTIES
0336         PURPOSE "libFuzzer – a library for coverage-guided fuzz testing."
0337         URL "https://llvm.org/docs/LibFuzzer.html"
0338         TYPE OPTIONAL)
0339     add_subdirectory(tests)
0340 endif()
0341 
0342 ecm_qt_install_logging_categories(
0343     EXPORT K3B
0344     FILE k3b.categories
0345     DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}
0346 )
0347 
0348 ki18n_install(po)
0349 kdoctools_install(po)
0350 
0351 ###################  K3b config summary ################################
0352 feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)