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

0001 # Build Kid3 using CMake
0002 #
0003 # Linux:
0004 # cmake -DCMAKE_BUILD_TYPE=Release -DWITH_APPS=Qt -DCMAKE_INSTALL_PREFIX=/usr ../kid3
0005 # make
0006 # make install/strip DESTDIR=$(pwd)/inst # or
0007 # cpack
0008 #
0009 # Windows:
0010 # set INCLUDE=%MSYSDIR%\local\include
0011 # set LIB=%MSYSDIR%\local\lib
0012 # cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX= ..\kid3
0013 # mingw32-make
0014 # cpack
0015 #
0016 # Mac OS X:
0017 # cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX= ../kid3
0018 # make
0019 # cpack
0020 
0021 # These markers are to tell releaseme (used by KDE neon and others) to not inject translations
0022 # SKIP_PO_INSTALL
0023 # SKIP_POQML_INSTALL
0024 
0025 project(kid3)
0026 
0027 cmake_minimum_required(VERSION 3.3)
0028 
0029 set(BUILD_SHARED_LIBS ON CACHE BOOL "build shared libraries")
0030 set(WITH_QML    ON CACHE BOOL "build with QML")
0031 set(WITH_TAGLIB ON CACHE BOOL "build with TagLib")
0032 set(WITH_MP4V2 OFF CACHE BOOL "build with mp4v2")
0033 set(WITH_FFMPEG OFF CACHE BOOL "force use of FFmpeg for Chromaprint decoding")
0034 set(WITH_CHROMAPRINT_FFMPEG OFF CACHE BOOL "link FFmpeg only for Chromaprint FFT")
0035 set(WITH_GSTREAMER OFF CACHE BOOL "force use of GStreamer for Chromaprint decoding")
0036 set(WITH_QAUDIODECODER OFF CACHE BOOL "force use of QAudioDecoder for Chromaprint decoding")
0037 set(WITH_NO_MANCOMPRESS OFF CACHE BOOL "disable compressed manpages")
0038 set(WITH_MULTIMEDIA ON CACHE BOOL "build with Qt Multimedia")
0039 if(ANDROID)
0040   set(CMAKE_INSTALL_PREFIX "" CACHE PATH "install path prefix" FORCE)
0041   set(WITH_ID3LIB OFF CACHE BOOL "build with id3lib")
0042   set(WITH_VORBIS OFF CACHE BOOL "build with Ogg/Vorbis")
0043   set(WITH_FLAC OFF CACHE BOOL "build with FLAC")
0044   set(WITH_CHROMAPRINT OFF CACHE BOOL "build with Chromaprint")
0045 else()
0046   set(WITH_ID3LIB ON CACHE BOOL "build with id3lib")
0047   set(WITH_VORBIS ON CACHE BOOL "build with Ogg/Vorbis")
0048   set(WITH_FLAC ON CACHE BOOL "build with FLAC")
0049   set(WITH_CHROMAPRINT ON CACHE BOOL "build with Chromaprint")
0050 endif()
0051 if(APPLE OR WIN32)
0052   set(WITH_DBUS OFF CACHE BOOL "build with QtDBus")
0053   set(WITH_APPS "Qt;CLI" CACHE STRING "build applications (Qt;CLI;Test)")
0054 elseif(ANDROID)
0055   set(WITH_DBUS OFF CACHE BOOL "build with QtDBus")
0056   set(WITH_APPS "Qml" CACHE STRING "build applications (Qml;Qt;CLI;Test)")
0057 else()
0058   set(WITH_DBUS ON CACHE BOOL "build with QtDBus")
0059   set(WITH_APPS "Qt;CLI;KDE" CACHE STRING "build applications (Qt;CLI;KDE;Test)")
0060 endif()
0061 if(WIN32)
0062   set(WITH_READLINE OFF CACHE BOOL "build with readline")
0063 else()
0064   set(WITH_READLINE ON CACHE BOOL "build with readline")
0065 endif()
0066 
0067 if(DEFINED WITH_KDE)
0068   unset(WITH_KDE CACHE)
0069   message(FATAL_ERROR "The variable WITH_KDE is no longer used. The KDE and Qt "
0070                       "applications can now be built together using common "
0071                       "libraries. Use WITH_APPS with a value of \"KDE\" for "
0072                       "the KDE application, \"Qt\" for the Qt application, "
0073                       "\"CLI\" for the command line application or "
0074                       "\"Qt;CLI;KDE\" for all. Default is -DWITH_APPS="
0075                       "\"${WITH_APPS}\".")
0076 endif()
0077 
0078 if(WITH_APPS)
0079   string(TOLOWER "${WITH_APPS}" _apps_lower)
0080   foreach(_app ${_apps_lower})
0081     if(_app STREQUAL "qt")
0082       set(BUILD_QT_APP ON)
0083     elseif(_app STREQUAL "qml")
0084       set(BUILD_QML_APP ON)
0085       set(WITH_QML ON)
0086     elseif(_app STREQUAL "cli")
0087       set(BUILD_CLI_APP ON)
0088     elseif(_app STREQUAL "kde")
0089       set(BUILD_KDE_APP ON)
0090     elseif(_app STREQUAL "test")
0091       set(BUILD_TEST_APP ON)
0092     else()
0093       message(SEND_ERROR "Invalid value ${_app} in WITH_APPS. "
0094                          "Supported applications are \"Qt;KDE;Test\".")
0095     endif()
0096   endforeach()
0097 endif()
0098 
0099 if(NOT BUILD_SHARED_LIBS AND WITH_QML)
0100   message(WARNING "Switching off WITH_QML because of static build")
0101   set(WITH_QML OFF)
0102   set(BUILD_QML_APP OFF)
0103 endif()
0104 
0105 
0106 # Version information
0107 set(CPACK_PACKAGE_VERSION_MAJOR 3)
0108 set(CPACK_PACKAGE_VERSION_MINOR 9)
0109 set(CPACK_PACKAGE_VERSION_PATCH 2)
0110 set(KID3_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
0111 set(CPACK_PACKAGE_VERSION ${KID3_VERSION})
0112 #set(CPACK_PACKAGE_VERSION "git20210123")
0113 set(RELEASE_YEAR 2022)
0114 
0115 # Platform specific default installation paths
0116 if(APPLE)
0117   set(WITH_DATAROOTDIR_DEFAULT "kid3.app/Contents/Resources")
0118   set(WITH_DOCDIR_DEFAULT "kid3.app/Contents/Resources")
0119   set(WITH_TRANSLATIONSDIR_DEFAULT "kid3.app/Contents/Resources")
0120   set(WITH_QMLDIR_DEFAULT "kid3.app/Contents/Resources/qml")
0121   set(WITH_BINDIR_DEFAULT ".")
0122   set(WITH_LIBDIR_DEFAULT "kid3.app/Contents/MacOS")
0123   set(WITH_PLUGINSDIR_DEFAULT "kid3.app/Contents/PlugIns")
0124 elseif(WIN32)
0125   set(WITH_DATAROOTDIR_DEFAULT ".")
0126   set(WITH_DOCDIR_DEFAULT ".")
0127   set(WITH_TRANSLATIONSDIR_DEFAULT ".")
0128   set(WITH_QMLDIR_DEFAULT "./qml")
0129   set(WITH_BINDIR_DEFAULT ".")
0130   set(WITH_LIBDIR_DEFAULT ".")
0131   set(WITH_PLUGINSDIR_DEFAULT "./plugins")
0132 elseif(ANDROID)
0133   set(WITH_DATAROOTDIR_DEFAULT ".")
0134   set(WITH_DOCDIR_DEFAULT ".")
0135   set(WITH_TRANSLATIONSDIR_DEFAULT ":/translations")
0136   set(WITH_QMLDIR_DEFAULT ":/")
0137   set(WITH_BINDIR_DEFAULT ".")
0138   set(WITH_LIBDIR_DEFAULT ".")
0139   set(WITH_PLUGINSDIR_DEFAULT ".")
0140   set(QT_ANDROID_APP_VERSION ${KID3_VERSION})
0141   set(QT_ANDROID_APP_VERSION_CODE 26)
0142 else()
0143   set(WITH_DATAROOTDIR_DEFAULT "share")
0144   set(WITH_DOCDIR_DEFAULT "share/doc/kid3-qt")
0145   if(BUILD_KDE_APP OR BUILD_SHARED_LIBS)
0146     set(WITH_TRANSLATIONSDIR_DEFAULT "share/kid3/translations")
0147   else()
0148     set(WITH_TRANSLATIONSDIR_DEFAULT "share/kid3-qt/translations")
0149   endif()
0150   set(WITH_QMLDIR_DEFAULT "share/kid3/qml")
0151   set(WITH_BINDIR_DEFAULT "bin")
0152   set(WITH_LIBDIR_DEFAULT "lib${LIB_SUFFIX}/kid3")
0153   set(WITH_PLUGINSDIR_DEFAULT "${WITH_LIBDIR_DEFAULT}/plugins")
0154 endif()
0155 
0156 set(WITH_DATAROOTDIR ${WITH_DATAROOTDIR_DEFAULT} CACHE STRING
0157     "data root directory relative to CMAKE_INSTALL_PREFIX")
0158 if(BUILD_KDE_APP)
0159   set(WITH_DBUSDIR "share/dbus-1/interfaces" CACHE STRING
0160       "dbus directory relative to CMAKE_INSTALL_PREFIX")
0161 endif()
0162 set(WITH_DOCDIR ${WITH_DOCDIR_DEFAULT} CACHE STRING
0163     "documentation directory relative to CMAKE_INSTALL_PREFIX")
0164 set(WITH_TRANSLATIONSDIR ${WITH_TRANSLATIONSDIR_DEFAULT} CACHE STRING
0165     "translations directory relative to CMAKE_INSTALL_PREFIX")
0166 set(WITH_BINDIR ${WITH_BINDIR_DEFAULT} CACHE STRING
0167     "binary directory relative to CMAKE_INSTALL_PREFIX")
0168 set(WITH_LIBDIR ${WITH_LIBDIR_DEFAULT} CACHE STRING
0169     "library directory relative to CMAKE_INSTALL_PREFIX")
0170 set(WITH_PLUGINSDIR ${WITH_PLUGINSDIR_DEFAULT} CACHE STRING
0171     "plugin directory relative to CMAKE_INSTALL_PREFIX")
0172 set(WITH_MANDIR ${WITH_DATAROOTDIR}/man CACHE STRING
0173     "man documentation directory relative to CMAKE_INSTALL_PREFIX")
0174 set(WITH_QMLDIR ${WITH_QMLDIR_DEFAULT} CACHE STRING
0175     "QML directory relative to CMAKE_INSTALL_PREFIX")
0176 if(CMAKE_INSTALL_PREFIX)
0177   set(CMAKE_INSTALL_PREFIX_SLASH "${CMAKE_INSTALL_PREFIX}/")
0178 else()
0179   set(CMAKE_INSTALL_PREFIX_SLASH "")
0180 endif()
0181 
0182 if(APPLE)
0183   file(RELATIVE_PATH CFG_DATAROOTDIR "/kid3.app/Contents/MacOS" /${WITH_DATAROOTDIR})
0184   file(RELATIVE_PATH CFG_DOCDIR "/kid3.app/Contents/MacOS" /${WITH_DOCDIR})
0185   file(RELATIVE_PATH CFG_TRANSLATIONSDIR "/kid3.app/Contents/MacOS" /${WITH_TRANSLATIONSDIR})
0186   file(RELATIVE_PATH CFG_QMLDIR "/kid3.app/Contents/MacOS" /${WITH_QMLDIR})
0187   file(RELATIVE_PATH CFG_PLUGINSDIR "/kid3.app/Contents/MacOS" /${WITH_PLUGINSDIR})
0188 elseif(WIN32)
0189   # When building with KDE craft, CMAKE_INSTALL_PREFIX would introduce paths inside the
0190   # CraftRoot. Remove the prefix and assume WITH_BINDIR to be the default ".".
0191   set(CFG_DATAROOTDIR ${WITH_DATAROOTDIR})
0192   set(CFG_DOCDIR ${WITH_DOCDIR})
0193   set(CFG_TRANSLATIONSDIR ${WITH_TRANSLATIONSDIR})
0194   set(CFG_QMLDIR ${WITH_QMLDIR})
0195   file(RELATIVE_PATH CFG_PLUGINSDIR /${WITH_BINDIR} /${WITH_PLUGINSDIR})
0196 else()
0197   set(CFG_DATAROOTDIR ${CMAKE_INSTALL_PREFIX_SLASH}${WITH_DATAROOTDIR})
0198   set(CFG_DOCDIR ${CMAKE_INSTALL_PREFIX_SLASH}${WITH_DOCDIR})
0199   set(CFG_TRANSLATIONSDIR ${CMAKE_INSTALL_PREFIX_SLASH}${WITH_TRANSLATIONSDIR})
0200   set(CFG_QMLDIR ${CMAKE_INSTALL_PREFIX_SLASH}${WITH_QMLDIR})
0201   file(RELATIVE_PATH CFG_PLUGINSDIR /${WITH_BINDIR} /${WITH_PLUGINSDIR})
0202 endif()
0203 if(CFG_PLUGINSDIR STREQUAL "")
0204   set(CFG_PLUGINSDIR ".")
0205 endif()
0206 if(WITH_QMLDIR MATCHES "^:/")
0207   set(HAVE_QMLDIR_IN_QRC 1)
0208 endif()
0209 if(WITH_TRANSLATIONSDIR MATCHES "^:/")
0210   set(HAVE_TRANSLATIONSDIR_IN_QRC 1)
0211 endif()
0212 set(CFG_QMLSRCDIR "${kid3_SOURCE_DIR}/src/qml")
0213 
0214 find_package(Threads)
0215 include(CTest)
0216 if(CMAKE_VERSION VERSION_LESS 3.12.0)
0217   set(Python_ADDITIONAL_VERSIONS 3)
0218   find_package(PythonInterp REQUIRED)
0219   # PythonInterp sets PYTHON_EXECUTABLE
0220 else()
0221   find_package(Python3 COMPONENTS Interpreter REQUIRED)
0222   set(PYTHON_EXECUTABLE "${Python3_EXECUTABLE}")
0223 endif()
0224 include (CheckCXXSourceCompiles)
0225 include (CheckCXXCompilerFlag)
0226 include (CheckLibraryExists)
0227 
0228 # Find Qt
0229 set(_qtDir)
0230 string(REGEX MATCH "^(.*[Qq]t[/\\]?([56]).*).bin.qmake.*" _qtDir "${QT_QMAKE_EXECUTABLE}")
0231 if(_qtDir)
0232   set(_qtDir ${CMAKE_MATCH_1})
0233   set(_qtVersionMajor ${CMAKE_MATCH_2})
0234   set(QT_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}")
0235   set(Qt${_qtVersionMajor}Core_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}Core")
0236   set(Qt${_qtVersionMajor}CoreTools_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}CoreTools")
0237   set(Qt${_qtVersionMajor}_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}")
0238   set(Qt${_qtVersionMajor}Gui_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}Gui")
0239   set(Qt${_qtVersionMajor}GuiTools_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}GuiTools")
0240   set(Qt${_qtVersionMajor}Widgets_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}Widgets")
0241   set(Qt${_qtVersionMajor}WidgetsTools_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}WidgetsTools")
0242   set(Qt${_qtVersionMajor}Network_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}Network")
0243   set(Qt${_qtVersionMajor}Xml_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}Xml")
0244   if(WITH_MULTIMEDIA)
0245     set(Qt${_qtVersionMajor}Multimedia_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}Multimedia")
0246   endif()
0247   set(Qt${_qtVersionMajor}LinguistTools_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}LinguistTools")
0248   set(Qt${_qtVersionMajor}Test_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}Test")
0249   if(WITH_DBUS)
0250     set(Qt${_qtVersionMajor}DBusTools_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}DBusTools")
0251     set(Qt${_qtVersionMajor}DBus_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}DBus")
0252   endif()
0253   if(WITH_QML)
0254     set(Qt${_qtVersionMajor}Qml_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}Qml")
0255     set(Qt${_qtVersionMajor}QmlTools_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}QmlTools")
0256     set(Qt${_qtVersionMajor}Quick_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}Quick")
0257   endif()
0258   if(BUILD_QML_APP)
0259     set(Qt${_qtVersionMajor}Svg_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}Svg")
0260     set(Qt${_qtVersionMajor}QuickControls2_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}QuickControls2")
0261   endif()
0262   if(ANDROID)
0263     set(Qt${_qtVersionMajor}AndroidExtras_DIR "${_qtDir}/lib/cmake/Qt${_qtVersionMajor}AndroidExtras")
0264   endif()
0265 endif()
0266 find_package(QT NAMES Qt5 Qt6 COMPONENTS Core REQUIRED)
0267 if(QT_VERSION_MAJOR EQUAL 6 AND QT_VERSION_MINOR LESS 2)
0268   set(WITH_MULTIMEDIA OFF)
0269 endif()
0270 set(_qtComponents Core Gui Widgets Network Xml LinguistTools)
0271 if(WITH_MULTIMEDIA)
0272   set(_qtComponents ${_qtComponents} Multimedia)
0273 endif()
0274 if(BUILD_TESTING)
0275   set(_qtComponents ${_qtComponents} Test)
0276 endif()
0277 if(WITH_DBUS)
0278   set(_qtComponents ${_qtComponents} DBus)
0279 endif()
0280 if(WITH_QML)
0281   set(_qtComponents ${_qtComponents} Qml Quick)
0282 endif()
0283 if(BUILD_QML_APP)
0284   set(_qtComponents ${_qtComponents} Svg QuickControls2)
0285 endif()
0286 if(ANDROID)
0287   set(_qtComponents ${_qtComponents} AndroidExtras)
0288 endif()
0289 find_package(Qt${QT_VERSION_MAJOR} COMPONENTS ${_qtComponents} REQUIRED)
0290 
0291 if(WITH_DBUS)
0292   set(HAVE_QTDBUS 1)
0293 endif()
0294 if(WITH_MULTIMEDIA)
0295   set(HAVE_QTMULTIMEDIA 1)
0296 endif()
0297 get_target_property(QT_LIBRARY_DIR Qt${QT_VERSION_MAJOR}::Core LOCATION)
0298 get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} PATH)
0299 if(APPLE)
0300   # For Mac Qt5.5.0 QT_LIBRARY_DIR is wrong
0301   # (<installdir>/Qt5.5.0/5.5/clang_64/lib/QtCore.framework),
0302   # also for Mac Qt6.2.2 it is wrong
0303   # (<installdir>/6.2.2/macos/lib/QtCore.framework/Versions/A), fix it.
0304   string(REGEX MATCH "^(.*)/QtCore.framework.*$" _qtLibDir "${QT_LIBRARY_DIR}")
0305   if(_qtLibDir)
0306     set(QT_LIBRARY_DIR ${CMAKE_MATCH_1})
0307   endif()
0308 endif()
0309 if(TARGET Qt${QT_VERSION_MAJOR}::lupdate)
0310   get_target_property(QT_LUPDATE_EXECUTABLE Qt${QT_VERSION_MAJOR}::lupdate LOCATION)
0311 endif()
0312 if(TARGET Qt${QT_VERSION_MAJOR}::QJpegPlugin)
0313   get_target_property(QT_PLUGINS_DIR Qt${QT_VERSION_MAJOR}::QJpegPlugin LOCATION)
0314 endif()
0315 if(QT_PLUGINS_DIR)
0316   get_filename_component(QT_PLUGINS_DIR ${QT_PLUGINS_DIR} PATH)
0317   get_filename_component(QT_PLUGINS_DIR ${QT_PLUGINS_DIR} PATH)
0318 elseif(_qtDir)
0319   set(QT_PLUGINS_DIR ${_qtDir}/plugins)
0320 else()
0321   # Before Qt 5.2 and with Qt 6, there seems to be no way to get the plugins directory.
0322   # Assume it is on the same level as the bin directory.
0323   get_target_property(_qmakeLocation Qt${QT_VERSION_MAJOR}::qmake LOCATION)
0324   get_filename_component(QT_PLUGINS_DIR ${_qmakeLocation} PATH)
0325   get_filename_component(QT_PLUGINS_DIR ${QT_PLUGINS_DIR} PATH)
0326   set(QT_PLUGINS_DIR ${QT_PLUGINS_DIR}/plugins)
0327 endif()
0328 
0329 if(QT_VERSION VERSION_LESS 5.15)
0330   function(qt_wrap_cpp outfiles)
0331     qt5_wrap_cpp("${outfiles}" ${ARGN})
0332     set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
0333   endfunction()
0334 
0335   function(qt_add_resources outfiles)
0336     qt5_add_resources("${outfiles}" ${ARGN})
0337     set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
0338   endfunction()
0339 
0340   function(qt_add_translation _qm_files)
0341     qt5_add_translation("${_qm_files}" ${ARGN})
0342     set("${_qm_files}" "${${_qm_files}}" PARENT_SCOPE)
0343   endfunction()
0344 endif()
0345 
0346 get_target_property(_qmakeLocation Qt${QT_VERSION_MAJOR}::qmake LOCATION)
0347 message(STATUS "Found Qt-Version ${QT_VERSION} (using ${_qmakeLocation})")
0348 
0349 if(LINUX_SELF_CONTAINED)
0350   set(CPACK_INSTALL_PREFIX "")
0351   # Avoid GLIBC_2.14 not found errors on older systems like Debian Wheezy.
0352   # https://stackoverflow.com/questions/8823267/linking-against-older-symbol-version-in-a-so-file
0353   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -include ${CMAKE_CURRENT_SOURCE_DIR}/linux/glibc_version_nightmare.h")
0354   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include ${CMAKE_CURRENT_SOURCE_DIR}/linux/glibc_version_nightmare.h")
0355   # Use RPATH instead of RUNPATH, the RPATH of the loading executable has to be used, see
0356   # https://www.qt.io/blog/2011/10/28/rpath-and-runpath
0357   set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--disable-new-dtags")
0358   set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--disable-new-dtags")
0359 endif()
0360 
0361 # Check that QT_NO_DEBUG is defined for release configurations
0362 foreach(_buildType RELWITHDEBINFO RELEASE MINSIZEREL)
0363   if(NOT CMAKE_CXX_FLAGS_${_buildType} MATCHES "-DQT_NO_DEBUG")
0364     set(CMAKE_CXX_FLAGS_${_buildType} "${CMAKE_CXX_FLAGS_${_buildType}} -DQT_NO_DEBUG")
0365   endif()
0366 endforeach()
0367 
0368 ### Check for xsltproc
0369 find_program(XSLTPROC xsltproc DOC "xsltproc transforms XML via XSLT"
0370   PATHS $ENV{XSLTPROCDIR})
0371 if(NOT XSLTPROC)
0372   message(FATAL_ERROR "Could not find xsltproc")
0373 endif()
0374 
0375 ### Check for HTML docbook.xsl
0376 file(GLOB _versionedStyleSheetDir /usr/share/xml/docbook/xsl-stylesheets-*)
0377 find_path(DOCBOOK_XSL_DIR xhtml/docbook.xsl
0378   PATHS ${WITH_DOCBOOKDIR}
0379         /usr/share/xml/docbook/stylesheet/nwalsh
0380         /usr/share/xml/docbook/stylesheet/nwalsh/current
0381         /usr/share/xml/docbook/stylesheet/docbook-xsl
0382         /usr/share/xml/docbook/stylesheet/docbook-xsl-ns
0383         /usr/share/sgml/docbook/xsl-stylesheets
0384         /usr/share/apps/ksgmltools2/docbook/xsl
0385        ${_versionedStyleSheetDir}
0386        $ENV{DOCBOOKDIR}
0387        $ENV{HOME}/docbook-xsl-1.72.0
0388   NO_DEFAULT_PATH)
0389 if(NOT DOCBOOK_XSL_DIR)
0390   message(FATAL_ERROR "Could not find HTML docbook.xsl")
0391 endif()
0392 
0393 if(WIN32)
0394   link_directories($ENV{LIB})
0395 endif()
0396 
0397 if(BUILD_SHARED_LIBS)
0398   add_definitions(-DKID3_SHARED)
0399 
0400   # the RPATH to be used when installing, but only if it's not a system directory
0401   # see https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
0402   set(_prefixLibdir "${CMAKE_INSTALL_PREFIX}/${WITH_LIBDIR}")
0403   list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${_prefixLibdir}" _isSystemDir)
0404   if("${_isSystemDir}" STREQUAL "-1")
0405     list(FIND CMAKE_INSTALL_RPATH "${_prefixLibdir}" _rpathContainsLibdir)
0406     if("${_rpathContainsLibdir}" STREQUAL "-1")
0407       list(APPEND CMAKE_INSTALL_RPATH "${_prefixLibdir}")
0408       if(CMAKE_SKIP_RPATH AND NOT ANDROID)
0409         message(WARNING
0410           "RPATH needs to be set to \"${_prefixLibdir}\" but CMAKE_SKIP_RPATH "
0411           "is set! Disable CMAKE_SKIP_RPATH or set WITH_LIBDIR (which is now "
0412           "\"${WITH_LIBDIR}\") to a system directory, "
0413           "e.g. \"-DWITH_LIBDIR=lib\".")
0414       endif()
0415     endif()
0416   endif()
0417 endif()
0418 
0419 ### Check for zlib
0420 if(WIN32)
0421   if(NOT MSVC)
0422     find_library(_ZLIB_PATH_NAME z)
0423     if(_ZLIB_PATH_NAME)
0424       get_filename_component(_ZLIB_PATH ${_ZLIB_PATH_NAME} PATH)
0425     else()
0426       message(FATAL_ERROR "Could not find zlib")
0427     endif()
0428     set(ZLIB_LIBRARIES "-L${_ZLIB_PATH}" -lz)
0429   endif()
0430 else()
0431   set(ZLIB_LIBRARIES -lz)
0432 endif()
0433 
0434 ### Check for QML
0435 if(WITH_QML AND (QT_QTDECLARATIVE_FOUND OR Qt${QT_VERSION_MAJOR}Qml_FOUND))
0436   set(HAVE_QML 1)
0437 endif()
0438 
0439 ### Check for libQtDBus
0440 if(WITH_DBUS AND QT_QTDBUS_LIBRARY)
0441   set(HAVE_QTDBUS 1)
0442 endif()
0443 
0444 ### Check for mntent.h
0445 include(CheckIncludeFile)
0446 check_include_file("mntent.h" HAVE_MNTENT_H)
0447 
0448 
0449 if(CMAKE_COMPILER_IS_GNUCC)
0450   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wundef -Wcast-align -Wall -W -Wpointer-arith -D_REENTRANT")
0451 endif()
0452 if(CMAKE_COMPILER_IS_GNUCXX)
0453   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wundef -Wcast-align -Wall -W -Wpointer-arith -fno-check-new -fno-common -D_REENTRANT")
0454   check_cxx_compiler_flag(-Woverloaded-virtual _HAVE_W_OVERLOADED_VIRTUAL)
0455   if(_HAVE_W_OVERLOADED_VIRTUAL)
0456     set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
0457   endif()
0458 endif()
0459 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
0460   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wundef -Wcast-align -Wall -W -Wpointer-arith -D_REENTRANT")
0461   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wundef -Wcast-align -Wall -W -Wpointer-arith -Woverloaded-virtual -fno-common -Werror=return-type -Wweak-vtables -D_REENTRANT")
0462 endif()
0463 if(APPLE)
0464   exec_program(sw_vers ARGS -productVersion OUTPUT_VARIABLE _osxVersion)
0465   if(_osxVersion VERSION_LESS "10.10" AND NOT CMAKE_CXX_COMPILER MATCHES "/osxcross/")
0466     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.5")
0467     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.5")
0468   else()
0469     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.7")
0470     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7 -stdlib=libc++")
0471     set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -stdlib=libc++")
0472   endif()
0473 endif()
0474 include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
0475 
0476 if(NOT WIN32)
0477   check_cxx_compiler_flag(-fvisibility=hidden _HAVE_GCC_VISIBILITY)
0478   if(_HAVE_GCC_VISIBILITY)
0479     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
0480     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden")
0481   endif()
0482 endif()
0483 
0484 if(UNIX AND NOT APPLE)
0485   set(KID3_EXECUTABLE kid3-qt)
0486 else()
0487   set(KID3_EXECUTABLE kid3)
0488 endif()
0489 
0490 configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
0491 
0492 if(APPLE AND CMAKE_STRIP)
0493   # Do something against these error messages starting with
0494   # strip: symbols referenced by indirect symbol table entries that can't be stripped in
0495   configure_file(${CMAKE_CURRENT_SOURCE_DIR}/strip_silent.sh.in
0496                  ${CMAKE_CURRENT_BINARY_DIR}/strip_silent.sh
0497                  @ONLY)
0498   set(CMAKE_STRIP "${CMAKE_CURRENT_BINARY_DIR}/strip_silent.sh")
0499 endif()
0500 
0501 add_subdirectory(src)
0502 add_subdirectory(doc)
0503 add_subdirectory(translations)
0504 
0505 if(ANDROID)
0506   add_subdirectory(android)
0507 endif()
0508 
0509 
0510 if(BUILD_TESTING)
0511   add_test(NAME test_cli_functions
0512            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/src/test/test_cli_functions.py)
0513   add_custom_target(check ${CMAKE_CTEST_COMMAND} --output-on-failure)
0514   if(NOT CMAKE_VERSION VERSION_LESS "3.17")
0515     list(APPEND CMAKE_CTEST_ARGUMENTS --output-on-failure)
0516   endif()
0517 endif()
0518 
0519 
0520 # To create a package, run cpack
0521 if(APPLE)
0522   set(CPACK_BINARY_DRAGNDROP ON)
0523   set(CPACK_GENERATOR DragNDrop)
0524 elseif(WIN32)
0525   set(CPACK_GENERATOR ZIP)
0526 elseif(LINUX_SELF_CONTAINED)
0527   set(CPACK_GENERATOR TGZ)
0528 else()
0529   set(CPACK_GENERATOR DEB)
0530 endif()
0531 
0532 if(BUILD_KDE_APP OR APPLE OR WIN32 OR LINUX_SELF_CONTAINED)
0533   set(CPACK_PACKAGE_NAME "kid3")
0534   set(CPACK_DEBIAN_PACKAGE_SECTION "kde")
0535 else()
0536   set(CPACK_PACKAGE_NAME "kid3-qt")
0537   set(CPACK_DEBIAN_PACKAGE_SECTION "sound")
0538 endif()
0539 set(CPACK_PACKAGE_CONTACT "ufleisch@users.sourceforge.net")
0540 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Audio tag editor")
0541 set(CPACK_STRIP_FILES ON)
0542 set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://kid3.kde.org/")
0543 set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
0544 set(CPACK_SET_DESTDIR ON)
0545 
0546 include(CPack)