Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -22,7 +22,6 @@ ${PC_AVCODEC_INCLUDEDIR} ${PC_AVFORMAT_INCLUDEDIR} ${FFMPEG_INCLUDE_DIR} - ${TAGLIB_INCLUDES} ) # Certain versions of FFMPEG need this to be defined @@ -41,7 +40,7 @@ kconfig_add_kcfg_files(ffmpegthumbs_PART_SRCS ffmpegthumbnailersettings5.kcfgc) add_library(ffmpegthumbs MODULE ${ffmpegthumbs_PART_SRCS}) -target_link_libraries(ffmpegthumbs Qt5::Core Qt5::Gui KF5::KIOWidgets KF5::KIOCore KF5::I18n KF5::ConfigCore KF5::ConfigGui ${AVUTIL_LIBRARIES} ${AVFILTER_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVCODEC_LIBRARIES} ${SWSCALE_LIBRARIES} ${TAGLIB_LIBRARIES} ) +target_link_libraries(ffmpegthumbs Qt5::Core Qt5::Gui KF5::KIOWidgets KF5::KIOCore KF5::I18n KF5::ConfigCore KF5::ConfigGui ${AVUTIL_LIBRARIES} ${AVFILTER_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVCODEC_LIBRARIES} ${SWSCALE_LIBRARIES} Taglib::Taglib ) install(FILES ffmpegthumbnailersettings5.kcfg DESTINATION ${KCFG_INSTALL_DIR}) install(TARGETS ffmpegthumbs DESTINATION ${PLUGIN_INSTALL_DIR}) Index: cmake/FindTaglib.cmake =================================================================== --- cmake/FindTaglib.cmake +++ cmake/FindTaglib.cmake @@ -1,93 +1,90 @@ -# - Try to find the Taglib library -# Once done this will define +#.rst: +# FindTaglib +#----------- # -# TAGLIB_FOUND - system has the taglib library -# TAGLIB_INCLUDES - the taglib includes -# TAGLIB_LIBRARIES - The libraries needed to use taglib - -# Copyright (c) 2006, Laurent Montel, +# Try to find the Taglib library. # -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. +# This will define the following variables: # -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. - -if(NOT TAGLIB_MIN_VERSION) - set(TAGLIB_MIN_VERSION "1.4") -endif(NOT TAGLIB_MIN_VERSION) +# ``Taglib_FOUND`` +# True if the system has the taglib library of at least the minimum +# version specified by the version parameter to find_package() +# ``Taglib_INCLUDE_DIRS`` +# The taglib include dirs for use with target_include_directories +# ``Taglib_LIBRARIES`` +# The taglib libraries for use with target_link_libraries() +# ``Taglib_VERSION`` +# The version of taglib that was found +# +# If ``Taglib_FOUND is TRUE, it will also define the following imported +# target: +# +# ``Taglib::Taglib`` +# The Taglib library +# +# Since 5.72.0 +# +# SPDX-FileCopyrightText: 2006 Laurent Montel +# SPDX-FileCopyrightText: 2019 Heiko Becker +# SPDX-FileCopyrightText: 2020 Elvis Angelaccio +# SPDX-License-Identifier: BSD-3-Clause -if(NOT WIN32) - find_program(TAGLIBCONFIG_EXECUTABLE NAMES taglib-config PATHS - ${BIN_INSTALL_DIR} - ) -endif(NOT WIN32) +find_package(PkgConfig QUIET) -#reset vars -set(TAGLIB_LIBRARIES) -set(TAGLIB_CFLAGS) +pkg_search_module(PC_TAGLIB QUIET taglib) -# if taglib-config has been found -if(TAGLIBCONFIG_EXECUTABLE) +find_path(Taglib_INCLUDE_DIRS + NAMES tag.h + PATH_SUFFIXES taglib + HINTS ${PC_TAGLIB_INCLUDEDIR} +) - exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_VERSION) +find_library(Taglib_LIBRARIES + NAMES tag + HINTS ${PC_TAGLIB_LIBDIR} +) - exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_LIBRARIES) +set(Taglib_VERSION ${PC_TAGLIB_VERSION}) - exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_CFLAGS) +if (Taglib_INCLUDE_DIRS AND NOT Taglib_VERSION) + if(EXISTS "${Taglib_INCLUDE_DIRS}/taglib.h") + file(READ "${Taglib_INCLUDE_DIRS}/taglib.h" TAGLIB_H) - # Assume software will include by things like #include instead of - string(REPLACE "/taglib" "" TAGLIB_STRIPPED_INCLUDE_PATHS "${TAGLIB_CFLAGS}") - string(REGEX REPLACE " *-I" ";" TAGLIB_INCLUDES "${TAGLIB_STRIPPED_INCLUDE_PATHS}") + string(REGEX MATCH "#define TAGLIB_MAJOR_VERSION[ ]+[0-9]+" TAGLIB_MAJOR_VERSION_MATCH ${TAGLIB_H}) + string(REGEX MATCH "#define TAGLIB_MINOR_VERSION[ ]+[0-9]+" TAGLIB_MINOR_VERSION_MATCH ${TAGLIB_H}) + string(REGEX MATCH "#define TAGLIB_PATCH_VERSION[ ]+[0-9]+" TAGLIB_PATCH_VERSION_MATCH ${TAGLIB_H}) - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(Taglib FOUND_VAR TAGLIB_FOUND - REQUIRED_VARS TAGLIB_LIBRARIES TAGLIB_INCLUDES - VERSION_VAR TAGLIB_VERSION) - mark_as_advanced(TAGLIB_CFLAGS TAGLIB_LIBRARIES TAGLIB_INCLUDES) + string(REGEX REPLACE ".*_MAJOR_VERSION[ ]+(.*)" "\\1" TAGLIB_MAJOR_VERSION "${TAGLIB_MAJOR_VERSION_MATCH}") + string(REGEX REPLACE ".*_MINOR_VERSION[ ]+(.*)" "\\1" TAGLIB_MINOR_VERSION "${TAGLIB_MINOR_VERSION_MATCH}") + string(REGEX REPLACE ".*_PATCH_VERSION[ ]+(.*)" "\\1" TAGLIB_PATCH_VERSION "${TAGLIB_PATCH_VERSION_MATCH}") -else(TAGLIBCONFIG_EXECUTABLE) + set(Taglib_VERSION "${TAGLIB_MAJOR_VERSION}.${TAGLIB_MINOR_VERSION}.${TAGLIB_PATCH_VERSION}") + endif() +endif() - include(FindPackageHandleStandardArgs) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Taglib + FOUND_VAR + Taglib_FOUND + REQUIRED_VARS + Taglib_LIBRARIES + Taglib_INCLUDE_DIRS + VERSION_VAR + Taglib_VERSION +) - # To avoid issues, make the same assumption as above: - # Assume software will include by things like #include instead of - find_path(TAGLIB_INCLUDES - NAMES - taglib/tag.h - PATHS - ${INCLUDE_INSTALL_DIR} - ) +if (Taglib_FOUND AND NOT TARGET Taglib::Taglib) + add_library(Taglib::Taglib UNKNOWN IMPORTED) + set_target_properties(Taglib::Taglib PROPERTIES + IMPORTED_LOCATION "${Taglib_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${Taglib_INCLUDE_DIRS}" + ) +endif() - # TODO: this originally used find_library_with_debug(), - # which is only available with KDELibs4Support, with - # arguments "WIN32_DEBUG_POSTFIX d". It is equivalent - # to find_library on all platforms other than Win32. - find_library(TAGLIB_LIBRARIES - NAMES tag - PATHS - ${LIB_INSTALL_DIR} - ) +mark_as_advanced(Taglib_LIBRARIES Taglib_INCLUDE_DIRS) - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(Taglib DEFAULT_MSG - TAGLIB_INCLUDES TAGLIB_LIBRARIES) -endif(TAGLIBCONFIG_EXECUTABLE) +include(FeatureSummary) +set_package_properties(Taglib PROPERTIES + URL "https://taglib.org/" + DESCRIPTION "A library for reading and editing the meta-data of audio formats" +) Index: ffmpegthumbnailer.cpp =================================================================== --- ffmpegthumbnailer.cpp +++ ffmpegthumbnailer.cpp @@ -47,7 +47,8 @@ bool FFMpegThumbnailer::create(const QString& path, int width, int /*height*/, QImage& img) { - TagLib::MP4::File f(path.toStdString().c_str(), false); + QByteArray ba = path.toLocal8Bit(); + TagLib::MP4::File f(ba.data(), false); if (f.isValid()) { Index: tests/CMakeLists.txt =================================================================== --- tests/CMakeLists.txt +++ tests/CMakeLists.txt @@ -20,7 +20,7 @@ add_executable(ffmpegthumbtest ${ffmpegthumbtest_SRCS} ) -target_link_libraries(ffmpegthumbtest Qt5::Core Qt5::Gui KF5::KIOWidgets KF5::KIOCore KF5::I18n KF5::ConfigCore KF5::ConfigGui ${AVUTIL_LIBRARIES} ${AVFILTER_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVCODEC_LIBRARIES} ${SWSCALE_LIBRARIES} ${TAGLIB_LIBRARIES}) +target_link_libraries(ffmpegthumbtest Qt5::Core Qt5::Gui KF5::KIOWidgets KF5::KIOCore KF5::I18n KF5::ConfigCore KF5::ConfigGui ${AVUTIL_LIBRARIES} ${AVFILTER_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVCODEC_LIBRARIES} ${SWSCALE_LIBRARIES} Taglib::Taglib)