mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 01:49:53 +00:00
CMake fixes
* Update Vorbis targets to match upstream * Better dependency handling with Vcpkg * Fix dev warning with SQLite3
This commit is contained in:
parent
a1fa15ff44
commit
06ebde50e3
@ -64,7 +64,7 @@ include(SndFileChecks)
|
||||
|
||||
|
||||
cmake_dependent_option (BUILD_REGTEST "Build regtest" ON "SQLITE3_FOUND" OFF)
|
||||
cmake_dependent_option (ENABLE_EXTERNAL_LIBS "Enable FLAC, Vorbis, and Opus codecs" ON "VORBISENC_FOUND;FLAC_FOUND;OPUS_FOUND" OFF)
|
||||
cmake_dependent_option (ENABLE_EXTERNAL_LIBS "Enable FLAC, Vorbis, and Opus codecs" ON "Vorbis_FOUND;FLAC_FOUND;OPUS_FOUND" OFF)
|
||||
cmake_dependent_option (ENABLE_CPU_CLIP "Enable tricky cpu specific clipper" ON "CPU_CLIPS_POSITIVE;CPU_CLIPS_NEGATIVE" OFF)
|
||||
if (NOT ENABLE_CPU_CLIP)
|
||||
set (CPU_CLIPS_POSITIVE FALSE)
|
||||
@ -104,7 +104,7 @@ set_package_properties (Ogg PROPERTIES
|
||||
DESCRIPTION "library for manipulating ogg bitstreams"
|
||||
PURPOSE "Required to enable Vorbis, Speex, and Opus support"
|
||||
)
|
||||
set_package_properties (VorbisEnc PROPERTIES
|
||||
set_package_properties (Vorbis PROPERTIES
|
||||
TYPE RECOMMENDED
|
||||
URL "www.vorbis.com/"
|
||||
DESCRIPTION "open source lossy audio codec"
|
||||
@ -305,7 +305,7 @@ target_include_directories(sndfile
|
||||
target_link_libraries (sndfile
|
||||
PRIVATE
|
||||
$<$<BOOL:${LIBM_REQUIRED}>:m>
|
||||
$<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:Vorbis::VorbisEnc>
|
||||
$<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:Vorbis::vorbisenc>
|
||||
$<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:FLAC::FLAC>
|
||||
$<$<AND:$<BOOL:${ENABLE_EXPERIMENTAL}>,$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>,$<BOOL:${HAVE_SPEEX}>>:Speex::Speex>
|
||||
$<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:Opus::opus>
|
||||
|
@ -46,7 +46,7 @@ find_package_handle_standard_args (FLAC
|
||||
REQUIRED_VARS
|
||||
FLAC_LIBRARY
|
||||
FLAC_INCLUDE_DIR
|
||||
OGG_FOUND
|
||||
Ogg_FOUND
|
||||
VERSION_VAR
|
||||
FLAC_VERSION
|
||||
)
|
||||
|
@ -33,7 +33,7 @@ find_library (SQLITE3_LIBRARY
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args (SQLITE3
|
||||
find_package_handle_standard_args (SQLite3
|
||||
REQUIRED_VARS
|
||||
SQLITE3_LIBRARY
|
||||
SQLITE3_INCLUDE_DIR
|
||||
|
@ -5,60 +5,155 @@
|
||||
# VORBIS_LIBRARIES - List of libraries when using vorbis.
|
||||
# VORBIS_FOUND - True if vorbis found.
|
||||
|
||||
if (VORBIS_INCLUDE_DIR)
|
||||
if (Vorbis_Vorbis_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
set (VORBIS_FIND_QUIETLY TRUE)
|
||||
set (Vorbis_FIND_QUIETLY TRUE)
|
||||
endif ()
|
||||
|
||||
set (Vorbis_Vorbis_FIND_QUIETLY TRUE)
|
||||
set (Vorbis_Enc_FIND_QUIETLY TRUE)
|
||||
set (Vorbis_File_FIND_QUIETLY TRUE)
|
||||
|
||||
find_package (Ogg QUIET)
|
||||
|
||||
find_package (PkgConfig QUIET)
|
||||
pkg_check_modules (PC_VORBIS QUIET vorbis)
|
||||
pkg_check_modules (PC_Vorbis_Vorbis QUIET vorbis)
|
||||
pkg_check_modules (PC_Vorbis_Enc QUIET vorbisenc)
|
||||
pkg_check_modules (PC_Vorbis_File QUIET vorbisfile)
|
||||
|
||||
set (VORBIS_VERSION ${PC_VORBIS_VERSION})
|
||||
set (Vorbis_VERSION ${PC_VORBIS_VERSION})
|
||||
|
||||
find_path (VORBIS_INCLUDE_DIR vorbis/codec.h
|
||||
find_path (Vorbis_Vorbis_INCLUDE_DIR vorbis/codec.h
|
||||
HINTS
|
||||
${PC_VORBIS_INCLUDEDIR}
|
||||
${PC_VORBIS_INCLUDE_DIRS}
|
||||
${VORBIS_ROOT}
|
||||
${PC_Vorbis_Vorbis_INCLUDEDIR}
|
||||
${PC_Vorbis_Vorbis_INCLUDE_DIRS}
|
||||
${Vorbis_ROOT}
|
||||
)
|
||||
|
||||
find_library (VORBIS_LIBRARY
|
||||
find_path (Vorbis_Enc_INCLUDE_DIR vorbis/vorbisenc.h
|
||||
HINTS
|
||||
${PC_Vorbis_Enc_INCLUDEDIR}
|
||||
${PC_Vorbis_Enc_INCLUDE_DIRS}
|
||||
${Vorbis_ROOT}
|
||||
)
|
||||
|
||||
find_path (Vorbis_File_INCLUDE_DIR vorbis/vorbisfile.h
|
||||
HINTS
|
||||
${PC_Vorbis_File_INCLUDEDIR}
|
||||
${PC_Vorbis_File_INCLUDE_DIRS}
|
||||
${Vorbis_ROOT}
|
||||
)
|
||||
|
||||
find_library (Vorbis_Vorbis_LIBRARY
|
||||
NAMES
|
||||
vorbis
|
||||
vorbis_static
|
||||
libvorbis
|
||||
libvorbis_static
|
||||
HINTS
|
||||
${PC_VORBIS_LIBDIR}
|
||||
${PC_VORBIS_LIBRARY_DIRS}
|
||||
${VORBIS_ROOT}
|
||||
${PC_Vorbis_Vorbis_LIBDIR}
|
||||
${PC_Vorbis_Vorbis_LIBRARY_DIRS}
|
||||
${Vorbis_ROOT}
|
||||
)
|
||||
|
||||
find_library (Vorbis_Enc_LIBRARY
|
||||
NAMES
|
||||
vorbisenc
|
||||
vorbisenc_static
|
||||
libvorbisenc
|
||||
libvorbisenc_static
|
||||
HINTS
|
||||
${PC_Vorbis_Enc_LIBDIR}
|
||||
${PC_Vorbis_Enc_LIBRARY_DIRS}
|
||||
${Vorbis_ROOT}
|
||||
)
|
||||
|
||||
find_library (Vorbis_File_LIBRARY
|
||||
NAMES
|
||||
vorbisfile
|
||||
vorbisfile_static
|
||||
libvorbisfile
|
||||
libvorbisfile_static
|
||||
HINTS
|
||||
${PC_Vorbis_File_LIBDIR}
|
||||
${PC_Vorbis_File_LIBRARY_DIRS}
|
||||
${Vorbis_ROOT}
|
||||
)
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set VORBIS_FOUND
|
||||
# to TRUE if all listed variables are TRUE.
|
||||
include (FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args (Vorbis
|
||||
|
||||
find_package_handle_standard_args (Vorbis_Vorbis
|
||||
REQUIRED_VARS
|
||||
VORBIS_LIBRARY
|
||||
VORBIS_INCLUDE_DIR
|
||||
OGG_FOUND
|
||||
VERSION_VAR
|
||||
VORBIS_VERSION
|
||||
Vorbis_Vorbis_LIBRARY
|
||||
Vorbis_Vorbis_INCLUDE_DIR
|
||||
Ogg_FOUND
|
||||
NAME_MISMATCHED
|
||||
)
|
||||
|
||||
if (VORBIS_FOUND)
|
||||
set (VORBIS_INCLUDE_DIRS ${VORBIS_INCLUDE_DIR})
|
||||
set (VORBIS_LIBRARIES ${VORBIS_LIBRARY} ${OGG_LIBRARIES})
|
||||
if (NOT TARGET Vorbis::Vorbis)
|
||||
add_library (Vorbis::Vorbis UNKNOWN IMPORTED)
|
||||
set_target_properties (Vorbis::Vorbis PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${VORBIS_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${VORBIS_LIBRARY}"
|
||||
find_package_handle_standard_args (Vorbis_Enc
|
||||
REQUIRED_VARS
|
||||
Vorbis_Enc_LIBRARY
|
||||
Vorbis_Enc_INCLUDE_DIR
|
||||
Vorbis_Vorbis_FOUND
|
||||
NAME_MISMATCHED
|
||||
)
|
||||
|
||||
find_package_handle_standard_args (Vorbis_File
|
||||
REQUIRED_VARS
|
||||
Vorbis_File_LIBRARY
|
||||
Vorbis_File_INCLUDE_DIR
|
||||
Vorbis_Vorbis_FOUND
|
||||
NAME_MISMATCHED
|
||||
)
|
||||
|
||||
if (Vorbis_Vorbis_FOUND)
|
||||
set (Vorbis_Vorbis_INCLUDE_DIRS ${VORBIS_INCLUDE_DIR})
|
||||
set (Vorbis_Vorbis_LIBRARIES ${VORBIS_LIBRARY} ${OGG_LIBRARIES})
|
||||
if (NOT TARGET Vorbis::vorbis)
|
||||
add_library (Vorbis::vorbis UNKNOWN IMPORTED)
|
||||
set_target_properties (Vorbis::vorbis PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_Vorbis_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${Vorbis_Vorbis_LIBRARY}"
|
||||
INTERFACE_LINK_LIBRARIES Ogg::ogg
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (Vorbis_Enc_FOUND)
|
||||
set (Vorbis_Enc_INCLUDE_DIRS ${Vorbis_Enc_INCLUDE_DIR})
|
||||
set (Vorbis_Enc_LIBRARIES ${Vorbis_Enc_LIBRARY} ${Vorbis_Enc_LIBRARIES})
|
||||
if (NOT TARGET Vorbis::vorbisenc)
|
||||
add_library (Vorbis::vorbisenc UNKNOWN IMPORTED)
|
||||
set_target_properties (Vorbis::vorbisenc PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_Enc_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${Vorbis_Enc_LIBRARY}"
|
||||
INTERFACE_LINK_LIBRARIES Vorbis::vorbis
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
mark_as_advanced (VORBIS_INCLUDE_DIR VORBIS_LIBRARY)
|
||||
if (Vorbis_File_FOUND)
|
||||
set (Vorbis_File_INCLUDE_DIRS ${Vorbis_File_INCLUDE_DIR})
|
||||
set (Vorbis_File_LIBRARIES ${Vorbis_File_LIBRARY} ${Vorbis_File_LIBRARIES})
|
||||
if (NOT TARGET Vorbis::vorbisfile)
|
||||
add_library (Vorbis::vorbisfile UNKNOWN IMPORTED)
|
||||
set_target_properties (Vorbis::vorbisfile PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_File_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${Vorbis_File_LIBRARY}"
|
||||
INTERFACE_LINK_LIBRARIES Vorbis::vorbis
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
endif ()
|
||||
|
||||
find_package_handle_standard_args (Vorbis
|
||||
REQUIRED_VARS
|
||||
Vorbis_Vorbis_LIBRARY
|
||||
Vorbis_Vorbis_INCLUDE_DIR
|
||||
Ogg_FOUND
|
||||
HANDLE_COMPONENTS
|
||||
VERSION_VAR Vorbis_VERSION)
|
||||
|
||||
mark_as_advanced (Vorbis_Vorbis_INCLUDE_DIR Vorbis_Vorbis_LIBRARY)
|
||||
mark_as_advanced (Vorbis_Enc_INCLUDE_DIR Vorbis_Enc_LIBRARY)
|
||||
mark_as_advanced (Vorbis_File_INCLUDE_DIR Vorbis_File_LIBRARY)
|
||||
|
@ -27,11 +27,28 @@ if (NOT WIN32)
|
||||
find_package (Sndio)
|
||||
endif ()
|
||||
|
||||
if (VCPKG_TOOLCHAIN AND (NOT CMAKE_VERSION VERSION_LESS 3.15))
|
||||
set (CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
|
||||
endif ()
|
||||
|
||||
if (CMAKE_FIND_PACKAGE_PREFER_CONFIG)
|
||||
find_package (Ogg 1.3 CONFIG)
|
||||
find_package (Vorbis CONFIG COMPONENTS Enc)
|
||||
find_package (FLAC CONFIG)
|
||||
find_package (Opus CONFIG)
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args (Ogg CONFIG_MODE)
|
||||
find_package_handle_standard_args (Vorbis CONFIG_MODE)
|
||||
find_package_handle_standard_args (FLAC CONFIG_MODE)
|
||||
find_package_handle_standard_args (Opus CONFIG_MODE)
|
||||
else ()
|
||||
find_package (Ogg 1.3)
|
||||
find_package (VorbisEnc)
|
||||
find_package (Vorbis COMPONENTS Enc)
|
||||
find_package (FLAC)
|
||||
find_package (Opus)
|
||||
if (VORBIS_FOUND AND FLAC_FOUND AND OPUS_FOUND)
|
||||
endif ()
|
||||
if (Vorbis_FOUND AND FLAC_FOUND AND Opus_FOUND)
|
||||
set (HAVE_EXTERNAL_XIPH_LIBS 1)
|
||||
else ()
|
||||
set (HAVE_EXTERNAL_XIPH_LIBS 0)
|
||||
|
Loading…
Reference in New Issue
Block a user