Merge pull request #927 from codicodi/add-sdl2-mixer

Add sdl2-mixer
This commit is contained in:
Robert Schumacher 2017-04-11 18:32:56 -07:00 committed by GitHub
commit a6f895ac8c
3 changed files with 125 additions and 0 deletions

View File

@ -0,0 +1,95 @@
cmake_minimum_required(VERSION 3.0)
project(SDL2_MIXER C)
find_path(SDL_INCLUDE_DIR SDL.h PATH_SUFFIXES SDL2)
find_library(SDL_LIBRARY SDL2)
set(SDL_MIXER_INCLUDES ${SDL_INCLUDE_DIR})
set(SDL_MIXER_LIBRARIES ${SDL_LIBRARY})
# builtin formats
set(SDL_MIXER_DEFINES
WAV_MUSIC
MID_MUSIC
USE_NATIVE_MIDI)
# MP3 support
if(SDL_MIXER_ENABLE_MP3)
find_path(SMPEG_INCLUDE_DIR smpeg.h)
find_library(SMPEG_LIBRARY smpeg2)
list(APPEND SDL_MIXER_INCLUDES ${SMPEG_INCLUDE_DIR})
list(APPEND SDL_MIXER_LIBRARIES ${SMPEG_LIBRARY})
list(APPEND SDL_MIXER_DEFINES MP3_MUSIC)
endif()
# FLAC support
if(SDL_MIXER_ENABLE_FLAC)
find_path(FLAC_INCLUDE_DIR flac/all.h)
find_library(FLAC_LIBRARY flac)
list(APPEND SDL_MIXER_INCLUDES ${FLAC_INCLUDE_DIR})
list(APPEND SDL_MIXER_LIBRARIES ${FLAC_LIBRARY})
list(APPEND SDL_MIXER_DEFINES FLAC_MUSIC)
endif()
# MOD support
if(SDL_MIXER_ENABLE_MOD)
find_path(MODPLUG_INCLUDE_DIR libmodplug/modplug.h)
find_library(MODPLUG_LIBRARY modplug)
list(APPEND SDL_MIXER_INCLUDES ${MODPLUG_INCLUDE_DIR})
list(APPEND SDL_MIXER_LIBRARIES ${MODPLUG_LIBRARY})
list(APPEND SDL_MIXER_DEFINES MODPLUG_MUSIC)
endif()
# Ogg-Vorbis support
if(SDL_MIXER_ENABLE_OGGVORBIS)
find_path(VORBIS_INCLUDE_DIR vorbis/codec.h)
find_library(VORBISFILE_LIBRARY vorbisfile)
list(APPEND SDL_MIXER_INCLUDES ${VORBIS_INCLUDE_DIR})
list(APPEND SDL_MIXER_LIBRARIES ${VORBISFILE_LIBRARY})
list(APPEND SDL_MIXER_DEFINES OGG_MUSIC)
endif()
add_library(SDL2_mixer
dynamic_flac.c
dynamic_fluidsynth.c
dynamic_mod.c
dynamic_modplug.c
dynamic_mp3.c
dynamic_ogg.c
effect_position.c
effect_stereoreverse.c
effects_internal.c
fluidsynth.c
load_aiff.c
load_flac.c
load_mp3.c
load_ogg.c
load_voc.c
mixer.c
music.c
music_cmd.c
music_flac.c
music_mad.c
music_mod.c
music_modplug.c
music_ogg.c
wavestream.c
native_midi/native_midi_common.c
native_midi/native_midi_win32.c)
target_compile_definitions(SDL2_mixer PRIVATE ${SDL_MIXER_DEFINES})
target_include_directories(SDL2_mixer PRIVATE ${SDL_MIXER_INCLUDES} ./native_midi)
target_link_libraries(SDL2_mixer ${SDL_MIXER_LIBRARIES} Winmm)
install(TARGETS SDL2_mixer
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
if(NOT SDL_MIXER_SKIP_HEADERS)
install(FILES SDL_mixer.h DESTINATION include/SDL2)
endif()
message(STATUS "Link-time dependencies:")
foreach(LIBRARY ${SDL_MIXER_LIBRARIES})
message(STATUS " " ${LIBRARY})
endforeach()

4
ports/sdl2-mixer/CONTROL Normal file
View File

@ -0,0 +1,4 @@
Source: sdl2-mixer
Version: 2.0.1
Description: Multi-channel audio mixer library for SDL.
Build-Depends: sdl2, libflac, smpeg2, libmodplug, libvorbis

View File

@ -0,0 +1,26 @@
include(vcpkg_common_functions)
set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/SDL2_mixer-2.0.1)
vcpkg_download_distfile(ARCHIVE
URLS "https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.zip"
FILENAME "SDL2_mixer-2.0.1.zip"
SHA512 7399f08c5b091698c90d49fcc2996677eae8a36f05a65b4470807c9cf2c04730669e0ca395893cfa49177a929f8c5b2b10b6c541ba2fe2646300dcdad4ec1d9e)
vcpkg_extract_source_archive(${ARCHIVE})
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DSDL_MIXER_ENABLE_MP3=ON # smpeg2
-DSDL_MIXER_ENABLE_FLAC=ON # libflac
-DSDL_MIXER_ENABLE_MOD=ON # libmodplug
-DSDL_MIXER_ENABLE_OGGVORBIS=ON # libvorbis
OPTIONS_DEBUG
-DSDL_MIXER_SKIP_HEADERS=ON)
vcpkg_install_cmake()
vcpkg_copy_pdbs()
file(COPY ${SOURCE_PATH}/COPYING.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/sdl2-mixer)
file(RENAME ${CURRENT_PACKAGES_DIR}/share/sdl2-mixer/COPYING.txt ${CURRENT_PACKAGES_DIR}/share/sdl2-mixer/copyright)