mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 01:49:53 +00:00
cmake: fix LAME dependency search
This commit is contained in:
parent
33e765ccba
commit
eff5f0a640
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
* Searching for LAME dependency with CMake build system (issue #821).
|
||||
|
||||
## [1.1.0] - 2022-03-27
|
||||
|
||||
### Added
|
||||
|
@ -174,7 +174,7 @@ set_package_properties (FLAC PROPERTIES
|
||||
DESCRIPTION "Free Lossless Audio Codec Library"
|
||||
PURPOSE "Enables FLAC support"
|
||||
)
|
||||
set_package_properties (Lame PROPERTIES
|
||||
set_package_properties (mp3lame PROPERTIES
|
||||
TYPE RECOMMENDED
|
||||
URL "https://lame.sourceforge.io/"
|
||||
DESCRIPTION "High quality MPEG Audio Layer III (MP3) encoder"
|
||||
@ -237,20 +237,7 @@ if (INSTALL_PKGCONFIG_MODULE)
|
||||
endif ()
|
||||
if (ENABLE_MPEG)
|
||||
set (EXTERNAL_MPEG_REQUIRE "libmpg123")
|
||||
get_filename_component(LAME_WE ${LAME_LIBRARY} NAME_WE)
|
||||
if (LAME_HIP_LIBRARY)
|
||||
get_filename_component(LAME_HIP_WE ${LAME_HIP_LIBRARY} NAME_WE)
|
||||
endif ()
|
||||
if (CMAKE_IMPORT_LIBRARY_PREFIX)
|
||||
string (REGEX REPLACE "^${CMAKE_IMPORT_LIBRARY_PREFIX}" "" LAME_WE_NO_PREFIX ${LAME_WE})
|
||||
if (LAME_HIP_LIBRARY)
|
||||
string (REGEX REPLACE "^${CMAKE_IMPORT_LIBRARY_PREFIX}" "" LAME_HIP_WE_NO_PREFIX ${LAME_HIP_WE})
|
||||
endif ()
|
||||
endif ()
|
||||
set (EXTERNAL_MPEG_LIBS "-l${LAME_WE_NO_PREFIX}")
|
||||
if (LAME_HIP_LIBRARY)
|
||||
set (EXTERNAL_MPEG_LIBS "${MPEG_LIBS} -l${LAME_HIP_WE}")
|
||||
endif ()
|
||||
set (EXTERNAL_MPEG_LIBS "-lmp3lame")
|
||||
endif ()
|
||||
|
||||
configure_file (sndfile.pc.in sndfile.pc @ONLY)
|
||||
@ -411,7 +398,7 @@ target_link_libraries (sndfile
|
||||
$<$<AND:$<BOOL:${ENABLE_EXPERIMENTAL}>,$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>,$<BOOL:${HAVE_SPEEX}>>:Speex::Speex>
|
||||
$<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:Opus::opus>
|
||||
$<$<BOOL:${HAVE_MPEG}>:MPG123::libmpg123>
|
||||
$<$<BOOL:${HAVE_MPEG}>:Lame::Lame>
|
||||
$<$<BOOL:${HAVE_MPEG}>:mp3lame::mp3lame>
|
||||
)
|
||||
set_target_properties (sndfile PROPERTIES
|
||||
PUBLIC_HEADER "${sndfile_HDRS}"
|
||||
|
@ -1,66 +0,0 @@
|
||||
# - Find lame
|
||||
# Find the native lame includes and libraries
|
||||
#
|
||||
# LAME_INCLUDE_DIRS - where to find lame.h, etc.
|
||||
# LAME_LIBRARIES - List of libraries when using lame.
|
||||
# LAME_FOUND - True if Lame found.
|
||||
|
||||
if (LAME_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
set(LAME_FIND_QUIETLY TRUE)
|
||||
endif ()
|
||||
|
||||
find_path (LAME_INCLUDE_DIR lame/lame.h
|
||||
HINTS
|
||||
${LAME_ROOT}
|
||||
)
|
||||
|
||||
# MSVC built lame may be named mp3lame_static.
|
||||
# The provided project files name the library with the lib prefix.
|
||||
|
||||
find_library (LAME_LIBRARY
|
||||
NAMES
|
||||
mp3lame
|
||||
mp3lame_static
|
||||
libmp3lame
|
||||
libmp3lame_static
|
||||
libmp3lame-static
|
||||
HINTS
|
||||
${LAME_ROOT}
|
||||
)
|
||||
|
||||
find_library (LAME_HIP_LIBRARY
|
||||
NAMES
|
||||
mpghip-static
|
||||
libmpghip-static
|
||||
HINTS
|
||||
${LAME_ROOT}
|
||||
)
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set LAME_FOUND
|
||||
# to TRUE if all listed variables are TRUE.
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args (Lame
|
||||
REQUIRED_VARS
|
||||
LAME_LIBRARY
|
||||
LAME_INCLUDE_DIR
|
||||
)
|
||||
|
||||
if (LAME_FOUND)
|
||||
set (LAME_LIBRARIES ${LAME_LIBRARY} ${LAME_HIP_LIBRARY})
|
||||
set (LAME_INCLUDE_DIRS ${LAME_INCLUDE_DIR})
|
||||
|
||||
if (NOT TARGET Lame::Lame)
|
||||
add_library (Lame::Lame UNKNOWN IMPORTED)
|
||||
set_target_properties (Lame::Lame PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${LAME_INCLUDE_DIRS}"
|
||||
IMPORTED_LOCATION "${LAME_LIBRARY}"
|
||||
)
|
||||
if (LAME_HIP_LIBRARY)
|
||||
set_property (TARGET Lame::Lame APPEND PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES "${LAME_HIP_LIBRARY}")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
mark_as_advanced(LAME_INCLUDE_DIR LAME_LIBRARY LAME_HIP_LIBRARY)
|
67
cmake/Findmp3lame.cmake
Normal file
67
cmake/Findmp3lame.cmake
Normal file
@ -0,0 +1,67 @@
|
||||
# - Find lame
|
||||
# Find the native lame includes and libraries
|
||||
#
|
||||
# MP3LAME_INCLUDE_DIRS - where to find lame.h, etc.
|
||||
# MP3LAME_LIBRARIES - List of libraries when using lame.
|
||||
# MP3LAME_FOUND - True if Lame found.
|
||||
|
||||
if (MP3LAME_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
set(MP3LAME_FIND_QUIETLY TRUE)
|
||||
endif ()
|
||||
|
||||
find_path (MP3LAME_INCLUDE_DIR lame/lame.h
|
||||
HINTS
|
||||
${LAME_ROOT}
|
||||
)
|
||||
|
||||
# MSVC built lame may be named mp3lame_static.
|
||||
# The provided project files name the library with the lib prefix.
|
||||
|
||||
find_library (MP3LAME_LIBRARY
|
||||
NAMES
|
||||
mp3lame
|
||||
mp3lame_static
|
||||
libmp3lame
|
||||
libmp3lame_static
|
||||
libmp3lame-static
|
||||
HINTS
|
||||
${MP3LAME_ROOT}
|
||||
)
|
||||
|
||||
find_library (MP3LAME_HIP_LIBRARY
|
||||
NAMES
|
||||
mpghip-static
|
||||
libmpghip-static
|
||||
HINTS
|
||||
${MP3LAME_ROOT}
|
||||
)
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set LAME_FOUND
|
||||
# to TRUE if all listed variables are TRUE.
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args (mp3lame
|
||||
REQUIRED_VARS
|
||||
MP3LAME_LIBRARY
|
||||
MP3LAME_INCLUDE_DIR
|
||||
)
|
||||
|
||||
if (MP3LAME_FOUND)
|
||||
set (MP3LAME_LIBRARIES ${MP3LAME_LIBRARY} ${MP3LAME_HIP_LIBRARY})
|
||||
set (MP3LAME_INCLUDE_DIRS ${MP3LAME_INCLUDE_DIR})
|
||||
|
||||
if (NOT TARGET mp3lame::mp3lame)
|
||||
add_library (mp3lame::mp3lame UNKNOWN IMPORTED)
|
||||
set_target_properties (mp3lame::mp3lame PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${MP3LAME_INCLUDE_DIRS}"
|
||||
IMPORTED_LOCATION "${MP3LAME_LIBRARY}"
|
||||
)
|
||||
if (MP3LAME_HIP_LIBRARY AND (NOT TARGET mp3lame::mpghip))
|
||||
add_library (mp3lame::mpghip STATIC IMPORTED)
|
||||
set_property (mp3lame::mpghip PROPERTY IMPORTED_LOCATION "${MP3LAME_HIP_LIBRARY}")
|
||||
set_property (TARGET mp3lame::mp3lame PROPERTY INTERFACE_LINK_LIBRARIES "mp3lame::mpghip")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
mark_as_advanced(MP3LAME_INCLUDE_DIR MP3LAME_LIBRARY MP3LAME_HIP_LIBRARY)
|
@ -56,9 +56,9 @@ else ()
|
||||
set (HAVE_EXTERNAL_XIPH_LIBS 0)
|
||||
endif ()
|
||||
|
||||
find_package (Lame)
|
||||
find_package (mp3lame)
|
||||
find_package (Mpg123 1.25.10)
|
||||
if (LAME_FOUND AND (TARGET MPG123::libmpg123))
|
||||
if (TARGET mp3lame::mp3lame AND (TARGET MPG123::libmpg123))
|
||||
set (HAVE_MPEG_LIBS 1)
|
||||
else ()
|
||||
set (HAVE_MPEG_LIBS 0)
|
||||
|
@ -18,7 +18,7 @@ if (SndFile_WITH_EXTERNAL_LIBS AND NOT @BUILD_SHARED_LIBS@)
|
||||
endif ()
|
||||
|
||||
if (SndFile_WITH_MPEG AND NOT @BUILD_SHARED_LIBS@)
|
||||
find_dependency (Lame)
|
||||
find_dependency (mp3lame)
|
||||
find_dependency (MPG123)
|
||||
endif ()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user