From a28a5e6d202aa1b50782da3a66a6c8cdfc88585a Mon Sep 17 00:00:00 2001 From: Tom M Date: Wed, 12 May 2021 21:09:33 +0200 Subject: [PATCH] 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". --- CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3b1e131..9226281c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 )