Find Opus because SndFile now depends on it

fix-squashed-planets
MrSimbax 2021-09-04 20:33:15 +02:00
parent 65e12621ff
commit 8f0b367f9c
2 changed files with 71 additions and 1 deletions

69
cmake/FindOpus.cmake Normal file
View File

@ -0,0 +1,69 @@
# - Find opus
# Find the native opus includes and libraries
#
# OPUS_INCLUDE_DIRS - where to find opus.h, etc.
# OPUS_LIBRARIES - List of libraries when using opus.
# OPUS_FOUND - True if Opus found.
# From https://github.com/erikd/libsndfile/
if (OPUS_INCLUDE_DIR)
# Already in cache, be silent
set(OPUS_FIND_QUIETLY TRUE)
endif ()
find_package (Ogg QUIET)
find_package (PkgConfig QUIET)
pkg_check_modules(PC_OPUS QUIET opus>=1.1)
set (OPUS_VERSION ${PC_OPUS_VERSION})
find_path (OPUS_INCLUDE_DIR opus/opus.h
HINTS
${PC_OPUS_INCLUDEDIR}
${PC_OPUS_INCLUDE_DIRS}
${OPUS_ROOT}
)
# MSVC built opus may be named opus_static.
# The provided project files name the library with the lib prefix.
find_library (OPUS_LIBRARY
NAMES
opus
opus_static
libopus
libopus_static
HINTS
${PC_OPUS_LIBDIR}
${PC_OPUS_LIBRARY_DIRS}
${OPUS_ROOT}
)
# Handle the QUIETLY and REQUIRED arguments and set OPUS_FOUND
# to TRUE if all listed variables are TRUE.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args (Opus
REQUIRED_VARS
OPUS_LIBRARY
OPUS_INCLUDE_DIR
OGG_FOUND
VERSION_VAR
OPUS_VERSION
)
if (OPUS_FOUND)
set (OPUS_LIBRARIES ${OPUS_LIBRARY})
set (OPUS_INCLUDE_DIRS ${OPUS_INCLUDE_DIR})
if (NOT TARGET Opus::opus)
add_library (Opus::opus UNKNOWN IMPORTED)
set_target_properties (Opus::opus PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OPUS_INCLUDE_DIRS}"
IMPORTED_LOCATION "${OPUS_LIBRARIES}"
)
endif ()
endif ()
mark_as_advanced(OPUS_INCLUDE_DIR OPUS_LIBRARY)

View File

@ -21,10 +21,11 @@ if(SndFile_FOUND AND NOT TARGET SndFile::sndfile)
# If we want to statically link it, we also need its dependencies # If we want to statically link it, we also need its dependencies
if(SNDFILE_STATIC) if(SNDFILE_STATIC)
find_package(Ogg REQUIRED) find_package(Ogg REQUIRED)
find_package(Opus REQUIRED)
find_package(FLAC REQUIRED) find_package(FLAC REQUIRED)
find_package(Vorbis REQUIRED) find_package(Vorbis REQUIRED)
find_package(VorbisEnc REQUIRED) find_package(VorbisEnc REQUIRED)
set_property(TARGET SndFile::sndfile APPEND PROPERTY set_property(TARGET SndFile::sndfile APPEND PROPERTY
INTERFACE_LINK_LIBRARIES Ogg::ogg FLAC::FLAC Vorbis::vorbis Vorbis::VorbisEnc) INTERFACE_LINK_LIBRARIES Ogg::ogg Opus::opus FLAC::FLAC Vorbis::vorbis Vorbis::VorbisEnc)
endif() endif()
endif() endif()