From 7c7b57e295aebcca9b09d8c5798e172cb8fd179c Mon Sep 17 00:00:00 2001 From: Andreas Sturmlechner Date: Mon, 13 Jul 2020 02:11:06 +0200 Subject: [PATCH] Import FindTaglib.cmake from ECM 5.72.0 This version of ECM gained a module that is overriding Tomahawk's own, but variables are incompatible. Use the updated ECM module until we can depend on the necessary ECM version itself. Signed-off-by: Andreas Sturmlechner --- CMakeLists.txt | 2 +- CMakeModules/CheckTagLibFileName.cmake | 5 +- CMakeModules/FindTaglib.cmake | 173 +++++++++++++------------ src/libtomahawk/CMakeLists.txt | 4 +- 4 files changed, 93 insertions(+), 91 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9422a808e..2f1e72238 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,7 +213,7 @@ macro_optional_find_package(Lucene++ 3.0.0) macro_log_feature(LUCENEPP_FOUND "Lucene++" "The open-source, C++ search engine" "https://github.com/luceneplusplus/LucenePlusPlus/" TRUE "" "Lucene++ is used for indexing the collection") macro_optional_find_package(Taglib 1.8.0) -macro_log_feature(TAGLIB_FOUND "TagLib" "Audio Meta-Data Library" "http://developer.kde.org/~wheeler/taglib.html" TRUE "" "taglib is needed for reading meta data from audio files") +macro_log_feature(Taglib_FOUND "TagLib" "Audio Meta-Data Library" "http://developer.kde.org/~wheeler/taglib.html" TRUE "" "taglib is needed for reading meta data from audio files") include( CheckTagLibFileName ) check_taglib_filename( COMPLEX_TAGLIB_FILENAME ) diff --git a/CMakeModules/CheckTagLibFileName.cmake b/CMakeModules/CheckTagLibFileName.cmake index e5b3706c9..7828dcf34 100644 --- a/CMakeModules/CheckTagLibFileName.cmake +++ b/CMakeModules/CheckTagLibFileName.cmake @@ -1,9 +1,8 @@ # taglib changed filenames to be a char/wchar struct on some platforms, need to check for it macro (CHECK_TAGLIB_FILENAME TAGLIB_FILENAME_COMPLEX) include (CheckCXXSourceCompiles) - set (CMAKE_REQUIRED_FLAGS ${TAGLIB_CFLAGS}) - set (CMAKE_REQUIRED_INCLUDES ${TAGLIB_INCLUDES}) - set (CMAKE_REQUIRED_LIBRARIES ${TAGLIB_LIBRARIES}) + set (CMAKE_REQUIRED_INCLUDES ${Taglib_INCLUDE_DIRS}) + set (CMAKE_REQUIRED_LIBRARIES ${Taglib_LIBRARIES}) check_cxx_source_compiles( "#include int main() diff --git a/CMakeModules/FindTaglib.cmake b/CMakeModules/FindTaglib.cmake index d4ada2592..ad14c79cd 100644 --- a/CMakeModules/FindTaglib.cmake +++ b/CMakeModules/FindTaglib.cmake @@ -1,87 +1,90 @@ -# - Try to find the Taglib library -# Once done this will define +#.rst: +# FindTaglib +# ---------- # -# TAGLIB_FOUND - system has the taglib library -# TAGLIB_CFLAGS - the taglib cflags -# TAGLIB_LIBRARIES - The libraries needed to use taglib - -# Copyright (c) 2006, Laurent Montel, +# Try to find the Taglib library. # -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -IF(TAGLIB_FOUND) - MESSAGE(STATUS "Using manually specified taglib locations") -ELSE() - - if(NOT TAGLIB_MIN_VERSION) - set(TAGLIB_MIN_VERSION "1.6") - endif(NOT TAGLIB_MIN_VERSION) - - if(NOT WIN32) - find_program(TAGLIBCONFIG_EXECUTABLE NAMES taglib-config PATHS - ${BIN_INSTALL_DIR} - ) - endif(NOT WIN32) - - #reset vars - set(TAGLIB_LIBRARIES) - set(TAGLIB_CFLAGS) - -# MESSAGE( STATUS "PATHS: ${PATHS}") - # if taglib-config has been found - if(TAGLIBCONFIG_EXECUTABLE) - - exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_VERSION) - - if(TAGLIB_VERSION VERSION_LESS "${TAGLIB_MIN_VERSION}") - message(STATUS "TagLib version not found: version searched :${TAGLIB_MIN_VERSION}, found ${TAGLIB_VERSION}") - set(TAGLIB_FOUND FALSE) - else(TAGLIB_VERSION VERSION_LESS "${TAGLIB_MIN_VERSION}") - - exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_LIBRARIES) - - exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_CFLAGS) - - if(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS) - set(TAGLIB_FOUND TRUE) -# message(STATUS "Found taglib: ${TAGLIB_LIBRARIES}") - endif(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS) - string(REGEX REPLACE " *-I" ";" TAGLIB_INCLUDES "${TAGLIB_CFLAGS}") - endif(TAGLIB_VERSION VERSION_LESS "${TAGLIB_MIN_VERSION}") - mark_as_advanced(TAGLIB_CFLAGS TAGLIB_LIBRARIES TAGLIB_INCLUDES) - - else(TAGLIBCONFIG_EXECUTABLE) - - include(FindLibraryWithDebug) - include(FindPackageHandleStandardArgs) - - find_path(TAGLIB_INCLUDES - NAMES - tag.h - PATH_SUFFIXES taglib - PATHS - ${INCLUDE_INSTALL_DIR} - ) - - find_library_with_debug(TAGLIB_LIBRARIES - WIN32_DEBUG_POSTFIX d - NAMES tag - PATHS - ${LIB_INSTALL_DIR} - ) - - find_package_handle_standard_args(Taglib DEFAULT_MSG - TAGLIB_INCLUDES TAGLIB_LIBRARIES) - endif(TAGLIBCONFIG_EXECUTABLE) -ENDIF() - -if(TAGLIB_FOUND) - if(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE) - message(STATUS "Found TagLib: ${TAGLIB_LIBRARIES}") - endif(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE) -else(TAGLIB_FOUND) - if(Taglib_FIND_REQUIRED) - message(FATAL_ERROR "Could not find Taglib") - endif(Taglib_FIND_REQUIRED) -endif(TAGLIB_FOUND) +# 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 +# +# SPDX-FileCopyrightText: 2006 Laurent Montel +# SPDX-FileCopyrightText: 2019 Heiko Becker +# SPDX-FileCopyrightText: 2020 Elvis Angelaccio +# SPDX-License-Identifier: BSD-3-Clause + +find_package(PkgConfig QUIET) + +pkg_search_module(PC_TAGLIB QUIET taglib) + +find_path(Taglib_INCLUDE_DIRS + NAMES tag.h + PATH_SUFFIXES taglib + HINTS ${PC_TAGLIB_INCLUDEDIR} +) + +find_library(Taglib_LIBRARIES + NAMES tag + HINTS ${PC_TAGLIB_LIBDIR} +) + +set(Taglib_VERSION ${PC_TAGLIB_VERSION}) + +if (Taglib_INCLUDE_DIRS AND NOT Taglib_VERSION) + if(EXISTS "${Taglib_INCLUDE_DIRS}/taglib.h") + file(READ "${Taglib_INCLUDE_DIRS}/taglib.h" TAGLIB_H) + + 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}) + + 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}") + + set(Taglib_VERSION "${TAGLIB_MAJOR_VERSION}.${TAGLIB_MINOR_VERSION}.${TAGLIB_PATCH_VERSION}") + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Taglib + FOUND_VAR + Taglib_FOUND + REQUIRED_VARS + Taglib_LIBRARIES + Taglib_INCLUDE_DIRS + VERSION_VAR + Taglib_VERSION +) + +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() + +mark_as_advanced(Taglib_LIBRARIES Taglib_INCLUDE_DIRS) + +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/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index 348d6b1dd..e0a342f0e 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -533,8 +533,8 @@ TARGET_LINK_LIBRARIES(${TOMAHAWK_LIBRARY} PRIVATE ) # TagLib -TARGET_LINK_LIBRARIES(${TOMAHAWK_LIBRARY} LINK_PUBLIC ${TAGLIB_LIBRARIES}) -TARGET_INCLUDE_DIRECTORIES(${TOMAHAWK_LIBRARY} PUBLIC ${TAGLIB_INCLUDES}) +TARGET_LINK_LIBRARIES(${TOMAHAWK_LIBRARY} LINK_PUBLIC ${Taglib_LIBRARIES}) +TARGET_INCLUDE_DIRECTORIES(${TOMAHAWK_LIBRARY} PUBLIC ${Taglib_INCLUDE_DIRS}) INSTALL( TARGETS ${TOMAHAWK_LIBRARY} EXPORT TomahawkLibraryDepends -- 2.27.0