File 0001-copy-FindTaglib-from-ECM.patch of Package kio-extras5
From 025988c693544cdf45225bdf3b170686072dff3e Mon Sep 17 00:00:00 2001
From: Harald Sitter <sitter@kde.org>
Date: Fri, 31 Jul 2020 13:33:45 +0200
Subject: [PATCH] copy FindTaglib from ECM
slighlty more modern and sports an imported target which makes the using
more idiomatic from a modern cmake POV.
this was introduced in kf5.72 and is still super new, so I'm not too
excited about bumping the kf5 requirement just yet
---
CMakeLists.txt | 1 +
cmake/FindTaglib.cmake | 132 +++++++++++++++++++++++----------------
thumbnail/CMakeLists.txt | 10 ++-
3 files changed, 82 insertions(+), 61 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 002c0ecb..4f62de87 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,7 @@ project(kio-extras VERSION ${RELEASE_SERVICE_VERSION})
include(FeatureSummary)
set(QT_MIN_VERSION "5.11.0")
+# TODO: when bumping to 5.72+ drop FindTaglib.cmake
set(KF5_MIN_VERSION "5.66.0")
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS DBus Network Widgets Svg)
diff --git a/cmake/FindTaglib.cmake b/cmake/FindTaglib.cmake
index 00e8835d..479026e6 100644
--- a/cmake/FindTaglib.cmake
+++ b/cmake/FindTaglib.cmake
@@ -1,93 +1,92 @@
-# - Try to find the Taglib library
-# Once done this will define
-#
-# TAGLIB_FOUND - system has the taglib library
-# TAGLIB_INCLUDES - the taglib includes
-# TAGLIB_LIBRARIES - The libraries needed to use taglib
+# !!!! This is a copy from ECM, change there (as well) !!!!
#-# SPDX-License-Identifier: BSD-3-Clause
+#.rst:
+# FindTaglib
+# ----------
+#
+# Try to find the Taglib library.
+#
+# This will define the following variables:
+#
+# ``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
+#
-# Copyright (c) 2006, Laurent Montel, <montel@kde.org>
+# SPDX-FileCopyrightText: 2006 Laurent Montel <montel@kde.org>
+# SPDX-FileCopyrightText: 2019 Heiko Becker <heirecka@exherbo.org>
+# SPDX-FileCopyrightText: 2020 Elvis Angelaccio <elvis.angelaccio@kde.org>
+# SPDX-License-Identifier: BSD-3-Clause
-#
-# 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 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)
-
-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 <taglib/tfile.h> instead of <tfile.h>
- 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 <taglib/tfile.h> instead of <tfile.h>
- 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"
+)
diff --git a/thumbnail/CMakeLists.txt b/thumbnail/CMakeLists.txt
index 7b90897d..20ae5486 100644
--- a/thumbnail/CMakeLists.txt
+++ b/thumbnail/CMakeLists.txt
@@ -216,14 +216,12 @@ install(TARGETS kritathumbnail DESTINATION ${KDE_INSTALL_PLUGINDIR})
find_package(Taglib 1.11)
-if(TAGLIB_FOUND)
- set(audiothumbnail_SRCS audiocreator.cpp)
- add_library(audiothumbnail MODULE ${audiothumbnail_SRCS})
- target_include_directories(audiothumbnail BEFORE PRIVATE ${TAGLIB_INCLUDES})
- target_link_libraries(audiothumbnail ${TAGLIB_LIBRARIES} KF5::KIOWidgets)
+if(Taglib_FOUND)
+ add_library(audiothumbnail MODULE audiocreator.cpp)
+ target_link_libraries(audiothumbnail Taglib::Taglib KF5::KIOWidgets)
install(TARGETS audiothumbnail DESTINATION ${KDE_INSTALL_PLUGINDIR})
set(audiothumbnail_desktop audiothumbnail.desktop)
-endif(TAGLIB_FOUND)
+endif()
# ########### next target ###############
--
GitLab