kdelibs/cmake/modules/FindMusicBrainz5.cmake
Ivailo Monev 3eb17fdf2b cmake: review modules rewritten so far by me
using pkg-config search as primary method with fallback to path lookup,
this may result in overlinking however if libraries require additional
include paths (as is the case with PulseAudio) with this change that will
not be a problem.

it will also reduce the lookups done during configuration/build since path
lookups will not be done, unless pkg-config lookup does not set the
required variables.

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
2020-02-10 20:52:45 +00:00

46 lines
1.4 KiB
CMake

# - Try to find MusicBrainz
#
# Once done this will define
#
# MUSICBRAINZ5_FOUND - system has MusicBrainz
# MUSICBRAINZ5_INCLUDE_DIR - the MusicBrainz include directory
# MUSICBRAINZ5_LIBRARIES - The libraries needed to use MusicBrainz
#
# Copyright (c) 2020, Ivailo Monev, <xakepa10@gmail.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
if(MUSICBRAINZ5_INCLUDE_DIR AND MUSICBRAINZ5_LIBRARIES)
set(MUSICBRAINZ5_FIND_QUIETLY TRUE)
endif()
if(NOT WIN32)
include(FindPkgConfig)
pkg_check_modules(PC_MUSICBRAINZ5 QUIET libmusicbrainz5cc)
if(NOT PC_MUSICBRAINZ5_FOUND)
pkg_check_modules(PC_MUSICBRAINZ5 QUIET libmusicbrainz5)
endif()
set(MUSICBRAINZ5_INCLUDE_DIR ${PC_MUSICBRAINZ5_INCLUDE_DIRS})
set(MUSICBRAINZ5_LIBRARIES ${PC_MUSICBRAINZ5_LIBRARIES})
endif()
if(NOT MUSICBRAINZ5_INCLUDE_DIR OR NOT MUSICBRAINZ5_LIBRARIES)
find_path(MUSICBRAINZ5_INCLUDE_DIR
NAMES musicbrainz5/Disc.h
HINTS $ENV{MUSICBRAINZ5DIR}/include
)
find_library(MUSICBRAINZ5_LIBRARIES
NAMES musicbrainz5cc musicbrainz5
HINTS $ENV{MUSICBRAINZ5DIR}/lib
)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MusicBrainz5
VERSION_VAR PC_MUSICBRAINZ5_VERSION
REQUIRED_VARS MUSICBRAINZ5_LIBRARIES MUSICBRAINZ5_INCLUDE_DIR
)
mark_as_advanced(MUSICBRAINZ5_INCLUDE_DIR MUSICBRAINZ5_LIBRARIES)