mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-26 19:40:24 +00:00
CMake: Fix Vorbis dependency handling
* Fix Vorbis not found for CMake < 3.17 (closes #530) * Update FindVorbis module documentation * Remove unused VorbisEnc.cmake * Fix bug in SndFileConfig.cmake.in
This commit is contained in:
parent
7a8149a723
commit
73e09a1705
@ -19,7 +19,7 @@ EXTRA_DIST = libsndfile.spec.in sndfile.pc.in Scripts/android-configure.sh \
|
||||
cmake_files = cmake/ClipMode.cmake cmake/FindFLAC.cmake \
|
||||
cmake/CMakeAutoGen.cmake cmake/CMakeAutoGenScript.cmake \
|
||||
cmake/FindOgg.cmake cmake/FindVorbis.cmake cmake/FindSndio.cmake \
|
||||
cmake/FindSpeex.cmake cmake/FindSQLite3.cmake cmake/FindVorbisEnc.cmake \
|
||||
cmake/FindSpeex.cmake cmake/FindSQLite3.cmake \
|
||||
cmake/SndFileChecks.cmake cmake/TestInline.cmake \
|
||||
cmake/TestLargeFiles.cmake cmake/TestInline.c.in \
|
||||
cmake/FindOpus.cmake cmake/SndFileConfig.cmake.in
|
||||
|
@ -1,9 +1,71 @@
|
||||
# - Find vorbisenc
|
||||
# Find the native vorbisenc includes and libraries
|
||||
#
|
||||
# VORBIS_INCLUDE_DIRS - where to find vorbis.h, etc.
|
||||
# VORBIS_LIBRARIES - List of libraries when using vorbis.
|
||||
# VORBIS_FOUND - True if vorbis found.
|
||||
#[=======================================================================[.rst:
|
||||
FindVorbis
|
||||
----------
|
||||
|
||||
Finds the native vorbis, vorbisenc amd vorbisfile includes and libraries.
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module provides the following imported targets, if found:
|
||||
|
||||
``Vorbis::vorbis``
|
||||
The Vorbis library
|
||||
``Vorbis::vorbisenc``
|
||||
The VorbisEnc library
|
||||
``Vorbis::vorbisfile``
|
||||
The VorbisFile library
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This will define the following variables:
|
||||
|
||||
``Vorbis_Vorbis_INCLUDE_DIRS``
|
||||
List of include directories when using vorbis.
|
||||
``Vorbis_Enc_INCLUDE_DIRS``
|
||||
List of include directories when using vorbisenc.
|
||||
``Vorbis_File_INCLUDE_DIRS``
|
||||
List of include directories when using vorbisfile.
|
||||
``Vorbis_Vorbis_LIBRARIES``
|
||||
List of libraries when using vorbis.
|
||||
``Vorbis_Enc_LIBRARIES``
|
||||
List of libraries when using vorbisenc.
|
||||
``Vorbis_File_LIBRARIES``
|
||||
List of libraries when using vorbisfile.
|
||||
``Vorbis_FOUND``
|
||||
True if vorbis and requested components found.
|
||||
``Vorbis_Vorbis_FOUND``
|
||||
True if vorbis found.
|
||||
``Vorbis_Enc_FOUND``
|
||||
True if vorbisenc found.
|
||||
``Vorbis_Enc_FOUND``
|
||||
True if vorbisfile found.
|
||||
|
||||
Cache variables
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
The following cache variables may also be set:
|
||||
|
||||
``Vorbis_Vorbis_INCLUDE_DIR``
|
||||
The directory containing ``vorbis/vorbis.h``.
|
||||
``Vorbis_Enc_INCLUDE_DIR``
|
||||
The directory containing ``vorbis/vorbisenc.h``.
|
||||
``Vorbis_File_INCLUDE_DIR``
|
||||
The directory containing ``vorbis/vorbisenc.h``.
|
||||
``Vorbis_Vorbis_LIBRARY``
|
||||
The path to the vorbis library.
|
||||
``Vorbis_Enc_LIBRARY``
|
||||
The path to the vorbisenc library.
|
||||
``Vorbis_File_LIBRARY``
|
||||
The path to the vorbisfile library.
|
||||
|
||||
Hints
|
||||
^^^^^
|
||||
|
||||
A user may set ``Vorbis_ROOT`` to a vorbis installation root to tell this module where to look.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
if (Vorbis_Vorbis_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
@ -21,7 +83,7 @@ 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_Vorbis_VERSION})
|
||||
|
||||
find_path (Vorbis_Vorbis_INCLUDE_DIR vorbis/codec.h
|
||||
HINTS
|
||||
@ -82,29 +144,26 @@ find_library (Vorbis_File_LIBRARY
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args (Vorbis_Vorbis
|
||||
if (Vorbis_Vorbis_LIBRARY AND Vorbis_Vorbis_INCLUDE_DIR AND Ogg_FOUND)
|
||||
set (Vorbis_Vorbis_FOUND TRUE)
|
||||
endif ()
|
||||
|
||||
if (Vorbis_Enc_LIBRARY AND Vorbis_Enc_INCLUDE_DIR AND Vorbis_Vorbis_FOUND)
|
||||
set (Vorbis_Enc_FOUND TRUE)
|
||||
endif ()
|
||||
|
||||
if (Vorbis_Vorbis_FOUND AND Vorbis_File_LIBRARY AND Vorbis_File_INCLUDE_DIR)
|
||||
set (Vorbis_File_FOUND TRUE)
|
||||
endif ()
|
||||
|
||||
find_package_handle_standard_args (Vorbis
|
||||
REQUIRED_VARS
|
||||
Vorbis_Vorbis_LIBRARY
|
||||
Vorbis_Vorbis_INCLUDE_DIR
|
||||
Ogg_FOUND
|
||||
NAME_MISMATCHED
|
||||
)
|
||||
HANDLE_COMPONENTS
|
||||
VERSION_VAR Vorbis_VERSION)
|
||||
|
||||
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})
|
||||
@ -146,14 +205,6 @@ if (Vorbis_Vorbis_FOUND)
|
||||
|
||||
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)
|
||||
|
@ -1,64 +0,0 @@
|
||||
# - Find vorbisenc
|
||||
# Find the native vorbisenc includes and libraries
|
||||
#
|
||||
# VORBISENC_INCLUDE_DIRS - where to find vorbisenc.h, etc.
|
||||
# VORBISENC_LIBRARIES - List of libraries when using vorbisenc.
|
||||
# VORBISENC_FOUND - True if vorbisenc found.
|
||||
|
||||
if (VORBISENC_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
set (VORBISENC_FIND_QUIETLY TRUE)
|
||||
endif ()
|
||||
|
||||
find_package (Vorbis QUIET)
|
||||
|
||||
find_package (PkgConfig QUIET)
|
||||
pkg_check_modules (PC_VORBISENC QUIET vorbisenc)
|
||||
|
||||
set (VORBISENC_VERSION ${PC_VORBISENC_VERSION})
|
||||
|
||||
find_path (VORBISENC_INCLUDE_DIR vorbis/vorbisenc.h
|
||||
HINTS
|
||||
${PC_VORBISENC_INCLUDEDIR}
|
||||
${PC_VORBISENC_INCLUDE_DIRS}
|
||||
${VORBISENC_ROOT}
|
||||
)
|
||||
|
||||
find_library (VORBISENC_LIBRARY
|
||||
NAMES
|
||||
vorbisenc
|
||||
vorbisenc_static
|
||||
libvorbisenc
|
||||
libvorbisenc_static
|
||||
HINTS
|
||||
${PC_VORBISENC_LIBDIR}
|
||||
${PC_VORBISENC_LIBRARY_DIRS}
|
||||
${VORBISENC_ROOT}
|
||||
)
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set VORBISENC_FOUND
|
||||
# to TRUE if all listed variables are TRUE.
|
||||
include (FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args (VorbisEnc
|
||||
REQUIRED_VARS
|
||||
VORBISENC_LIBRARY
|
||||
VORBISENC_INCLUDE_DIR
|
||||
VORBIS_FOUND
|
||||
VERSION_VAR
|
||||
VORBISENC_VERSION
|
||||
)
|
||||
|
||||
if (VORBISENC_FOUND)
|
||||
set (VORBISENC_INCLUDE_DIRS ${VORBISENC_INCLUDE_DIR})
|
||||
set (VORBISENC_LIBRARIES ${VORBISENC_LIBRARY} ${VORBIS_LIBRARIES})
|
||||
if (NOT TARGET Vorbis::VorbisEnc)
|
||||
add_library (Vorbis::VorbisEnc UNKNOWN IMPORTED)
|
||||
set_target_properties (Vorbis::VorbisEnc PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${VORBISENC_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${VORBISENC_LIBRARY}"
|
||||
INTERFACE_LINK_LIBRARIES Vorbis::Vorbis
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
mark_as_advanced (VORBISENC_INCLUDE_DIR VORBISENC_LIBRARY)
|
@ -11,7 +11,7 @@ include (CMakeFindDependencyMacro)
|
||||
|
||||
if (SndFile_WITH_EXTERNAL_LIBS AND NOT @BUILD_SHARED_LIBS@)
|
||||
find_dependency (Ogg 1.3)
|
||||
find_dependency (VorbisEnc)
|
||||
find_dependency (Vorbis)
|
||||
find_dependency (FLAC)
|
||||
find_dependency (Opus)
|
||||
endif ()
|
||||
|
Loading…
Reference in New Issue
Block a user