[sdl2-mixer] Update features and fix static linking (#29681)

* [sdl2-mixer] Update features behaviour.

- Reword feature description.
- Disable FLAC and MP3 support when libflac and mpg123 are not selected.
- Make libvorbis a dependency instead of a feature.
Unlike the FLAC/MP3 backends, the vorbis backend cannot be disabled.

* [sdl2-mixer] Remove alternative midi features.

The priority for MIDI backends is: fluidsynth > timidity > nativemidi.

- Turn off implicitely enabled timidity backend which shadows the
nativemidi backend.
- Remove nativemidi as it offers the same functionalities as fluidsynth
but is not available outside of Windows and Apple platforms. Moreover it
may give the false impression that MIDI is supported out of the box

* [sdl2-mixer] Use targets provided by dependencies.

This allows the dependencies to inform the sdl2-mixer about their usage
requirements, making it much easier to statically link the library.

* [sdl2-mixer] FluidSynth now requires pkg-config.

Since 2.3.1#1 FluidSynth's CMake config required pkg-config to find its
dependencies.

* [sdl2-mixer] UWP builds should work again.

* [sdl2-mixer] Update baseline.

* [sdl2-mixer] Add back a dummy libvorbis feature.

This is to keep compatibility with downstream users.

* [sdl2-mixer] Update version.

* [sdl2-mixer] Remove the dummy libvorbis feature.

Since vcpkg tool version 2023-02-16, this is no longer needed.

* [sdl2-mixer] Update version.

---------

Co-authored-by: Monica <v-liumonica@microsoft.com>
This commit is contained in:
Pierre Wendling 2023-03-21 15:40:45 -04:00 committed by GitHub
parent 39ffd6851e
commit 812080c89a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 162 additions and 92 deletions

View File

@ -1,33 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 54317572..4fcd92d5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -323,6 +323,9 @@ if(SDL2MIXER_OGG)
if(SDL2MIXER_OGG_install)
list(APPEND INSTALL_EXTRA_TARGETS ogg)
endif()
+ else()
+ find_package(Ogg CONFIG REQUIRED)
+ target_link_libraries(SDL2_mixer PRIVATE Ogg::ogg)
endif()
endif()
@@ -384,7 +387,8 @@ if(SDL2MIXER_OPUS)
add_dependencies(SDL2_mixer opusfile::opusfile)
endif()
else()
- target_link_libraries(SDL2_mixer PRIVATE opusfile::opusfile)
+ find_package(Opus CONFIG REQUIRED)
+ target_link_libraries(SDL2_mixer PRIVATE opusfile::opusfile Opus::opus)
endif()
endif()
@@ -528,7 +532,7 @@ if(SDL2MIXER_FLAC_LIBFLAC)
add_dependencies(SDL2_mixer FLAC)
endif()
else()
- target_link_libraries(SDL2_mixer PRIVATE FLAC)
+ target_link_libraries(SDL2_mixer PRIVATE FLAC::FLAC)
endif()
endif()

View File

@ -0,0 +1,137 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 54317572..5f84dd22 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -366,7 +366,7 @@ if(SDL2MIXER_OPUS)
endif()
else()
message(STATUS "Using system opusfile")
- find_package(opusfile REQUIRED)
+ find_package(OpusFile CONFIG REQUIRED)
if(NOT SDL2MIXER_OPUS_SHARED)
list(APPEND PC_REQUIRES opusfile)
endif()
@@ -384,7 +384,7 @@ if(SDL2MIXER_OPUS)
add_dependencies(SDL2_mixer opusfile::opusfile)
endif()
else()
- target_link_libraries(SDL2_mixer PRIVATE opusfile::opusfile)
+ target_link_libraries(SDL2_mixer PRIVATE OpusFile::opusfile)
endif()
endif()
@@ -467,7 +467,7 @@ if(SDL2MIXER_VORBIS_VORBISFILE)
endif()
else()
message(STATUS "Using system vorbisfile")
- find_package(vorbisfile REQUIRED)
+ find_package(Vorbis CONFIG REQUIRED)
if(NOT SDL2MIXER_VORBIS_VORBISFILE_SHARED)
list(APPEND PC_REQUIRES vorbisfile)
endif()
@@ -485,7 +485,7 @@ if(SDL2MIXER_VORBIS_VORBISFILE)
add_dependencies(SDL2_mixer vorbisfile::vorbisfile)
endif()
else()
- target_link_libraries(SDL2_mixer PRIVATE vorbisfile::vorbisfile)
+ target_link_libraries(SDL2_mixer PRIVATE Vorbis::vorbisfile)
endif()
endif()
@@ -510,7 +510,7 @@ if(SDL2MIXER_FLAC_LIBFLAC)
endif()
else()
message(STATUS "Using system libflac")
- find_package(FLAC REQUIRED)
+ find_package(FLAC CONFIG REQUIRED)
if(NOT SDL2MIXER_FLAC_LIBFLAC_SHARED)
list(APPEND PC_REQUIRES flac)
endif()
@@ -528,7 +528,7 @@ if(SDL2MIXER_FLAC_LIBFLAC)
add_dependencies(SDL2_mixer FLAC)
endif()
else()
- target_link_libraries(SDL2_mixer PRIVATE FLAC)
+ target_link_libraries(SDL2_mixer PRIVATE FLAC::FLAC)
endif()
endif()
@@ -643,7 +643,7 @@ if(SDL2MIXER_MP3_MPG123)
endif()
else()
message(STATUS "Using system mpg123")
- find_package(MPG123 REQUIRED)
+ find_package(MPG123 CONFIG REQUIRED)
if(NOT SDL2MIXER_MP3_MPG123_SHARED)
list(APPEND PC_REQUIRES libmpg123)
endif()
@@ -661,7 +661,7 @@ if(SDL2MIXER_MP3_MPG123)
add_dependencies(SDL2_mixer MPG123::mpg123)
endif()
else()
- target_link_libraries(SDL2_mixer PRIVATE MPG123::mpg123)
+ target_link_libraries(SDL2_mixer PRIVATE MPG123::libmpg123)
endif()
endif()
@@ -672,7 +672,7 @@ if(SDL2MIXER_MIDI_FLUIDSYNTH)
message(FATAL_ERROR "FluidSynth is not vendored.")
else()
message(STATUS "Using system FluidSynth")
- find_package(FluidSynth REQUIRED)
+ find_package(FluidSynth CONFIG REQUIRED)
if(NOT SDL2MIXER_MIDI_FLUIDSYNTH_SHARED)
list(APPEND PC_REQUIRES fluidsynth)
endif()
@@ -690,7 +690,7 @@ if(SDL2MIXER_MIDI_FLUIDSYNTH)
add_dependencies(SDL2_mixer FluidSynth::FluidSynth)
endif()
else()
- target_link_libraries(SDL2_mixer PRIVATE FluidSynth::FluidSynth)
+ target_link_libraries(SDL2_mixer PRIVATE FluidSynth::libfluidsynth)
endif()
endif()
diff --git a/SDL2_mixerConfig.cmake.in b/SDL2_mixerConfig.cmake.in
index d65a43ce..29866349 100644
--- a/SDL2_mixerConfig.cmake.in
+++ b/SDL2_mixerConfig.cmake.in
@@ -54,7 +54,7 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL2_mixer-static-targets.cmake")
include(CMakeFindDependencyMacro)
if(SDL2MIXER_FLAC_LIBFLAC AND NOT SDL2MIXER_VENDORED AND NOT TARGET FLAC::FLAC)
- find_dependency(FLAC)
+ find_dependency(FLAC CONFIG)
endif()
if(SDL2MIXER_MOD_MODPLUG AND NOT SDL2MIXER_VENDORED AND NOT TARGET modplug::modplug)
@@ -69,20 +69,23 @@ include(CMakeFindDependencyMacro)
find_dependency(libxmp-lite)
endif()
- if(SDL2MIXER_MP3_MPG123 AND NOT SDL2MIXER_VENDORED AND NOT TARGET MPG123::mpg123)
- find_dependency(MPG123)
+ if(SDL2MIXER_MP3_MPG123 AND NOT SDL2MIXER_VENDORED AND NOT TARGET MPG123::libmpg123)
+ find_dependency(MPG123 CONFIG)
endif()
- if(SDL2MIXER_MIDI_FLUIDSYNTH AND NOT SDL2MIXER_VENDORED AND NOT TARGET FluidSynth::FluidSynth)
- find_dependency(FluidSynth)
+ if(SDL2MIXER_MIDI_FLUIDSYNTH AND NOT SDL2MIXER_VENDORED AND NOT TARGET FluidSynth::libfluidsynth)
+ find_dependency(FluidSynth CONFIG)
endif()
if(SDL2MIXER_VORBIS_TREMOR AND NOT SDL2MIXER_VENDORED AND NOT TARGET tremor::tremor)
find_dependency(tremor)
endif()
- if(SDL2MIXER_VORBIS_VORBISFILE AND NOT SDL2MIXER_VENDORED AND NOT TARGET vorbisfile::vorbisfile)
- find_dependency(vorbisfile)
+ if(SDL2MIXER_VORBIS_VORBISFILE AND NOT SDL2MIXER_VENDORED AND NOT TARGET Vorbis::vorbisfile)
+ find_dependency(Vorbis CONFIG)
+ endif()
+ if(SDL2MIXER_OPUS AND NOT SDL2MIXER_VENDORED AND NOT TARGET OpusFile::opusfile)
+ find_dependency(OpusFile CONFIG)
endif()
if((NOT SDL2MIXER_VENDORED AND SDL2MIXER_MOD_MODPLUG) OR (HAIKU AND SDL2MIXER_MIDI_NATIVE))

View File

@ -1,14 +0,0 @@
diff --git a/SDL2_mixerConfig.cmake.in b/SDL2_mixerConfig.cmake.in
index d65a43ce..15a461d4 100644
--- a/SDL2_mixerConfig.cmake.in
+++ b/SDL2_mixerConfig.cmake.in
@@ -85,6 +85,9 @@ include(CMakeFindDependencyMacro)
find_dependency(vorbisfile)
endif()
+ if(SDL2MIXER_OPUS AND NOT SDL2MIXER_VENDORED AND NOT TARGET opusfile::opusfile)
+ find_dependency(opusfile)
+ endif()
if((NOT SDL2MIXER_VENDORED AND SDL2MIXER_MOD_MODPLUG) OR (HAIKU AND SDL2MIXER_MIDI_NATIVE))
include(CheckLanguage)
check_language(CXX)

View File

@ -1,13 +0,0 @@
diff --git a/cmake/FindFluidSynth.cmake b/cmake/FindFluidSynth.cmake
index 435840b6..6fd9db7b 100644
--- a/cmake/FindFluidSynth.cmake
+++ b/cmake/FindFluidSynth.cmake
@@ -1,7 +1,7 @@
include(FindPackageHandleStandardArgs)
find_library(FluidSynth_LIBRARY
- NAMES fluidsynth
+ NAMES fluidsynth libfluidsynth
)
find_path(FluidSynth_INCLUDE_PATH

View File

@ -6,43 +6,43 @@ vcpkg_from_github(
PATCHES
fix-pkg-prefix.patch
fix-pkgconfig.patch
fix-windows-static-findfluidsynth.patch
fix-missing-find-opusfile.patch
fix-deps-link.patch
fix-deps-targets.patch
)
vcpkg_check_features(
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
fluidsynth SDL2MIXER_MIDI
fluidsynth SDL2MIXER_MIDI_FLUIDSYNTH
libflac SDL2MIXER_FLAC
libflac SDL2MIXER_FLAC_LIBFLAC
libmodplug SDL2MIXER_MOD
libmodplug SDL2MIXER_MOD_MODPLUG
libvorbis SDL2MIXER_VORBIS_VORBISFILE
mpg123 SDL2MIXER_MP3
mpg123 SDL2MIXER_MP3_MPG123
nativemidi SDL2MIXER_MIDI_NATIVE
opusfile SDL2MIXER_OPUS
INVERTED_FEATURES
libflac SDL2MIXER_FLAC_DRFLAC
mpg123 SDL2MIXER_MP3_DRMP3
)
if(FEATURE_OPTIONS MATCHES "SDL2MIXER_VORBIS_VORBISFILE=ON")
set(VORBIS_BACKEND "VORBISFILE")
else()
set(VORBIS_BACKEND "STB")
if("fluidsynth" IN_LIST FEATURES)
vcpkg_find_acquire_program(PKGCONFIG)
list(APPEND EXTRA_OPTIONS "-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}")
endif()
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
${EXTRA_OPTIONS}
-DSDL2MIXER_VENDORED=OFF
-DSDL2MIXER_SAMPLES=OFF
-DSDL2MIXER_DEPS_SHARED=OFF
-DSDL2MIXER_OPUS_SHARED=OFF
-DSDL2MIXER_VORBIS_VORBISFILE_SHARED=OFF
-DSDL2MIXER_VORBIS=${VORBIS_BACKEND}
-DSDL2MIXER_VORBIS="VORBISFILE"
-DSDL2MIXER_FLAC_DRFLAC=OFF
-DSDL2MIXER_MIDI_NATIVE=OFF
-DSDL2MIXER_MIDI_TIMIDITY=OFF
-DSDL2MIXER_MP3_DRMP3=OFF
)
vcpkg_cmake_install()

View File

@ -1,10 +1,12 @@
{
"name": "sdl2-mixer",
"version": "2.6.3",
"port-version": 1,
"description": "Multi-channel audio mixer library for SDL.",
"homepage": "https://github.com/libsdl-org/SDL_mixer",
"license": "Zlib",
"dependencies": [
"libvorbis",
"sdl2",
{
"name": "vcpkg-cmake",
@ -15,9 +17,6 @@
"host": true
}
],
"default-features": [
"nativemidi"
],
"features": {
"fluidsynth": {
"description": "Use FluidSynth to play MIDI audio format.",
@ -26,34 +25,25 @@
]
},
"libflac": {
"description": "Use libflac to play FLAC audio format instead of the built-in dr_flac.",
"description": "Use libflac to play FLAC audio format.",
"dependencies": [
"libflac"
]
},
"libmodplug": {
"description": "Support for MOD audio format using libmodplug.",
"description": "Use libmodplug to play MOD audio format.",
"dependencies": [
"libmodplug"
]
},
"libvorbis": {
"description": "Use libvorbis to play OGG Vorbis audio format instead of the built-in stb_vorbis.",
"dependencies": [
"libvorbis"
]
},
"mpg123": {
"description": "Use mpg123 to play MP3 audio format instead of the built-in dr_mp3.",
"description": "Use mpg123 to play MP3 audio format.",
"dependencies": [
"mpg123"
]
},
"nativemidi": {
"description": "Support for MIDI audio format on Windows and macOS."
},
"opusfile": {
"description": "Support for Opus audio format using opusfile.",
"description": "Use opusfile to play Opus audio format.",
"dependencies": [
"opusfile"
]

View File

@ -879,8 +879,6 @@ sdformat6:x64-windows-static-md=fail
sdformat9:arm-uwp=fail
sdformat9:x64-uwp=fail
sdformat9:x64-windows-static-md=fail
sdl2-mixer:arm-uwp=fail
sdl2-mixer:x64-uwp=fail
sdl2-net:arm-uwp=fail
sdl2-net:x64-uwp=fail
septag-sx:arm64-windows=fail

View File

@ -7138,7 +7138,7 @@
},
"sdl2-mixer": {
"baseline": "2.6.3",
"port-version": 0
"port-version": 1
},
"sdl2-net": {
"baseline": "2.2.0",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "4c169dd178363fec7d46194a45dc250b604b1f2e",
"version": "2.6.3",
"port-version": 1
},
{
"git-tree": "dfa1721f4df6e01b9d30886c569c88128d7243f0",
"version": "2.6.3",