Improve OGG/Vorbis detection (#888)

Previously, cmake only tested for a specific version of libsndfile and then assumed, it has OGG/Vorbis support. However, libsndfile may still be compiled without OGG/Vorbis support. If this is the case, fluidsynth should refuse to load SF3 files. Otherwise the attempt to load SF3 files would fail with a bunch of error messages.

The solution of this PR proposes to lookup the private libs listed in sndfile.pc and see whether it includes "vorbis".
This commit is contained in:
Tom M 2021-05-12 21:09:33 +02:00 committed by GitHub
parent cd393d863a
commit a28a5e6d20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -527,8 +527,17 @@ else(NOT enable-pkgconfig)
pkg_check_modules ( LIBSNDFILE sndfile>=1.0.0 )
set ( LIBSNDFILE_SUPPORT ${LIBSNDFILE_FOUND} )
if ( LIBSNDFILE_SUPPORT )
pkg_check_modules ( LIBSNDFILE_VORBIS sndfile>=1.0.18 )
set ( LIBSNDFILE_HASVORBIS ${LIBSNDFILE_VORBIS_FOUND} )
message (DEBUG "LIBSNDFILE_STATIC_LIBRARIES: ${LIBSNDFILE_STATIC_LIBRARIES}")
message (DEBUG "LIBSNDFILE_STATIC_LINK_LIBRARIES: ${LIBSNDFILE_STATIC_LINK_LIBRARIES}")
message (DEBUG "LIBSNDFILE_STATIC_LDFLAGS: ${LIBSNDFILE_STATIC_LDFLAGS}")
message (DEBUG "LIBSNDFILE_STATIC_LDFLAGS_OTHER: ${LIBSNDFILE_STATIC_LDFLAGS_OTHER}")
if ( LIBSNDFILE_STATIC_LIBRARIES MATCHES "vorbis" OR
LIBSNDFILE_STATIC_LDFLAGS MATCHES "vorbis" OR
LIBSNDFILE_STATIC_LDFLAGS_OTHER MATCHES "vorbis" )
set ( LIBSNDFILE_HASVORBIS 1 )
else ()
message ( NOTICE "Seems like libsndfile was compiled without OGG/Vorbis support." )
endif ()
endif ( LIBSNDFILE_SUPPORT )
else ( enable-libsndfile )
unset_pkg_config ( LIBSNDFILE )