Skip to content

Commit

Permalink
CMake: check for TagLib >= 1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Be-ing authored and uklotzde committed Aug 28, 2021
1 parent 68043a4 commit e42c162
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2366,10 +2366,7 @@ else()
endif()

# TagLib
# TODO: Check for minimum required version?
# See also: static_assert in src/track/taglib/trackmetadata_common.h
# that verifies TAGLIB_MAJOR_VERSION/TAGLIB_MINOR_VERSION.
find_package(TagLib REQUIRED)
find_package(TagLib 1.11 REQUIRED)
target_link_libraries(mixxx-lib PRIVATE TagLib::TagLib)

# Threads
Expand Down
26 changes: 23 additions & 3 deletions cmake/modules/FindTagLib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,32 @@ find_library(TagLib_LIBRARY
)
mark_as_advanced(TagLib_LIBRARY)

# Version detection
if(DEFINED PC_TagLib_VERSION)
set(TagLib_VERSION "${PC_TagLib_VERSION}")
else()
if (EXISTS "${TagLib_INCLUDE_DIR}/taglib.h")
file(READ "${TagLib_INCLUDE_DIR}/taglib.h" TagLib_H_CONTENTS)
string(REGEX MATCH "#define TAGLIB_MAJOR_VERSION ([0-9]+)" _dummy "${TagLib_H_CONTENTS}")
set(TagLib_VERSION_MAJOR "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define TAGLIB_MINOR_VERSION ([0-9]+)" _dummy "${TagLib_H_CONTENTS}")
set(TagLib_VERSION_MINOR "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define TAGLIB_PATCH_VERSION ([0-9]+)" _dummy "${TagLib_H_CONTENTS}")
set(TagLib_VERSION_PATCH "${CMAKE_MATCH_1}")
# Simply using if(NOT) does not work because 0 is a valid value, so compare to empty string.
if (NOT TagLib_VERSION_MAJOR STREQUAL "" AND
NOT TagLib_VERSION_MINOR STREQUAL "" AND
NOT TagLib_VERSION_PATCH STREQUAL "")
set(TagLib_VERSION "${TagLib_VERSION_MAJOR}.${TagLib_VERSION_MINOR}.${TagLib_VERSION_PATCH}")
endif()
endif()
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
TagLib
DEFAULT_MSG
TagLib_LIBRARY
TagLib_INCLUDE_DIR
REQUIRED_VARS TagLib_LIBRARY TagLib_INCLUDE_DIR
VERSION_VAR TagLib_VERSION
)

if(TagLib_FOUND)
Expand Down
5 changes: 0 additions & 5 deletions src/track/taglib/trackmetadata_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <QFlags>
#include <QImage>
#include <QString>
#include <type_traits>

#if defined(__EXTRA_METADATA__)
// UUID -> QString
Expand All @@ -16,10 +15,6 @@

#include "track/trackmetadata.h"

static_assert(
TAGLIB_MAJOR_VERSION > 1 || (TAGLIB_MAJOR_VERSION == 1 && TAGLIB_MINOR_VERSION >= 11),
"TagLib 1.11 or newer is required");

namespace mixxx {

namespace taglib {
Expand Down

0 comments on commit e42c162

Please sign in to comment.