diff --git a/.github/fetch_sdl_vc.ps1 b/.github/fetch_sdl_vc.ps1 new file mode 100644 index 00000000..2e3cc7c6 --- /dev/null +++ b/.github/fetch_sdl_vc.ps1 @@ -0,0 +1,40 @@ +$ErrorActionPreference = "Stop" + +$project_root = "$psScriptRoot\.." +Write-Output "project_root: $project_root" + +$sdl2_version = "2.0.9" +$sdl2_zip = "SDL2-devel-$($sdl2_version)-VC.zip" + +$sdl2_url = "https://github.com/libsdl-org/SDL/releases/download/release-$($sdl2_version)/SDL2-devel-$($sdl2_version)-VC.zip" +$sdl2_dlpath = "$($Env:TEMP)\$sdl2_zip" + +$sdl2_bindir = "$($project_root)" +$sdl2_extractdir = "$($sdl2_bindir)\SDL2-$($sdl2_version)" +$sdl2_root_name = "SDL2-devel-VC" + +echo "sdl2_bindir: $sdl2_bindir" +echo "sdl2_extractdir: $sdl2_extractdir" +echo "sdl2_root_name: $sdl2_root_name" + +echo "Cleaning previous artifacts" +if (Test-Path $sdl2_extractdir) { + Remove-Item $sdl2_extractdir -Recurse -Force +} +if (Test-Path "$($sdl2_bindir)/$sdl2_root_name") { + Remove-Item "$($sdl2_bindir)/$sdl2_root_name" -Recurse -Force +} +if (Test-Path $sdl2_dlpath) { + Remove-Item $sdl2_dlpath -Force +} + +Write-Output "Downloading $sdl2_url" +Invoke-WebRequest -Uri $sdl2_url -OutFile $sdl2_dlpath + +Write-Output "Extracting archive" +Expand-Archive $sdl2_dlpath -DestinationPath $sdl2_bindir + +Write-Output "Setting up SDL2 folder" +Rename-Item $sdl2_extractdir $sdl2_root_name + +Write-Output "Done" diff --git a/.github/fetch_yasm.ps1 b/.github/fetch_yasm.ps1 new file mode 100644 index 00000000..5353e46f --- /dev/null +++ b/.github/fetch_yasm.ps1 @@ -0,0 +1,33 @@ +$ErrorActionPreference = "Stop" + +$project_root = "$psScriptRoot\.." +Write-Output "project_root: $project_root" + +$yasm_version = "1.3.0" +$yasm_dlexe = "yasm-$yasm_version-win64.exe" + +$yasm_url = "https://github.com/yasm/yasm/releases/download/v$yasm_version/$yasm_dlexe" +$yasm_exename = "yasm.exe" +$yasm_exepath = "$project_root/yasm.exe" + +$yasm_dlpath = "$project_root\$yasm_dlexe" + +echo "yasm_dlpath: $yasm_dlpath" +echo "yasm_exename: $yasm_exename" +echo "yasm_exepath: $yasm_exepath" + +echo "Cleaning previous artifacts" +if (Test-Path $yasm_dlpath) { + Remove-Item $yasm_dlpath -Force +} +if (Test-Path $yasm_exepath) { + Remove-Item $yasm_exepath -Force +} + +Write-Output "Downloading $yasm_dlexe ($yasm_url)" +Invoke-WebRequest -Uri $yasm_url -OutFile $yasm_dlpath + +Write-Output "Moving $yasm_dlexe to $yasm_exename" +Rename-Item $yasm_dlpath $yasm_exename + +Write-Output "Done" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a1dcf5ec..f3d6a05c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,10 +15,16 @@ jobs: fail-fast: false matrix: platform: - - { name: Windows (mingw32), os: windows-latest, shell: 'msys2 {0}', msystem: mingw32, msys-env: mingw-w64-i686 } - - { name: Windows (mingw64), os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64 } - - { name: Linux (CMake), os: ubuntu-20.04, shell: sh, cmake: '-GNinja' } - - { name: Linux (autotools), os: ubuntu-20.04, shell: sh } + - { name: Windows (MSVC+CMake), os: windows-2019, shell: sh, cmake: '-DSDL2MIXER_VENDORED=ON -GNinja', msvc: 1, shared: 1, static: 0 } + - { name: Windows (mingw32+autotools), os: windows-latest, shell: 'msys2 {0}', msystem: mingw32, msys-env: mingw-w64-i686, shared: 1, static: 1 } + - { name: Windows (mingw64+CMake), os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64, shared: 1, static: 0, + cmake: '-DSDL2MIXER_VENDORED=OFF -G "Ninja Multi-Config"' } + - { name: Linux (autotools), os: ubuntu-20.04, shell: sh, shared: 1, static: 1} + - { name: Linux (CMake), os: ubuntu-20.04, shell: sh, cmake: '-DSDL2MIXER_VENDORED=ON -GNinja', shared: 1, static: 0 } + - { name: 'Linux (CMake, static)', os: ubuntu-20.04, shell: sh, cmake: '-DSDL2MIXER_VENDORED=ON -DBUILD_SHARED_LIBS=OFF -GNinja', shared: 0, static: 1 } + - { name: Macos (autotools), os: macos-latest, shell: sh, shared: 1, static: 1 } + - { name: Macos (CMake), os: macos-latest, shell: sh, cmake: '-DSDL2MIXER_VENDORED=ON -GNinja', shared: 1, static: 0 } + steps: - name: Set up MSYS2 @@ -39,7 +45,23 @@ jobs: ${{ matrix.platform.msys-env }}-opusfile ${{ matrix.platform.msys-env }}-ninja ${{ matrix.platform.msys-env }}-pkg-config - + - name: Setup Macos dependencies + if: runner.os == 'macOS' + run: | + brew install \ + sdl2 \ + autoconf \ + automake \ + libtool \ + ninja \ + pkg-config \ + mpg123 \ + flac \ + libmodplug \ + fluidsynth \ + libvorbis \ + opusfile \ + ${NULL+} - name: Setup Linux dependencies if: runner.os == 'Linux' run: | @@ -61,56 +83,101 @@ jobs: - uses: actions/checkout@v2 with: submodules: recursive + + - name: Setup MSVC dependencies + if: "matrix.platform.msvc" + shell: pwsh + run: | + echo "::group::Downloading SDL" + .github/fetch_sdl_vc.ps1 + echo "SDL2_DIR=$Env:GITHUB_WORKSPACE/SDL2-devel-VC" >> $Env:GITHUB_ENV + echo "::endgroup::" + echo "::group::Downloading yasm" + .github/fetch_yasm.ps1 + echo "${{ github.workspace }}" >> $Env:GITHUB_PATH + echo "::endgroup::" + - name: Setup Ninja for MSVC + if: "matrix.platform.msvc" + uses: ashutoshvarma/setup-ninja@master + with: + version: 1.10.2 + - uses: ilammy/msvc-dev-cmd@v1 + if: "matrix.platform.msvc" + with: + arch: x64 + - name: Check that versioning is consistent # We only need to run this once: arbitrarily use the Linux/CMake build if: "runner.os == 'Linux' && matrix.platform.cmake" run: ./test-versioning.sh - - name: Configure CMake + - name: Setup (CMake) + if: ${{ matrix.platform.cmake && !matrix.platform.msystem && !matrix.platform.msvc }} + uses: jwlawson/actions-setup-cmake@v1.12 + with: + cmake-version: '3.16' + - name: Configure (CMake) if: "matrix.platform.cmake" run: | - cmake -B build \ + set -- \ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_VERBOSE_MAKEFILE=ON \ - -DSUPPORT_FLAC=ON \ - -DSUPPORT_OGG=ON \ - -DSUPPORT_OPUS=ON \ - -DSUPPORT_MP3_MPG123=ON \ - -DSUPPORT_MOD_MODPLUG=ON \ + -DSDL2MIXER_FLAC=ON \ + -DSDL2MIXER_FLAC_LIBFLAC=ON \ + -DSDL2MIXER_VORBIS=VORBISFILE \ + -DSDL2MIXER_OPUS=ON \ + -DSDL2MIXER_MP3_MPG123=ON \ + -DSDL2MIXER_MOD_MODPLUG=ON \ + -DCMAKE_INSTALL_PREFIX=prefix_cmake \ + ${NULL+} + + cmake -B build \ + "$@" \ ${{ matrix.platform.cmake }} - - name: Build + - name: Build (CMake) + if: "matrix.platform.cmake" + run: | + cmake --build build/ --config Release --parallel --verbose + - name: Install (CMake) if: "matrix.platform.cmake" - run: cmake --build build/ --config Release -# - name: Install -# if: "matrix.platform.shell == 'sh' && matrix.platform.cmake" -# run: | -# set -eu -# rm -fr DESTDIR-cmake -# DESTDIR=$(pwd)/DESTDIR-cmake cmake --install build/ --config Release -# ( cd DESTDIR-cmake; find ) | LC_ALL=C sort -u + run: | + set -eu + rm -fr prefix_cmake + cmake --install build/ --config Release + echo "SDL2_mixer_DIR=$(pwd)/prefix_cmake" >> $GITHUB_ENV + ( cd prefix_cmake; find . ) | LC_ALL=C sort -u - - name: Configure Autotools + - name: Configure (Autotools) if: "! matrix.platform.cmake" run: | set -eu rm -fr build-autotools mkdir build-autotools ./autogen.sh - ( cd build-autotools && ../configure ) - - name: Build with Autotools + set -- -prefix=$(pwd)/prefix_autotools + ( cd build-autotools && ../configure "$@" ) + - name: Build (Autotools) if: "! matrix.platform.cmake" run: | set -eu parallel="$(getconf _NPROCESSORS_ONLN)" make -j"${parallel}" -C build-autotools V=1 - - name: Install with Autotools + - name: Install (Autotools) if: "! matrix.platform.cmake" run: | set -eu curdir="$(pwd)" parallel="$(getconf _NPROCESSORS_ONLN)" - rm -fr DESTDIR-autotools - mkdir DESTDIR-autotools - make -j"${parallel}" -C build-autotools install DESTDIR="${curdir}/DESTDIR-autotools" V=1 - ( cd DESTDIR-autotools; find ) | LC_ALL=C sort -u + rm -rf prefix_autotools + make -j"${parallel}" -C build-autotools install V=1 + echo "SDL2_mixer_DIR=$(pwd)/prefix_autotools" >> $GITHUB_ENV + ( cd prefix_autotools; find ) | LC_ALL=C sort -u + + - name: Verify CMake configuration files + run: | + cmake -S cmake/test -B cmake_config_build \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_PREFIX_PATH="${{ env.SDL2_mixer_DIR }};${{ env.SDL2_DIR }}" \ + -DTEST_SHARED=${{ matrix.platform.shared }} \ + -DTEST_STATIC=${{ matrix.platform.static }} + cmake --build cmake_config_build --verbose --config Release diff --git a/CMakeLists.txt b/CMakeLists.txt index cdfa2c8c..be4a2a69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,212 +1,880 @@ -cmake_minimum_required(VERSION 3.1.0) -project(SDL2_mixer C) +cmake_minimum_required(VERSION 3.16) -# FIXME: CMAKE SUPPORT IN SDL2_mixer IS VERY INCOMPLETE YET !!! -# -# FIXME: make it able build against system codec libraries, too. -# FIXME: handle library versioning. -# FIXME: test accross different target platforms. +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") # See docs/release_checklist.md set(MAJOR_VERSION 2) set(MINOR_VERSION 5) set(MICRO_VERSION 1) -set(FULL_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}") +set(SDL_REQUIRED_VERSION 2.0.9) -option(SUPPORT_WAV "Support loading WAVE music" ON) -option(SUPPORT_FLAC "Support loading FLAC music with libFLAC" OFF) -option(SUPPORT_OGG "Support loading OGG Vorbis music via libvorbis" OFF) -option(SUPPORT_OPUS "Support loading OGG Opus music via libopusfile" OFF) -option(SUPPORT_MP3_MPG123 "Support loading MP3 music via MPG123" OFF) -option(SUPPORT_MOD_MODPLUG "Support loading MOD music via modplug" OFF) -option(SUPPORT_MID_FLUIDSYNTH "Support loading MIDI music via FluidSynth" OFF) -option(SUPPORT_MID_TIMIDITY "Support loading MIDI music via TiMidity" ON) +# For historical reasons this is 3.0.0 rather than the expected 1.0.0 +set(DYLIB_COMPATIBILITY_VERSION "3.0.0") -option(BUILD_SHARED_LIBS "Enable shared library" ON) +include(PrivateSdlFunctions) +sdl_calculate_derived_version_variables() -if (NOT (TARGET SDL2::SDL2 OR TARGET SDL2::SDL2-static)) - find_package(SDL2 REQUIRED) - if(NOT TARGET SDL2::SDL2) - # SDL < 2.0.12 - add_library(SDL2::SDL2 INTERFACE IMPORTED) - set_target_properties(SDL2::SDL2 PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIRS} ${SDL2_INCLUDE_DIR} - INTERFACE_LINK_LIBRARIES ${SDL2_LIBRARIES} ${SDL2_LIBRARY} - ) - endif() +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) + message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the SDL_mixer source code and call cmake from there") endif() -# Calculate a libtool-like version number -math(EXPR BINARY_AGE "${MINOR_VERSION} * 100 + ${MICRO_VERSION}") -if(MINOR_VERSION MATCHES "[02468]$") - # Stable branch, 2.6.1 -> libSDL2_mixer-2.0.so.0.600.1 - set(INTERFACE_AGE ${MICRO_VERSION}) -else() - # Development branch, 2.5.1 -> libSDL2_mixer-2.0.so.0.501.0 - set(INTERFACE_AGE 0) -endif() - -# Increment this if there is an incompatible change - but if that happens, -# we should rename the library from SDL2 to SDL3, at which point this would -# reset to 0 anyway. -set(LT_MAJOR "0") - -math(EXPR LT_AGE "${BINARY_AGE} - ${INTERFACE_AGE}") -math(EXPR LT_CURRENT "${LT_MAJOR} + ${LT_AGE}") -set(LT_REVISION "${INTERFACE_AGE}") -# For historical reasons, the library name redundantly includes the major -# version twice: libSDL2_mixer-2.0.so.0. -# TODO: in SDL 3, set the OUTPUT_NAME to plain SDL3_mixer, which will simplify -# it to libSDL3_mixer.so.0 -set(LT_RELEASE "2.0") -set(LT_VERSION "${LT_MAJOR}.${LT_AGE}.${LT_REVISION}") - -# The following should match the versions in the Xcode project file. -# Each version is 1 higher than you might expect, for compatibility -# with libtool: macOS ABI versioning is 1-based, unlike other platforms -# which are normally 0-based. -math(EXPR DYLIB_CURRENT_VERSION_MAJOR "${LT_MAJOR} + ${LT_AGE} + 1") -math(EXPR DYLIB_CURRENT_VERSION_MINOR "${LT_REVISION}") -math(EXPR DYLIB_COMPAT_VERSION_MAJOR "${LT_MAJOR} + 1") -set(DYLIB_CURRENT_VERSION "${DYLIB_CURRENT_VERSION_MAJOR}.${DYLIB_CURRENT_VERSION_MINOR}.0") -# For historical reasons this is 3.0.0 rather than the expected 1.0.0 -set(DYLIB_COMPATIBILITY_VERSION "3.0.0") +project(SDL2_mixer + LANGUAGES C + VERSION "${FULL_VERSION}" +) -# For the static assertions in mixer.c -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSDL_BUILD_MAJOR_VERSION=${MAJOR_VERSION}") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSDL_BUILD_MINOR_VERSION=${MINOR_VERSION}") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSDL_BUILD_MICRO_VERSION=${MICRO_VERSION}") +message(STATUS "Configuring ${PROJECT_NAME} ${PROJECT_VERSION}") -include_directories(include src src/codecs) +if(POLICY CMP0112) + # Target file component generator expressions do not add target dependencies. + cmake_policy(SET CMP0112 NEW) +endif() -add_library(SDL2_mixer) -add_library(SDL2::mixer ALIAS SDL2_mixer) +# Set defaults preventing destination file conflicts +set(SDL2MIXER_DEBUG_POSTFIX "d" + CACHE STRING "Name suffix for debug builds") +mark_as_advanced(SDL2MIXER_DEBUG_POSTFIX) -if(SUPPORT_MID_TIMIDITY) - set(TIMIDITY_SRCS - src/codecs/timidity/common.c - src/codecs/timidity/instrum.c - src/codecs/timidity/mix.c - src/codecs/timidity/output.c - src/codecs/timidity/playmidi.c - src/codecs/timidity/readmidi.c - src/codecs/timidity/resample.c - src/codecs/timidity/tables.c - src/codecs/timidity/timidity.c - ) +# Assume MSVC projects don't have a package manager and need vendored dependencies (by default). +# Most other platforms have some kind of package manager. +# FIXME: consider a package manager such as conan/vcpkg instead of vendoring +if(MSVC) + set(vendored_default ON) +else() + set(vendored_default OFF) endif() -target_sources(SDL2_mixer PRIVATE - src/effect_position.c - src/effects_internal.c - src/effect_stereoreverse.c - src/mixer.c - src/music.c - src/utils.c - src/codecs/load_aiff.c - src/codecs/load_voc.c - src/codecs/music_cmd.c - src/codecs/music_wav.c - src/codecs/music_drflac.c - src/codecs/music_flac.c - src/codecs/music_drmp3.c - src/codecs/music_mpg123.c - src/codecs/mp3utils.c - src/codecs/music_ogg.c - src/codecs/music_ogg_stb.c - src/codecs/music_opus.c - src/codecs/music_modplug.c - src/codecs/music_xmp.c - src/codecs/music_fluidsynth.c - src/codecs/music_timidity.c - src/codecs/music_nativemidi.c - ${TIMIDITY_SRCS} -) +include(CheckSymbolExists) +include(CMakeDependentOption) +include(CMakePackageConfigHelpers) +include(GNUInstallDirs) -if (SUPPORT_WAV) - target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_WAV) -endif() +option(CMAKE_POSITION_INDEPENDENT_CODE "Build static libraries with -fPIC" ON) +option(BUILD_SHARED_LIBS "Build the library as a shared library" ON) + +# Save BUILD_SHARED_LIBS variable as soon as possible +set(SDL2MIXER_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) + +option(SDL2MIXER_INSTALL "Enable SDL2mixer install target" ON) +option(SDL2MIXER_DEPS_SHARED "Default value for loading dependencies dynamically" ON) +option(SDL2MIXER_VENDORED "Use vendored third-party libraries" ${vendored_default}) -if (SUPPORT_OGG OR SUPPORT_FLAC OR SUPPORT_OPUS) - add_subdirectory(external/ogg) +option(SDL2MIXER_SAMPLES "Build the SDL2_mixer sample program(s)" ON) +cmake_dependent_option(SDL2MIXER_SAMPLES_INSTALL "Install the SDL2_mixer sample program(s)" OFF "SDL2MIXER_SAMPLES;SDL2MIXER_INSTALL" OFF) + +if(UNIX AND NOT APPLE) + set(sdl2mixer_cmd_default ON) +else() + set(sdl2mixer_cmd_default OFF) endif() +option(SDL2MIXER_CMD "Support an external music player" ${sdl2mixer_cmd_default}) + +option(SDL2MIXER_FLAC "Enable FLAC music" ON) + +cmake_dependent_option(SDL2MIXER_FLAC_LIBFLAC "Enable FLAC music using libFLAC" ON SDL2MIXER_FLAC OFF) +cmake_dependent_option(SDL2MIXER_FLAC_LIBFLAC_SHARED "Dynamically load LIBFLAC" "${SDL2MIXER_DEPS_SHARED}" SDL2MIXER_FLAC_LIBFLAC OFF) + +cmake_dependent_option(SDL2MIXER_FLAC_DRFLAC "Enable FLAC music using drflac" ON SDL2MIXER_FLAC OFF) + +option(SDL2MIXER_MOD "Support loading MOD music" ON) -if (SUPPORT_FLAC) - target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_FLAC_LIBFLAC) - add_subdirectory(external/flac) - target_include_directories(SDL2_mixer PRIVATE external/flac/include) - target_link_libraries(SDL2_mixer PRIVATE FLAC) +cmake_dependent_option(SDL2MIXER_MOD_MODPLUG "Support loading MOD music via modplug" ON SDL2MIXER_MOD OFF) +cmake_dependent_option(SDL2MIXER_MOD_MODPLUG_SHARED "Dynamically load modplug" "${SDL2MIXER_DEPS_SHARED}" SDL2MIXER_MOD_MODPLUG OFF) + +cmake_dependent_option(SDL2MIXER_MOD_XMP "Support loading MOD music via libxmp" OFF SDL2MIXER_MOD OFF) +cmake_dependent_option(SDL2MIXER_MOD_XMP_LITE "Use libxmp-lite instead of libxmp" OFF SDL2MIXER_MOD_XMP OFF) +cmake_dependent_option(SDL2MIXER_MOD_XMP_SHARED "Dynamically load libxmp(-lite)" "${SDL2MIXER_DEPS_SHARED}" SDL2MIXER_MOD_XMP OFF) + +if(SDL2MIXER_MOD AND NOT (SDL2MIXER_MOD_MODPLUG OR SDL2MIXER_MOD_XMP)) + message(FATAL_EROR "MOD support was enabled (SDL2MIXER_MOD) but neither mpdplug (SDL2MIXER_MOD_MODPLUG) or xmp (SDL2MIXER_MOD_XMP) was enabled.") endif() -if (SUPPORT_OGG) - target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_OGG) - add_subdirectory(external/vorbis) - target_include_directories(SDL2_mixer PRIVATE external/vorbis/include) - target_link_libraries(SDL2_mixer PRIVATE vorbisfile vorbis ogg) +option(SDL2MIXER_MP3 "Enable MP3 music" ON) + +cmake_dependent_option(SDL2MIXER_MP3_DRMP3 "Support loading MP3 music via dr_mp3" ON SDL2MIXER_MP3 OFF) + +cmake_dependent_option(SDL2MIXER_MP3_MPG123 "Support loading MP3 music via MPG123" OFF SDL2MIXER_MP3 OFF) +cmake_dependent_option(SDL2MIXER_MP3_MPG123_SHARED "Dynamically load mpg123" "${SDL2MIXER_DEPS_SHARED}" SDL2MIXER_MP3_MPG123 OFF) + +if(SDL2MIXER_MP3 AND NOT (SDL2MIXER_MP3_DRMP3 OR SDL2MIXER_MP3_MPG123)) + message(FATAL_ERROR "MP3 support was enabled (SDL2MIXER_MP3) but neither drmp3 (SDL2MIXER_MP3_DRMP3) or mpg123 (SDL2MIXER_MP3_MPG123) were enabled.") endif() -if (SUPPORT_OPUS) - target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_OPUS -DOPUSFILE_HEADER=) - set(OP_DISABLE_HTTP ON CACHE BOOL "Disable HTTP support") - set(OP_DISABLE_EXAMPLES ON CACHE BOOL "Do not build example applications") - set(OP_DISABLE_DOCS ON CACHE BOOL "Do not build API documentation") - add_subdirectory(external/opus) - add_subdirectory(external/opusfile) - target_link_libraries(SDL2_mixer PRIVATE opusfile) +option(SDL2MIXER_MIDI "Enable MIDI music" ON) + +cmake_dependent_option(SDL2MIXER_MIDI_FLUIDSYNTH "Support FluidSynth MIDI output" ON "SDL2MIXER_MIDI;NOT SDL2MIXER_VENDORED" OFF) +cmake_dependent_option(SDL2MIXER_MIDI_FLUIDSYNTH_SHARED "Dynamically load libfluidsynth" "${SDL2MIXER_DEPS_SHARED}" SDL2MIXER_MIDI_FLUIDSYNTH OFF) + +if(WIN32 OR APPLE OR HAIKU) + cmake_dependent_option(SDL2MIXER_MIDI_NATIVE "Support native MIDI output" ON SDL2MIXER_MIDI OFF) +else() + set(SDL2MIXER_MIDI_NATIVE OFF) endif() -if (SUPPORT_MP3_MPG123) - target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_MP3_MPG123) - add_subdirectory(external/mpg123/ports/cmake) - target_include_directories(SDL2_mixer PRIVATE external/mpg123/ports/cmake/src/libmpg123) - target_link_libraries(SDL2_mixer PRIVATE libmpg123) +cmake_dependent_option(SDL2MIXER_MIDI_TIMIDITY "Support timidity MIDI output" ON SDL2MIXER_MIDI OFF) + +if(SDL2MIXER_MIDI AND NOT (SDL2MIXER_MIDI_TIMIDITY OR SDL2MIXER_MIDI_NATIVE OR SDL2MIXER_MIDI_FLUIDSYNTH)) + message(FATAL_ERROR "MIDI support was enabled (SDL2MIXER_MIDI) but neither FluidSynth (SDL2MIXER_MIDI_FLUIDSYNTH), native (SDL2MIXER_MIDI_NATIVE) or timidity (SDL2MIXER_MIDI_TIMIDITY) was enabled") endif() -if (SUPPORT_MOD_MODPLUG) - target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_MOD_MODPLUG -DMODPLUG_HEADER=) - add_subdirectory(external/libmodplug) - target_include_directories(SDL2_mixer PRIVATE external/libmodplug/src) - target_link_libraries(SDL2_mixer PRIVATE modplug) +option(SDL2MIXER_OPUS "Enable Opus music" ON) +cmake_dependent_option(SDL2MIXER_OPUS_SHARED "Dynamically load libopus" ON SDL2MIXER_OPUS OFF) + +set(sdl2mixer_vorbis_strings STB TREMOR VORBISFILE) +set(SDL2MIXER_VORBIS "STB" CACHE STRING "Enable OGG Vorbis music") +set_property(CACHE SDL2MIXER_VORBIS PROPERTY STRINGS "${sdl2mixer_vorbis_strings}") +if(SDL2MIXER_VORBIS) + if(NOT SDL2MIXER_VORBIS IN_LIST sdl2mixer_vorbis_strings) + message(FATAL_ERROR "SDL2MIXER_VORBIS contains an invalid value (=${SDL2MIXER_VORBIS}). It must be one of ${sdl2mixer_vorbis_strings}.") + endif() +endif() +set(SDL2MIXER_VORBIS_STB OFF) +set(SDL2MIXER_VORBIS_TREMOR OFF) +set(SDL2MIXER_VORBIS_VORBISFILE OFF) +if(SDL2MIXER_VORBIS STREQUAL "STB") + set(SDL2MIXER_VORBIS_STB ON) endif() +if(SDL2MIXER_VORBIS STREQUAL "TREMOR") + set(SDL2MIXER_VORBIS_TREMOR ON) +endif() +if(SDL2MIXER_VORBIS STREQUAL "VORBISFILE") + set(SDL2MIXER_VORBIS_VORBISFILE ON) +endif() +cmake_dependent_option(SDL2MIXER_VORBIS_TREMOR_SHARED "Dynamically load tremor library" ON SDL2MIXER_VORBIS_TREMOR OFF) +cmake_dependent_option(SDL2MIXER_VORBIS_VORBISFILE_SHARED "Dynamically load vorbisfile library" ON SDL2MIXER_VORBIS_VORBISFILE OFF) + +option(SDL2MIXER_WAVE "Enable streaming WAVE music" ON) -if (SUPPORT_MID_FLUIDSYNTH) - target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_MID_FLUIDSYNTH) - target_link_libraries(SDL2_mixer PRIVATE fluidsynth) +if(SDL2MIXER_VORBIS_TREMOR OR SDL2MIXER_VORBIS_VORBISFILE OR SDL2MIXER_FLAC_LIBFLAC OR SDL2MIXER_OPUS) + set(SDL2MIXER_OGG TRUE) + set(SDL2MIXER_OGG_install FALSE) + if(SDL2MIXER_VORBIS_VORBISFILE_SHARED OR SDL2MIXER_FLAC_SHARED OR SDL2MIXER_OPUS_SHARED) + set(SDL2MIXER_OGG_SHARED TRUE) + set(SDL2MIXER_OGG_install TRUE) + else() + set(SDL2MIXER_OGG_SHARED FALSE) + if(NOT SDL2MIXER_BUILD_SHARED_LIBS) + set(SDL2MIXER_OGG_install TRUE) + endif() + endif() +else() + set(SDL2MIXER_OGG FALSE) endif() -if (SUPPORT_MID_TIMIDITY) - target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_MID_TIMIDITY) +if(SDL2MIXER_BUILD_SHARED_LIBS) + set(sdl2_mixer_export_name SDL2_mixer) + set(sdl2_mixer_install_name_infix shared) + set(sdl2_target_name SDL2::SDL2) +else() + set(sdl2_mixer_export_name SDL2_mixer-static) + set(sdl2_mixer_install_name_infix static) + set(sdl2_target_name SDL2::SDL2-static) endif() -if(BUILD_SHARED_LIBS) - if(WIN32 OR OS2) - set_target_properties(SDL2_mixer PROPERTIES PREFIX "") - endif() +sdl_find_sdl2(${sdl2_target_name} ${SDL_REQUIRED_VERSION}) + +set(BUILD_SHARED_LIBS ${SDL2MIXER_BUILD_SHARED_LIBS}) +add_library(SDL2_mixer + src/codecs/load_aiff.c + src/codecs/load_voc.c + src/codecs/mp3utils.c + src/codecs/music_cmd.c + src/codecs/music_drflac.c + src/codecs/music_drmp3.c + src/codecs/music_flac.c + src/codecs/music_fluidsynth.c + src/codecs/music_modplug.c + src/codecs/music_mpg123.c + src/codecs/music_nativemidi.c + src/codecs/music_ogg.c + src/codecs/music_ogg_stb.c + src/codecs/music_opus.c + src/codecs/music_timidity.c + src/codecs/music_wav.c + src/codecs/music_xmp.c + src/effect_position.c + src/effect_stereoreverse.c + src/effects_internal.c + src/mixer.c + src/music.c + src/utils.c +) +add_library(SDL2_mixer::${sdl2_mixer_export_name} ALIAS SDL2_mixer) +target_include_directories(SDL2_mixer + PUBLIC + "$" + "$" + PRIVATE + src + src/codecs +) +target_compile_definitions(SDL2_mixer PRIVATE + BUILD_SDL + SDL_BUILD_MAJOR_VERSION=${MAJOR_VERSION} + SDL_BUILD_MINOR_VERSION=${MINOR_VERSION} + SDL_BUILD_MICRO_VERSION=${MICRO_VERSION} +) +target_link_libraries(SDL2_mixer PRIVATE $) +if(WIN32 AND BUILD_SHARED_LIBS) + target_sources(SDL2_mixer PRIVATE + version.rc + ) +endif() +set_target_properties(SDL2_mixer PROPERTIES + DEFINE_SYMBOL DLL_EXPORT + PUBLIC_HEADER "include/SDL_mixer.h" + EXPORT_NAME ${sdl2_mixer_export_name} + C_VISIBILITY_PRESET "hidden" +) +if(NOT ANDROID) + set_target_properties(SDL2_mixer PROPERTIES + DEBUG_POSTFIX "${SDL2MIXER_DEBUG_POSTFIX}" + ) if(APPLE) - # TODO: Handle DYLIB_COMPATIBILITY_VERSION, DYLIB_CURRENT_VERSION here + # the SOVERSION property corresponds to the compatibility version and VERSION corresponds to the current version + # https://cmake.org/cmake/help/latest/prop_tgt/SOVERSION.html#mach-o-versions + set_target_properties(SDL2_mixer PROPERTIES + SOVERSION "${DYLIB_COMPATIBILITY_VERSION}" + VERSION "${DYLIB_CURRENT_VERSION}" + ) + else() + set_target_properties(SDL2_mixer PROPERTIES + SOVERSION "${LT_MAJOR}" + VERSION "${LT_VERSION}" + ) endif() - if(WIN32) - target_compile_definitions(SDL2_mixer PRIVATE -DDLL_EXPORT) - target_sources(SDL2_mixer PRIVATE version.rc) - elseif(OS2) +endif() +if(SDL2MIXER_BUILD_SHARED_LIBS AND (APPLE OR (UNIX AND NOT ANDROID))) + add_custom_command(TARGET SDL2_mixer POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E create_symlink "$" "libSDL2_mixer$<$:${SDL2MIXER_DEBUG_POSTFIX}>$" + # BYPRODUCTS "libSDL2_mixer$<$:${SDL2MIXER_DEBUG_POSTFIX}>$" # Needs CMake 3.20 + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" + ) +endif() +if(SDL2MIXER_BUILD_SHARED_LIBS) + if(WIN32 OR OS2) + set_target_properties(SDL2_mixer PROPERTIES + PREFIX "" + ) + endif() + if(OS2) # OS/2 doesn't support a DLL name longer than 8 characters. set_target_properties(SDL2_mixer PROPERTIES - OUTPUT_NAME "SDL2mix" + OUTPUT_NAME "SDL2mix" ) elseif(UNIX AND NOT ANDROID) - # This is compatible with the libtool build set_target_properties(SDL2_mixer PROPERTIES - VERSION ${LT_VERSION} - SOVERSION ${LT_MAJOR} - OUTPUT_NAME "SDL2_mixer-${LT_RELEASE}" + OUTPUT_NAME "SDL2_mixer-${LT_RELEASE}" ) endif() +else() + if(MSVC OR (WATCOM AND (WIN32 OR OS2))) + set_target_properties(SDL2_mixer PROPERTIES + OUTPUT_NAME "SDL2_mixer-static" + ) + endif() +endif() + +if(SDL2MIXER_BUILD_SHARED_LIBS) + # Use `Compatible Interface Properties` to ensure a shared SDL2_mixer is linked to a shared SDL2 library + set_property(TARGET SDL2_mixer PROPERTY INTERFACE_SDL2_SHARED ${SDL2MIXER_BUILD_SHARED_LIBS}) + set_property(TARGET SDL2_mixer APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL2_SHARED) endif() -target_include_directories(SDL2_mixer PUBLIC include) +if(SDL2MIXER_BUILD_SHARED_LIBS) + # Make sure static library dependencies are built with -fPIC when building a shared SDL2_mixer + set(CMAKE_POSITION_INDEPENDENT_CODE ON) +endif() -if (BUILD_SHARED_LIBS) - target_link_libraries(SDL2_mixer PRIVATE SDL2::SDL2) -else() - target_link_libraries(SDL2_mixer PRIVATE SDL2::SDL2-static) +set(INSTALL_EXTRA_TARGETS) +set(PC_LIBS) +set(PC_REQUIRES) + +if(SDL2MIXER_CMD) + target_compile_definitions(SDL2_mixer PRIVATE MUSIC_CMD) + set(fork_found OFF) + if(NOT fork_found) + check_symbol_exists(fork sys/unistd.h HAVE_FORK) + if(HAVE_FORK) + set(fork_found ON) + target_compile_definitions(SDL2_mixer PRIVATE HAVE_FORK) + endif() + endif() + if(NOT fork_found) + check_symbol_exists(fork sys/unistd.h HAVE_VFORK) + if(HAVE_VFORK) + set(fork_found ON) + target_compile_definitions(SDL2_mixer PRIVATE HAVE_VFORK) + endif() + endif() + if(NOT fork_found) + message(FATAL_ERROR "Neither fork() or vfork() or available on this platform. Reconfigure with -DSDL2MIXER_CMD=OFF.") + endif() +endif() + +if(SDL2MIXER_OGG) + # libogg is a requirement of libflac, libtremor and libvorbisfile, so only need this library when vendoring + if(SDL2MIXER_VENDORED) + message(STATUS "Using vendored libogg") + set(BUILD_SHARED_LIBS ${SDL2MIXER_OGG_SHARED}) + set(INSTALL_CMAKE_PACKAGE_MODULE FALSE CACHE BOOL "Don't install cmake module for libogg") + sdl_check_project_in_subfolder(external/ogg ogg SDL2MIXER_VENDORED) + add_subdirectory(external/ogg EXCLUDE_FROM_ALL) + if(SDL2MIXER_OGG_install) + list(APPEND INSTALL_EXTRA_TARGETS ogg) + endif() + endif() +endif() + +if(SDL2MIXER_OPUS) + target_compile_definitions(SDL2_mixer PRIVATE MUSIC_OPUS) + if(SDL2MIXER_VENDORED) + # vendored libogg alread handled + if(NOT TARGET ogg) + message(FATAL_ERROR "ogg target not present") + endif() + message(STATUS "Using vendored opus") + set(BUILD_SHARED_LIBS ${SDL2MIXER_OPUS_SHARED}) + sdl_check_project_in_subfolder(external/opus opus SDL2MIXER_VENDORED) + add_subdirectory(external/opus EXCLUDE_FROM_ALL) + + set(OP_DISABLE_DOCS TRUE CACHE BOOL "Disable opusfile documentation") + set(OP_DISABLE_HTTP TRUE CACHE BOOL "Disable opusfile HTTP SUPPORT") + message(STATUS "Using vendored opusfile") + set(BUILD_SHARED_LIBS ${SDL2MIXER_OPUS_SHARED}) + sdl_check_project_in_subfolder(external/opusfile opusfile SDL2MIXER_VENDORED) + add_subdirectory(external/opusfile EXCLUDE_FROM_ALL) + if(MSVC) + set_property(TARGET opusfile PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + endif() + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/opusfile.h" "#include \"${CMAKE_CURRENT_SOURCE_DIR}/external/opusfile/include/opusfile.h\"\n") + execute_process( + COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/opus" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/opusfile.h" "${CMAKE_CURRENT_BINARY_DIR}/opus/opusfile.h" + ) + target_include_directories(SDL2_mixer PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") + + if(NOT TARGET opusfile::opusfile) + add_library(opusfile::opusfile ALIAS opusfile) + endif() + if(SDL2MIXER_OPUS_SHARED OR NOT SDL2MIXER_BUILD_SHARED_LIBS) + list(APPEND INSTALL_EXTRA_TARGETS opus opusfile) + endif() + if(NOT SDL2MIXER_OPUS_SHARED) + list(APPEND PC_LIBS -l$ -l$ -l$) + endif() + else() + message(STATUS "Using system opusfile") + find_package(opusfile REQUIRED) + if(NOT SDL2MIXER_OPUS_SHARED) + list(APPEND PC_REQUIRES opusfile) + endif() + endif() + if(SDL2MIXER_OPUS_SHARED) + target_include_directories(SDL2_mixer PRIVATE + $ + $ + $ + ) + target_get_dynamic_library(dynamic_opusfile opusfile::opusfile) + message(STATUS "Dynamic opus (opusfile): ${dynamic_opusfile}") + target_compile_definitions(SDL2_mixer PRIVATE "OPUS_DYNAMIC=\"${dynamic_opusfile}\"") + if(SDL2MIXER_VENDORED) + add_dependencies(SDL2_mixer opusfile::opusfile) + endif() + else() + target_link_libraries(SDL2_mixer PRIVATE opusfile::opusfile) + endif() +endif() + +if(SDL2MIXER_VORBIS_STB) + message(STATUS "Enabled ogg music: using stb_vorbis") + target_compile_definitions(SDL2_mixer PRIVATE MUSIC_OGG) + target_compile_definitions(SDL2_mixer PRIVATE OGG_USE_STB) +endif() + +if(SDL2MIXER_VORBIS_TREMOR) + target_compile_definitions(SDL2_mixer PRIVATE MUSIC_OGG OGG_USE_TREMOR) + if(SDL2MIXER_VENDORED) + # vendored libogg alread handled + if(NOT TARGET ogg) + message(FATAL_ERROR "ogg target not present") + endif() + message(STATUS "Using vendored tremor") + set(BUILD_SHARED_LIBS ${SDL2MIXER_VORBIS_TREMOR_SHARED}) + sdl_check_project_in_subfolder(external/tremor tremor SDL2MIXER_VENDORED) + add_subdirectory(external/tremor EXCLUDE_FROM_ALL) + if(NOT TARGET tremor::tremor) + add_library(tremor::tremor ALIAS vorbisidec) + endif() + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ivorbisfile.h" "#include \"${CMAKE_CURRENT_SOURCE_DIR}/external/tremor/ivorbisfile.h\"\n") + execute_process( + COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/tremor" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/ivorbisfile.h" "${CMAKE_CURRENT_BINARY_DIR}/tremor/ivorbisfile.h" + ) + target_include_directories(SDL2_mixer PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") + if(SDL2MIXER_VORBIS_TREMOR_SHARED OR NOT SDL2MIXER_BUILD_SHARED_LIBS) + list(APPEND INSTALL_EXTRA_TARGETS vorbisidec) + endif() + if(NOT SDL2MIXER_VORBIS_TREMOR_SHARED) + list(APPEND PC_LIBS -l$ -l$) + endif() + else() + message(STATUS "Using system tremor") + find_package(tremor REQUIRED) + if(NOT SDL2MIXER_VORBIS_TREMOR_SHARED) + list(APPEND PC_REQUIRES tremor) + endif() + endif() + if(SDL2MIXER_VORBIS_TREMOR_SHARED) + target_include_directories(SDL2_mixer PRIVATE + $ + $ + $ + ) + target_get_dynamic_library(dynamic_tremor tremor::tremor) + message(STATUS "Dynamic vorbis (tremor): ${dynamic_tremor}") + target_compile_definitions(SDL2_mixer PRIVATE "OGG_DYNAMIC=\"${dynamic_tremor}\"") + if(SDL2MIXER_VENDORED) + add_dependencies(SDL2_mixer tremor::tremor) + endif() + else() + target_link_libraries(SDL2_mixer PRIVATE tremor::tremor) + endif() +endif() + +if(SDL2MIXER_VORBIS_VORBISFILE) + target_compile_definitions(SDL2_mixer PRIVATE MUSIC_OGG) + if(SDL2MIXER_VENDORED) + # vendored libogg alread handled + if(NOT TARGET ogg) + message(FATAL_ERROR "ogg target not present") + endif() + message(STATUS "Using vendored vorbis + vorbisfile") + set(BUILD_SHARED_LIBS ${SDL2MIXER_VORBIS_VORBISFILE_SHARED}) + sdl_check_project_in_subfolder(external/vorbis vorbisfile SDL2MIXER_VENDORED) + add_subdirectory(external/vorbis EXCLUDE_FROM_ALL) + if(NOT TARGET vorbisfile::vorbisfile) + add_library(vorbisfile::vorbisfile ALIAS vorbisfile) + endif() + if(SDL2MIXER_VORBIS_VORBISFILE_SHARED OR NOT SDL2MIXER_BUILD_SHARED_LIBS) + list(APPEND INSTALL_EXTRA_TARGETS vorbis vorbisfile) + endif() + if(NOT SDL2MIXER_VORBIS_VORBISFILE_SHARED) + list(APPEND PC_LIBS -l$) + endif() + else() + message(STATUS "Using system vorbisfile") + find_package(vorbisfile REQUIRED) + if(NOT SDL2MIXER_VORBIS_VORBISFILE_SHARED) + list(APPEND PC_REQUIRES vorbisfile) + endif() + endif() + if(SDL2MIXER_VORBIS_VORBISFILE_SHARED) + target_include_directories(SDL2_mixer PRIVATE + $ + $ + $ + ) + target_get_dynamic_library(dynamic_vorbisfile vorbisfile::vorbisfile) + message(STATUS "Dynamic vorbisfile: ${dynamic_vorbisfile}") + target_compile_definitions(SDL2_mixer PRIVATE "OGG_DYNAMIC=\"${dynamic_vorbisfile}\"") + if(SDL2MIXER_VENDORED) + add_dependencies(SDL2_mixer vorbisfile::vorbisfile) + endif() + else() + target_link_libraries(SDL2_mixer PRIVATE vorbisfile::vorbisfile) + endif() +endif() + +if(SDL2MIXER_FLAC_LIBFLAC) + target_compile_definitions(SDL2_mixer PRIVATE MUSIC_FLAC_LIBFLAC) + if(SDL2MIXER_VENDORED) + # vendored libogg alread handled + if(NOT TARGET ogg) + message(FATAL_ERROR "ogg target not present") + endif() + set(BUILD_SHARED_LIBS "${SDL2MIXER_FLAC_LIBFLAC_SHARED}") + set(INSTALL_CMAKE_CONFIG_MODULE OFF CACHE BOOL "Disable libflac installation") + set(WITH_OGG OFF CACHE BOOL "Disable finding ogg using `find_package` (we have vendored it)") + message(STATUS "Using vendored libflac") + sdl_check_project_in_subfolder(external/flac libflac SDL2MIXER_VENDORED) + add_subdirectory(external/flac EXCLUDE_FROM_ALL) + if(SDL2MIXER_FLAC_LIBFLAC_SHARED) + list(APPEND INSTALL_EXTRA_TARGETS FLAC) + endif() + if(NOT SDL2MIXER_FLAC_LIBFLAC_SHARED) + list(APPEND PC_LIBS -l$ -l$) + endif() + else() + message(STATUS "Using system libflac") + find_package(FLAC REQUIRED) + if(NOT SDL2MIXER_FLAC_LIBFLAC_SHARED) + list(APPEND PC_REQUIRES flac) + endif() + endif() + if(SDL2MIXER_FLAC_LIBFLAC_SHARED) + target_include_directories(SDL2_mixer PRIVATE + $ + $ + $ + ) + target_get_dynamic_library(dynamic_flac FLAC::FLAC) + message(STATUS "Dynamic libflac: ${dynamic_flac}") + target_compile_definitions(SDL2_mixer PRIVATE "FLAC_DYNAMIC=\"${dynamic_flac}\"") + if(SDL2MIXER_VENDORED) + add_dependencies(SDL2_mixer FLAC) + endif() + else() + target_link_libraries(SDL2_mixer PRIVATE FLAC) + endif() +endif() + +if(SDL2MIXER_FLAC_DRFLAC) + target_compile_definitions(SDL2_mixer PRIVATE MUSIC_FLAC_DRFLAC) +endif() + +if(SDL2MIXER_MOD_MODPLUG) + target_compile_definitions(SDL2_mixer PRIVATE MUSIC_MOD_MODPLUG) + if(SDL2MIXER_VENDORED) + message(STATUS "Using vendored libmodplug") + sdl_check_project_in_subfolder(external/libmodplug libmodplug SDL2MIXER_VENDORED) + set(BUILD_SHARED_LIBS "${SDL2MIXER_MOD_MODPLUG_SHARED}") + enable_language(CXX) + add_subdirectory(external/libmodplug EXCLUDE_FROM_ALL) + target_include_directories(SDL2_mixer PRIVATE external/libmodplug/src) + if(NOT TARGET modplug::modplug) + add_library(modplug::modplug ALIAS modplug) + # is not escaped properly for windres when using MinGW + "Unix Makefiles" ==> limit it to C sources + target_compile_definitions(SDL2_mixer PRIVATE $<$:MODPLUG_HEADER=>) + endif() + if(SDL2MIXER_FLAC_LIBFLAC_SHARED OR NOT SDL2MIXER_BUILD_SHARED_LIBS) + list(APPEND INSTALL_EXTRA_TARGETS modplug) + endif() + if(NOT SDL2MIXER_MOD_MODPLUG_SHARED) + list(APPEND PC_LIBS -l$) + endif() + else() + message(STATUS "Using system libmodplug") + find_package(modplug REQUIRED) + if(NOT SDL2MIXER_MOD_MODPLUG_SHARED) + list(APPEND PC_REQUIRES libmodplug) + endif() + endif() + if(SDL2MIXER_MOD_MODPLUG_SHARED) + target_include_directories(SDL2_mixer PRIVATE + $ + $ + $ + ) + target_get_dynamic_library(dynamic_modplug modplug::modplug) + message(STATUS "Dynamic modplug: ${dynamic_modplug}") + target_compile_definitions(SDL2_mixer PRIVATE "MODPLUG_DYNAMIC=\"${dynamic_modplug}\"") + if(SDL2MIXER_VENDORED) + add_dependencies(SDL2_mixer modplug::modplug) + endif() + else() + target_link_libraries(SDL2_mixer PRIVATE modplug::modplug) + endif() +endif() + +if(SDL2MIXER_MOD_XMP) + target_compile_definitions(SDL2_mixer PRIVATE MUSIC_MOD_XMP) + if(SDL2MIXER_VENDORED) + message(STATUS "Using vendored libxmp/libxmp-lite") + message(WARNING "Neither libxmp or libxmp-lite are vendored. Using system libxmp instead.") + endif() + if(SDL2MIXER_MOD_XMP_LITE) + message(STATUS "Using system libxmp-lite") + find_package(libxmp-lite REQUIRED) + set(tgt_xmp libxmp-lite::libxmp-lite) + set(xmp_name libxmp-lite) + if(NOT SDL2MIXER_MOD_XMP_SHARED) + list(APPEND PC_REQUIRES libxmplite) + endif() + else() + message(STATUS "Using system libxmp") + find_package(libxmp REQUIRED) + set(tgt_xmp libxmp::libxmp) + set(xmp_name libxmp) + if(NOT SDL2MIXER_MOD_XMP_SHARED) + list(APPEND PC_REQUIRES libxmp) + endif() + endif() + if(SDL2MIXER_MOD_XMP_SHARED) + target_include_directories(SDL2_mixer PRIVATE + $ + $ + $ + ) + target_get_dynamic_library(dynamic_xmp ${tgt_xmp}) + message(STATUS "Dynamic ${xmp_name}: ${dynamic_xmp}") + target_compile_definitions(SDL2_mixer PRIVATE "XMP_DYNAMIC=\"${dynamic_xmp}\"") + if(SDL2MIXER_VENDORED) + add_dependencies(SDL2_mixer ${tgt_xmp}) + endif() + else() + target_link_libraries(SDL2_mixer PRIVATE ${tgt_xmp}) + endif() +endif() + +if(SDL2MIXER_MP3_DRMP3) + target_compile_definitions(SDL2_mixer PRIVATE MUSIC_MP3_DRMP3) +endif() + +if(SDL2MIXER_MP3_MPG123) + target_compile_definitions(SDL2_mixer PRIVATE MUSIC_MP3_MPG123) + if(SDL2MIXER_VENDORED) + message(STATUS "Using vendored mpg123") + sdl_check_project_in_subfolder(external/mpg123/ports/cmake mpg123 SDL2MIXER_VENDORED) + set(BUILD_LIBOUT123 FALSE CACHE BOOL "Don't configure libout123") + set(BUILD_SHARED_LIBS "${SDL2MIXER_MP3_MPG123_SHARED}") + add_subdirectory(external/mpg123/ports/cmake EXCLUDE_FROM_ALL) + if(NOT TARGET MPG123::mpg123) + add_library(MPG123::mpg123 ALIAS libmpg123) + endif() + if(SDL2MIXER_MP3_MPG123_SHARED OR NOT SDL2MIXER_BUILD_SHARED_LIBS) + list(APPEND INSTALL_EXTRA_TARGETS libmpg123) + endif() + if(NOT SDL2MIXER_MP3_MPG123_SHARED) + list(APPEND PC_LIBS -l$) + endif() + else() + message(STATUS "Using system mpg123") + find_package(MPG123 REQUIRED) + if(NOT SDL2MIXER_MP3_MPG123_SHARED) + list(APPEND PC_REQUIRES libmpg123) + endif() + endif() + if(SDL2MIXER_MP3_MPG123_SHARED) + target_include_directories(SDL2_mixer PRIVATE + $ + $ + $ + ) + target_get_dynamic_library(dynamic_mpg123 MPG123::mpg123) + message(STATUS "Dynamic mpg123}: ${dynamic_mpg123}") + target_compile_definitions(SDL2_mixer PRIVATE "MPG123_DYNAMIC=\"${dynamic_mpg123}\"") + if(SDL2MIXER_VENDORED) + add_dependencies(SDL2_mixer MPG123::mpg123) + endif() + else() + target_link_libraries(SDL2_mixer PRIVATE MPG123::mpg123) + endif() +endif() + +if(SDL2MIXER_MIDI_FLUIDSYNTH) + target_compile_definitions(SDL2_mixer PRIVATE MUSIC_MID_FLUIDSYNTH) + if(SDL2MIXER_VENDORED) + message(STATUS "Using vendored FluidSynth") + message(FATAL_ERROR "FluidSynth is not vendored.") + else() + message(STATUS "Using system FluidSynth") + find_package(FluidSynth REQUIRED) + if(NOT SDL2MIXER_MIDI_FLUIDSYNTH_SHARED) + list(APPEND PC_REQUIRES fluidsynth) + endif() + endif() + if(SDL2MIXER_MIDI_FLUIDSYNTH_SHARED) + target_include_directories(SDL2_mixer PRIVATE + $ + $ + $ + ) + target_get_dynamic_library(dynamic_fluidsynth FluidSynth::FluidSynth) + message(STATUS "Dynamic fluidsynth: ${dynamic_fluidsynth}") + target_compile_definitions(SDL2_mixer PRIVATE "FLUIDSYNTH_DYNAMIC=\"${dynamic_fluidsynth}\"") + if(SDL2MIXER_VENDORED) + add_dependencies(SDL2_mixer FluidSynth::FluidSynth) + endif() + else() + target_link_libraries(SDL2_mixer PRIVATE FluidSynth::FluidSynth) + endif() +endif() + +if(SDL2MIXER_MIDI_NATIVE) + target_compile_definitions(SDL2_mixer PRIVATE MUSIC_MID_NATIVE) + target_sources(SDL2_mixer PRIVATE + src/codecs/native_midi/native_midi_common.c + src/codecs/native_midi/native_midi_common.h + ) + if(WIN32) + target_sources(SDL2_mixer PRIVATE src/codecs/native_midi/native_midi_win32.c) + target_link_libraries(SDL2_mixer PRIVATE winmm) + elseif(APPLE) + target_sources(SDL2_mixer PRIVATE src/codecs/native_midi/native_midi_macosx.c) + target_link_options(SDL2_mixer PRIVATE -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,CoreServices) + elseif(HAIKU) + enable_language(CXX) + target_sources(SDL2_mixer PRIVATE src/codecs/native_midi/native_midi_haiku.cpp) + target_link_libraries(SDL2_mixer PRIVATE midi) + endif() +endif() + +if(SDL2MIXER_MIDI_TIMIDITY) + target_compile_definitions(SDL2_mixer PRIVATE MUSIC_MID_TIMIDITY) + target_sources(SDL2_mixer PRIVATE + src/codecs/timidity/common.c + src/codecs/timidity/instrum.c + src/codecs/timidity/mix.c + src/codecs/timidity/output.c + src/codecs/timidity/playmidi.c + src/codecs/timidity/readmidi.c + src/codecs/timidity/resample.c + src/codecs/timidity/tables.c + src/codecs/timidity/timidity.c + ) +endif() + +if(SDL2MIXER_WAVE) + target_compile_definitions(SDL2_mixer PRIVATE MUSIC_WAV) +endif() + +if(SDL2MIXER_INSTALL) + install( + TARGETS SDL2_mixer + EXPORT SDL2MixerTargets + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT devel + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT library + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT library + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/SDL2" COMPONENT devel + ) + + if(INSTALL_EXTRA_TARGETS) + install(TARGETS ${INSTALL_EXTRA_TARGETS} + EXPORT SDL2MixerTargets + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT devel + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT library + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT library + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" COMPONENT devel + ) + endif() + + ##### export files ##### + if(WIN32 AND NOT MINGW) + set(PKG_PREFIX "cmake") + else() + set(PKG_PREFIX "${CMAKE_INSTALL_LIBDIR}/cmake/SDL2_mixer") + endif() + + configure_package_config_file(SDL2_mixerConfig.cmake.in SDL2_mixerConfig.cmake + INSTALL_DESTINATION "${PKG_PREFIX}" + ) + write_basic_package_version_file("${PROJECT_BINARY_DIR}/SDL2_mixerConfigVersion.cmake" + VERSION ${FULL_VERSION} + COMPATIBILITY AnyNewerVersion + ) + install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/SDL2_mixerConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/SDL2_mixerConfigVersion.cmake" + DESTINATION "${PKG_PREFIX}" + COMPONENT devel + ) + if(NOT SDL2MIXER_BUILD_SHARED_LIBS) + install( + FILES + cmake/FindFLAC.cmake + cmake/FindFluidSynth.cmake + cmake/Findlibxmp.cmake + cmake/Findlibxmp-lite.cmake + cmake/Findmodplug.cmake + cmake/Findopusfile.cmake + cmake/FindMPG123.cmake + cmake/Findvorbisfile.cmake + cmake/Findtremor.cmake + DESTINATION "${PKG_PREFIX}" + COMPONENT devel + ) + endif() + install(EXPORT SDL2MixerTargets + FILE SDL2_mixer-${sdl2_mixer_install_name_infix}-targets.cmake + NAMESPACE SDL2_mixer:: + DESTINATION "${PKG_PREFIX}" + COMPONENT devel + ) + + if(SDL2MIXER_BUILD_SHARED_LIBS) + # Only create a .pc file for a shared SDL2_mixer + set(VERSION ${FULL_VERSION}) + set(SDL_VERSION ${SDL_REQUIRED_VERSION}) + set(prefix "${CMAKE_INSTALL_PREFIX}") + set(exec_prefix "\${prefix}") + set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") + set(bindir "\${exec_prefix}/bin") + set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") + string(JOIN " " PC_REQUIRES ${PC_REQUIRES}) + string(JOIN " " PC_LIBS ${PC_LIBS}) + configure_file(SDL2_mixer.pc.in ${CMAKE_CURRENT_BINARY_DIR}/SDL2_mixer.pc.intermediate @ONLY) + file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/SDL2_mixer-$.pc" INPUT "${CMAKE_CURRENT_BINARY_DIR}/SDL2_mixer.pc.intermediate") + + set(PC_DESTDIR) + if(CMAKE_SYSTEM_NAME MATCHES FreeBSD) + # FreeBSD uses ${PREFIX}/libdata/pkgconfig + set(PC_DESTDIR "libdata/pkgconfig") + else() + set(PC_DESTDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + endif() + # Only install a SDL2_mixer.pc file in Release mode + install(CODE " + # FIXME: use file(COPY_FILE) if minimum CMake version >= 3.21 + execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy_if_different + \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_mixer-$.pc\" + \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_mixer.pc\") + file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${PC_DESTDIR}\" + TYPE FILE + FILES \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_mixer.pc\")" CONFIG Release COMPONENT devel) + endif() + + if(SDL2MIXER_BUILD_SHARED_LIBS AND (APPLE OR (UNIX AND NOT ANDROID))) + install( + FILES + "${PROJECT_BINARY_DIR}/libSDL2_mixer$<$:${SDL2MIXER_DEBUG_POSTFIX}>$" + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT devel + ) + endif() + + install(FILES "LICENSE.txt" + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/licenses/${PROJECT_NAME}" + COMPONENT library + ) +endif() + +if(SDL2MIXER_SAMPLES) + add_executable(playmus playmus.c) + add_executable(playwave playwave.c) + + find_package(SDL2main) + + foreach(prog playmus playwave) + # FIXME: mingw should be handled by SDL2::SDL2(-static) target + if(MINGW) + target_link_libraries(${prog} PRIVATE mingw32) + target_link_options(${prog} PRIVATE -mwindows) + endif() + target_link_libraries(${prog} PRIVATE SDL2_mixer::${sdl2_mixer_export_name}) + if(TARGET SDL2::SDL2main) + target_link_libraries(${prog} PRIVATE SDL2::SDL2main) + endif() + target_link_libraries(${prog} PRIVATE ${sdl2_target_name}) + + if(SDL2MIXER_SAMPLES_INSTALL) + install(TARGETS ${prog} + RUNTIME DESTINATION "{CMAKE_INSTALL_BINDIR}" + ) + endif() + endforeach() +endif() + +add_library(SDL2::mixer INTERFACE IMPORTED GLOBAL) +set_target_properties(SDL2::mixer PROPERTIES + INTERFACE_LINK_LIBRARIES "SDL2_mixer" +) +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.17") + set_target_properties(SDL2::mixer PROPERTIES + DEPRECATION "Use SDL2_mixer::SDL2_mixer or SDL2_mixer::SDL2_mixer-static instead" + ) endif() diff --git a/Makefile.in b/Makefile.in index ac07ef37..deffdd53 100644 --- a/Makefile.in +++ b/Makefile.in @@ -106,6 +106,9 @@ install-hdrs: done $(SHELL) $(auxdir)/mkinstalldirs $(libdir)/pkgconfig $(INSTALL) -m 644 SDL2_mixer.pc $(libdir)/pkgconfig/ + $(SHELL) $(auxdir)/mkinstalldirs $(libdir)/cmake/SDL2_mixer/ + $(INSTALL) -m 644 sdl2_mixer-config.cmake $(libdir)/cmake/SDL2_mixer + $(INSTALL) -m 644 sdl2_mixer-config-version.cmake $(libdir)/cmake/SDL2_mixer install-lib: $(objects)/$(TARGET) $(SHELL) $(auxdir)/mkinstalldirs $(libdir) $(LIBTOOL) --mode=install $(INSTALL) $(objects)/$(TARGET) $(libdir)/$(TARGET) @@ -123,6 +126,10 @@ uninstall-hdrs: -rmdir $(includedir)/SDL2 rm -f $(libdir)/pkgconfig/SDL2_mixer.pc -rmdir $(libdir)/pkgconfig + rm -f $(libdir)/cmake/SDL2_mixer/sdl2_mixer-config.cmake + rm -f $(libdir)/cmake/SDL2_mixer/sdl2_mixer-config-version.cmake + -rmdir $(libdir)/cmake/SDL2_mixer + -rmdir $(libdir)/cmake uninstall-lib: $(LIBTOOL) --mode=uninstall rm -f $(libdir)/$(TARGET) uninstall-bin: diff --git a/SDL2_mixerConfig.cmake.in b/SDL2_mixerConfig.cmake.in new file mode 100644 index 00000000..d65a43ce --- /dev/null +++ b/SDL2_mixerConfig.cmake.in @@ -0,0 +1,101 @@ +# sdl2_mixer cmake project-config input for CMakeLists.txt script + +include(FeatureSummary) +set_package_properties(SDL2_mixer PROPERTIES + URL "https://www.libsdl.org/projects/SDL_mixer/" + DESCRIPTION "SDL_mixer is a sample multi-channel audio mixer library" +) + +set(SDL2_mixer_FOUND ON) + +set(SDL2MIXER_VENDORED @SDL2MIXER_VENDORED@) + +set(SDL2MIXER_CMD @SDL2MIXER_CMD@) + +set(SDL2MIXER_FLAC_LIBFLAC @SDL2MIXER_FLAC_LIBFLAC@) +set(SDL2MIXER_FLAC_DRFLAC @SDL2MIXER_FLAC_DRFLAC@) + +set(SDL2MIXER_MOD @SDL2MIXER_MOD@) +set(SDL2MIXER_MOD_MODPLUG @SDL2MIXER_MOD_MODPLUG@) +set(SDL2MIXER_MOD_XMP @SDL2MIXER_MOD_XMP@) +set(SDL2MIXER_MOD_XMP_LITE @SDL2MIXER_MOD_XMP_LITE@) + +set(SDL2MIXER_MP3 @SDL2MIXER_MP3@) +set(SDL2MIXER_MP3_DRMP3 @SDL2MIXER_MP3_DRMP3@) +set(SDL2MIXER_MP3_MPG123 @SDL2MIXER_MP3_MPG123@) + +set(SDL2MIXER_MIDI @SDL2MIXER_MIDI@) +set(SDL2MIXER_MIDI_FLUIDSYNTH @SDL2MIXER_MIDI_FLUIDSYNTH@) +set(SDL2MIXER_MIDI_NATIVE @SDL2MIXER_MIDI_NATIVE@) +set(SDL2MIXER_MIDI_TIMIDITY @SDL2MIXER_MIDI_TIMIDITY@) + +set(SDL2MIXER_OPUS @SDL2MIXER_OPUS@) + +set(SDL2MIXER_VORBIS @SDL2MIXER_VORBIS@) +set(SDL2MIXER_VORBIS_STB @SDL2MIXER_VORBIS_STB@) +set(SDL2MIXER_VORBIS_TREMOR @SDL2MIXER_VORBIS_TREMOR@) +set(SDL2MIXER_VORBIS_VORBISFILE @SDL2MIXER_VORBIS_VORBISFILE@) + +set(SDL2MIXER_WAVE @SDL2MIXER_WAVE@) + +set(SDL2MIXER_SDL2_REQUIRED_VERSION @SDL_REQUIRED_VERSION@) + +if(NOT SDL2MIXER_VENDORED) + set(_sdl_cmake_module_path "${CMAKE_MODULE_PATH}") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") +endif() + +if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL2_mixer-shared-targets.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/SDL2_mixer-shared-targets.cmake") +endif() + +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) + endif() + + if(SDL2MIXER_MOD_MODPLUG AND NOT SDL2MIXER_VENDORED AND NOT TARGET modplug::modplug) + find_dependency(modplug) + endif() + + if(SDL2MIXER_MOD_XMP AND NOT SDL2MIXER_VENDORED AND NOT TARGET libxmp::libxmp) + find_dependency(libxmp) + endif() + + if(SDL2MIXER_MOD_XMP_LITE AND NOT SDL2MIXER_VENDORED AND NOT TARGET libxmp-lite::libxmp-lite) + find_dependency(libxmp-lite) + endif() + + if(SDL2MIXER_MP3_MPG123 AND NOT SDL2MIXER_VENDORED AND NOT TARGET MPG123::mpg123) + find_dependency(MPG123) + endif() + + if(SDL2MIXER_MIDI_FLUIDSYNTH AND NOT SDL2MIXER_VENDORED AND NOT TARGET FluidSynth::FluidSynth) + find_dependency(FluidSynth) + 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) + endif() + + if((NOT SDL2MIXER_VENDORED AND SDL2MIXER_MOD_MODPLUG) OR (HAIKU AND SDL2MIXER_MIDI_NATIVE)) + include(CheckLanguage) + check_language(CXX) + if(NOT CMAKE_CXX_COMPILER) + message(WARNING "CXX language not enabled. Linking to SDL2_mixer::SDL2_mixer-static might fail.") + endif() + endif() + include("${CMAKE_CURRENT_LIST_DIR}/SDL2_mixer-static-targets.cmake") +endif() + +if(NOT SDL2MIXER_VENDORED) + set(CMAKE_MODULE_PATH "${_sdl_cmake_module_path}") + unset(_sdl_cmake_module_path) +endif() diff --git a/VisualC/pkg-support/cmake/sdl2_mixer-config-version.cmake b/VisualC/pkg-support/cmake/sdl2_mixer-config-version.cmake new file mode 100644 index 00000000..308dca2f --- /dev/null +++ b/VisualC/pkg-support/cmake/sdl2_mixer-config-version.cmake @@ -0,0 +1,54 @@ +# based on the files generated by CMake's write_basic_package_version_file + +# SDL2_mixer CMake version configuration file: +# This file is meant to be placed in a cmake subfolder of SDL2_mixer-devel-2.x.y-VC + +if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../include/SDL_mixer.h") + message(AUTHOR_WARNING "Could not find SDL_mixer.h. This script is meant to be placed in a CMake subfolder of SDL2_mixer-devel-2.x.y-VC") + return() +endif() + +file(READ "${CMAKE_CURRENT_LIST_DIR}/../SDL_mixer.h" _sdl_mixer_h) +string(REGEX MATCH "#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_major_re "${_sdl_mixer_h}") +set(_sdl_major "${CMAKE_MATCH_1}") +string(REGEX MATCH "#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_mixer_h}") +set(_sdl_minor "${CMAKE_MATCH_1}") +string(REGEX MATCH "#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+([0-9]+)" _sdl_patch_re "${_sdl_mixer_h}") +set(_sdl_patch "${CMAKE_MATCH_1}") +if(_sdl_major_re AND _sdl_minor_re AND _sdl_patch_re) + set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_patch}") +else() + message(AUTHOR_WARNING "Could not extract version from SDL_mixer.h.") + return() +endif() + +if(PACKAGE_FIND_VERSION_RANGE) + # Package version must be in the requested version range + if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN) + OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX) + OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX))) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + endif() +else() + if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() + endif() +endif() + +# if the using project doesn't have CMAKE_SIZEOF_VOID_P set, fail. +if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "") + set(PACKAGE_VERSION_UNSUITABLE TRUE) +endif() + +# check that the installed version has the same 32/64bit-ness as the one which is currently searching: +if(NOT (CMAKE_SIZEOF_VOID_P STREQUAL "8" OR CMAKE_SIZEOF_VOID_P STREQUAL "4")) + set(PACKAGE_VERSION "${PACKAGE_VERSION} (32+64bit)") + set(PACKAGE_VERSION_UNSUITABLE TRUE) +endif() diff --git a/VisualC/pkg-support/cmake/sdl2_mixer-config.cmake b/VisualC/pkg-support/cmake/sdl2_mixer-config.cmake new file mode 100644 index 00000000..ada1623f --- /dev/null +++ b/VisualC/pkg-support/cmake/sdl2_mixer-config.cmake @@ -0,0 +1,76 @@ +# SDL2_mixer CMake configuration file: +# This file is meant to be placed in a cmake subfolder of SDL2_mixer-devel-2.x.y-VC + +include(FeatureSummary) +set_package_properties(SDL2_mixer PROPERTIES + URL "https://www.libsdl.org/projects/SDL_mixer/" + DESCRIPTION "SDL_mixer is a sample multi-channel audio mixer library" +) + +cmake_minimum_required(VERSION 3.0) + +set(SDL2_mixer_FOUND TRUE) + +set(SDL2MIXER_VENDORED TRUE) + +set(SDL2MIXER_CMD FALSE) + +set(SDL2MIXER_FLAC_LIBFLAC FALSE) +set(SDL2MIXER_FLAC_DRFLAC TRUE) + +set(SDL2MIXER_MOD TRUE) +set(SDL2MIXER_MOD_MODPLUG TRUE) +set(SDL2MIXER_MOD_XMP FALSE) +set(SDL2MIXER_MOD_XMP_LITE FALSE) + +set(SDL2MIXER_MP3 TRUE) +set(SDL2MIXER_MP3_DRMP3 TRUE) +set(SDL2MIXER_MP3_MPG123 FALSE) + +set(SDL2MIXER_MIDI TRUE) +set(SDL2MIXER_MIDI_FLUIDSYNTH FALSE) +set(SDL2MIXER_MIDI_NATIVE TRUE) +set(SDL2MIXER_MIDI_TIMIDITY TRUE) + +set(SDL2MIXER_OPUS TRUE) + +set(SDL2MIXER_VORBIS STB) +set(SDL2MIXER_VORBIS_STB TRUE) +set(SDL2MIXER_VORBIS_TREMOR FALSE) +set(SDL2MIXER_VORBIS_VORBISFILE FALSE) + +set(SDL2MIXER_WAVE TRUE) + +if(CMAKE_SIZEOF_VOID_P STREQUAL "4") + set(_sdl_arch_subdir "x86") +elseif(CMAKE_SIZEOF_VOID_P STREQUAL "8") + set(_sdl_arch_subdir "x64") +else() + unset(_sdl_arch_subdir) + set(SDL2_mixer_FOUND FALSE) + return() +endif() + +set(_sdl2mixer_incdir "${CMAKE_CURRENT_LIST_DIR}/../include/SDL2") +set(_sdl2mixer_library "${CMAKE_CURRENT_LIST_DIR}/../lib/${_sdl_arch_subdir}/SDL2_mixer.lib") +set(_sdl2mixer_dll "${CMAKE_CURRENT_LIST_DIR}/../lib/${_sdl_arch_subdir}/SDL2_mixer.dll") + +# All targets are created, even when some might not be requested though COMPONENTS. +# This is done for compatibility with CMake generated SDL2_mixer-target.cmake files. + +if(NOT TARGET SDL2_mixer::SDL2_mixer) + add_library(SDL2_mixer::SDL2_mixer SHARED IMPORTED) + set_target_properties(SDL2_mixer::SDL2_mixer + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_sdl2mixer_incdir}" + IMPORTED_IMPLIB "${_sdl2mixer_library}" + IMPORTED_LOCATION "${_sdl2mixer_dll}" + COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED" + INTERFACE_SDL2_SHARED "ON" + ) +endif() + +unset(_sdl_arch_subdir) +unset(_sdl2mixer_incdir) +unset(_sdl2mixer_library) +unset(_sdl2mixer_dll) diff --git a/Xcode/pkg-support/resources/CMake/sdl2_mixer-config-version.cmake b/Xcode/pkg-support/resources/CMake/sdl2_mixer-config-version.cmake new file mode 100644 index 00000000..412d4fee --- /dev/null +++ b/Xcode/pkg-support/resources/CMake/sdl2_mixer-config-version.cmake @@ -0,0 +1,48 @@ +# based on the files generated by CMake's write_basic_package_version_file + +# SDL2_mixer CMake version configuration file: +# This file is meant to be placed in Resources/CMake of a SDL2_mixer framework + +if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../Headers/SDL_mixer.h") + message(AUTHOR_WARNING "Could not find SDL_mixer.h. This script is meant to be placed in the Resources/CMake directory of SDL2_mixer.framework") + return() +endif() + +file(READ "${CMAKE_CURRENT_LIST_DIR}/../../Headers/SDL_mixer.h" _sdl_mixer_h) +string(REGEX MATCH "#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_major_re "${_sdl_mixer_h}") +set(_sdl_major "${CMAKE_MATCH_1}") +string(REGEX MATCH "#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_mixer_h}") +set(_sdl_minor "${CMAKE_MATCH_1}") +string(REGEX MATCH "#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+([0-9]+)" _sdl_patch_re "${_sdl_mixer_h}") +set(_sdl_patch "${CMAKE_MATCH_1}") +if(_sdl_major_re AND _sdl_minor_re AND _sdl_patch_re) + set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_patch}") +else() + message(AUTHOR_WARNING "Could not extract version from SDL_mixer.h.") + return() +endif() + +if(PACKAGE_FIND_VERSION_RANGE) + # Package version must be in the requested version range + if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN) + OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX) + OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX))) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + endif() +else() + if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() + endif() +endif() + +# if the using project doesn't have CMAKE_SIZEOF_VOID_P set, fail. +if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "") + set(PACKAGE_VERSION_UNSUITABLE TRUE) +endif() diff --git a/Xcode/pkg-support/resources/CMake/sdl2_mixer-config.cmake b/Xcode/pkg-support/resources/CMake/sdl2_mixer-config.cmake new file mode 100644 index 00000000..ffd39518 --- /dev/null +++ b/Xcode/pkg-support/resources/CMake/sdl2_mixer-config.cmake @@ -0,0 +1,64 @@ +# SDL2_mixer CMake configuration file: +# This file is meant to be placed in Resources/CMake of a SDL2_mixer framework + +# INTERFACE_LINK_OPTIONS needs CMake 3.12 +cmake_minimum_required(VERSION 3.12) + +include(FeatureSummary) +set_package_properties(SDL2_mixer PROPERTIES + URL "https://www.libsdl.org/projects/SDL_mixer/" + DESCRIPTION "SDL_mixer is a sample multi-channel audio mixer library" +) + +set(SDL2_mixer_FOUND TRUE) + +set(SDL2MIXER_VENDORED TRUE) + +set(SDL2MIXER_CMD FALSE) + +set(SDL2MIXER_FLAC_LIBFLAC FALSE) +set(SDL2MIXER_FLAC_DRFLAC TRUE) + +set(SDL2MIXER_MOD FALSE) +set(SDL2MIXER_MOD_MODPLUG FALSE) +set(SDL2MIXER_MOD_XMP FALSE) +set(SDL2MIXER_MOD_XMP_LITE FALSE) + +set(SDL2MIXER_MP3 TRUE) +set(SDL2MIXER_MP3_DRMP3 TRUE) +set(SDL2MIXER_MP3_MPG123 FALSE) + +set(SDL2MIXER_MIDI FALSE) +set(SDL2MIXER_MIDI_FLUIDSYNTH FALSE) +set(SDL2MIXER_MIDI_NATIVE FALSE) +set(SDL2MIXER_MIDI_TIMIDITY FALSE) + +set(SDL2MIXER_OPUS FALSE) + +set(SDL2MIXER_VORBIS STB) +set(SDL2MIXER_VORBIS_STB TRUE) +set(SDL2MIXER_VORBIS_TREMOR FALSE) +set(SDL2MIXER_VORBIS_VORBISFILE FALSE) + +set(SDL2MIXER_WAVE TRUE) + +string(REGEX REPLACE "SDL2_mixer\\.framework.*" "SDL2_mixer.framework" _sdl2mixer_framework_path "${CMAKE_CURRENT_LIST_DIR}") +string(REGEX REPLACE "SDL2_mixer\\.framework.*" "" _sdl2mixer_framework_parent_path "${CMAKE_CURRENT_LIST_DIR}") + +# All targets are created, even when some might not be requested though COMPONENTS. +# This is done for compatibility with CMake generated SDL2_mixer-target.cmake files. + +if(NOT TARGET SDL2_mixer::SDL2_mixer) + add_library(SDL2_mixer::SDL2_mixer INTERFACE IMPORTED) + set_target_properties(SDL2_mixer::SDL2_mixer + PROPERTIES + INTERFACE_COMPILE_OPTIONS "SHELL:-F \"${_sdl2mixer_framework_parent_path}\"" + INTERFACE_INCLUDE_DIRECTORIES "${_sdl2mixer_framework_path}/Headers" + INTERFACE_LINK_OPTIONS "SHELL:-F \"${_sdl2mixer_framework_parent_path}\";SHELL:-framework SDL2_mixer" + COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED" + INTERFACE_SDL2_SHARED "ON" + ) +endif() + +unset(_sdl2mixer_framework_path) +unset(_sdl2mixer_framework_parent_path) diff --git a/Xcode/pkg-support/resources/ReadMe.txt b/Xcode/pkg-support/resources/ReadMe.txt index c7b37d75..a31fd29a 100644 --- a/Xcode/pkg-support/resources/ReadMe.txt +++ b/Xcode/pkg-support/resources/ReadMe.txt @@ -15,6 +15,18 @@ Copy the SDL2_mixer.framework to /Library/Frameworks You may alternatively install it in /Library/Frameworks if your access privileges are not high enough. (Be aware that the Xcode templates we provide in the SDL Developer Extras package may require some adjustment for your system if you do this.) +Use in CMake projects: +SDL2_mixer.framework can be used in CMake projects using the following pattern: +``` +find_package(SDL2_mixer REQUIRED) +add_executable(my_game ${MY_SOURCES}) +target_link_libraries(my_game PRIVATE SDL2_mixer::SDL2_mixer) +``` +If SDL2_mixer.framework is installed in a non-standard location, +please refer to the following link for ways to configure CMake: +https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure + + (Partial) History of PB/Xcode projects: 2009-09-21 - Updated for 64-bit (Snow Leopard) Universal Binaries. Switched to 10.4 minimum requirement. diff --git a/cmake/CommonFindSDL2.cmake b/cmake/CommonFindSDL2.cmake new file mode 100644 index 00000000..0a41bc6c --- /dev/null +++ b/cmake/CommonFindSDL2.cmake @@ -0,0 +1,22 @@ +# Common variables for FindSDL2*.cmake modules + +set(_inc_suffixes include) +set(_lib_suffixes) +if(MSVC) + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + list(APPEND _lib_suffixes "lib/x86") + endif() + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + list(APPEND _lib_suffixes "lib/x64") + endif() +endif() +if(MINGW) + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + list(APPEND _lib_suffixes "i686-w64-mingw32/lib") + list(APPEND _inc_suffixes "i686-w64-mingw32/include") + endif() + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + list(APPEND _lib_suffixes "x86_46-w64-mingw32/lib") + list(APPEND _inc_suffixes "x86_46-w64-mingw32/include") + endif() +endif() \ No newline at end of file diff --git a/cmake/FindFLAC.cmake b/cmake/FindFLAC.cmake new file mode 100644 index 00000000..b5ad76eb --- /dev/null +++ b/cmake/FindFLAC.cmake @@ -0,0 +1,32 @@ +include(FindPackageHandleStandardArgs) + +find_library(FLAC_LIBRARY + NAMES FLAC +) + +find_path(FLAC_INCLUDE_PATH + NAMES FLAC/all.h +) + +set(FLAC_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of FLAC") + +set(FLAC_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of FLAC") + +set(FLAC_LINK_FLAGS "" CACHE STRING "Extra link flags of FLAC") + +find_package_handle_standard_args(FLAC + REQUIRED_VARS FLAC_LIBRARY FLAC_INCLUDE_PATH +) + +if(FLAC_FOUND) + if(NOT TARGET FLAC::FLAC) + add_library(FLAC::FLAC UNKNOWN IMPORTED) + set_target_properties(FLAC::FLAC PROPERTIES + IMPORTED_LOCATION "${FLAC_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${FLAC_INCLUDE_PATH}" + INTERFACE_COMPILE_OPTIONS "${FLAC_COMPILE_OPTIONS}" + INTERFACE_LINK_LIBRARIES "${FLAC_LINK_LIBRARIES}" + INTERFACE_LINK_FLAGS "${FLAC_LINK_FLAGS}" + ) + endif() +endif() diff --git a/cmake/FindFluidSynth.cmake b/cmake/FindFluidSynth.cmake new file mode 100644 index 00000000..435840b6 --- /dev/null +++ b/cmake/FindFluidSynth.cmake @@ -0,0 +1,32 @@ +include(FindPackageHandleStandardArgs) + +find_library(FluidSynth_LIBRARY + NAMES fluidsynth +) + +find_path(FluidSynth_INCLUDE_PATH + NAMES fluidsynth.h +) + +set(FluidSynth_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of FluidSynth") + +set(FluidSynth_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of FluidSynth") + +set(FluidSynth_LINK_FLAGS "" CACHE STRING "Extra link flags of FluidSynth") + +find_package_handle_standard_args(FluidSynth + REQUIRED_VARS FluidSynth_LIBRARY FluidSynth_INCLUDE_PATH +) + +if(FluidSynth_FOUND) + if(NOT TARGET FluidSynth::FluidSynth) + add_library(FluidSynth::FluidSynth UNKNOWN IMPORTED) + set_target_properties(FluidSynth::FluidSynth PROPERTIES + IMPORTED_LOCATION "${FluidSynth_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${FluidSynth_INCLUDE_PATH}" + INTERFACE_COMPILE_OPTIONS "${FluidSynth_COMPILE_OPTIONS}" + INTERFACE_LINK_LIBRARIES "${FluidSynth_LINK_LIBRARIES}" + INTERFACE_LINK_FLAGS "${FluidSynth_LINK_FLAGS}" + ) + endif() +endif() diff --git a/cmake/FindMPG123.cmake b/cmake/FindMPG123.cmake new file mode 100644 index 00000000..f850d4f3 --- /dev/null +++ b/cmake/FindMPG123.cmake @@ -0,0 +1,32 @@ +include(FindPackageHandleStandardArgs) + +find_library(MPG123_LIBRARY + NAMES mpg123 +) + +find_path(MPG123_INCLUDE_PATH + NAMES mpg123.h +) + +set(MPG123_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of mpg123") + +set(MPG123_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of mpg123") + +set(MPG123_LINK_FLAGS "" CACHE STRING "Extra link flags of mpg123") + +find_package_handle_standard_args(MPG123 + REQUIRED_VARS MPG123_LIBRARY MPG123_INCLUDE_PATH +) + +if (MPG123_FOUND) + if (NOT TARGET MPG123::mpg123) + add_library(MPG123::mpg123 UNKNOWN IMPORTED) + set_target_properties(MPG123::mpg123 PROPERTIES + IMPORTED_LOCATION "${MPG123_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${MPG123_INCLUDE_PATH}" + INTERFACE_COMPILE_OPTIONS "${MPG123_COMPILE_OPTIONS}" + INTERFACE_LINK_LIBRARIES "${MPG123_LINK_LIBRARIES}" + INTERFACE_LINK_FLAGS "${MPG123_LINK_FLAGS}" + ) + endif() +endif() diff --git a/cmake/FindPrivateSDL2.cmake b/cmake/FindPrivateSDL2.cmake new file mode 100644 index 00000000..03141706 --- /dev/null +++ b/cmake/FindPrivateSDL2.cmake @@ -0,0 +1,47 @@ +# FIXME: this should be provided by SDL2 + +include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/CommonFindSDL2.cmake") + +find_library(SDL2_LIBRARY + NAMES SDL2 + HINTS ${SDL2_DIR} ENV SDL2_DIR + PATH_SUFFIXES ${_lib_suffixes} +) + +find_path(SDL2_INCLUDE_DIR + NAMES SDL_haptic.h + PATH_SUFFIXES SDL2 + HINTS ${SDL2_DIR} ENV SDL2_DIR + PATH_SUFFIXES ${_inc_suffixes} +) + +set(SDL2_VERSION) +if(SDL2_INCLUDE_DIR) + file(READ "${SDL2_INCLUDE_DIR}/SDL_version.h" _sdl_version_h) + string(REGEX MATCH "#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)" _sdl2_major_re "${_sdl_version_h}") + set(_sdl2_major "${CMAKE_MATCH_1}") + string(REGEX MATCH "#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)" _sdl2_minor_re "${_sdl_version_h}") + set(_sdl2_minor "${CMAKE_MATCH_1}") + string(REGEX MATCH "#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)" _sdl2_patch_re "${_sdl_version_h}") + set(_sdl2_patch "${CMAKE_MATCH_1}") + if(_sdl2_major_re AND _sdl2_minor_re AND _sdl2_patch_re) + set(SDL2_VERSION "${_sdl2_major}.${_sdl2_minor}.${_sdl2_patch}") + endif() +endif() + +find_package_handle_standard_args(PrivateSDL2 + REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR + VERSION_VAR SDL2_VERSION +) + +if(PrivateSDL2_FOUND) + if(NOT TARGET PrivateSDL2::PrivateSDL2) + add_library(PrivateSDL2::PrivateSDL2 UNKNOWN IMPORTED) + set_target_properties(PrivateSDL2::PrivateSDL2 PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${SDL2_LIBRARY}" + ) + endif() +endif() diff --git a/cmake/FindSDL2main.cmake b/cmake/FindSDL2main.cmake new file mode 100644 index 00000000..cbdfee86 --- /dev/null +++ b/cmake/FindSDL2main.cmake @@ -0,0 +1,24 @@ +# FIXME: this should be provided by SDL2 + +include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/CommonFindSDL2.cmake") + +find_library(SDL2_MAIN_LIBRARY + NAMES SDL2main + HINTS ${SDL2_DIR} ENV SDL2_DIR + PATH_SUFFIXES ${_lib_suffixes} +) + +find_package_handle_standard_args(SDL2main + REQUIRED_VARS SDL2_MAIN_LIBRARY +) + +if(SDL2main_FOUND) + if(NOT TARGET SDL2::SDL2main) + add_library(SDL2::SDL2main UNKNOWN IMPORTED) + set_target_properties(SDL2::SDL2main PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${SDL2_MAIN_LIBRARY}" + ) + endif() +endif() diff --git a/cmake/Findlibxmp-lite.cmake b/cmake/Findlibxmp-lite.cmake new file mode 100644 index 00000000..d0b2bbbb --- /dev/null +++ b/cmake/Findlibxmp-lite.cmake @@ -0,0 +1,31 @@ +find_library(libxmp_lite_LIBRARY + NAMES xmp +) + +find_path(libxmp_lite_INCLUDE_PATH + NAMES xmp.h +) + +set(libxmp_lite_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of libxmp_lite") + +set(libxmp_lite_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of libxmp_lite") + +set(libxmp_lite_LINK_FLAGS "" CACHE STRING "Extra link flags of libxmp_lite") + +find_package_handle_standard_args(libxmp_lite + REQUIRED_VARS libxmp_lite_LIBRARY libxmp_lite_INCLUDE_PATH +) + +if(libxmp_lite_FOUND) + if(NOT TARGET libxmp-lite::libxmp-lite) + add_library(libxmp-lite::libxmp-lite UNKNOWN IMPORTED) + set_target_properties(libxmp_lite::libxmp_lite-shared PROPERTIES + IMPORTED_LOCATION "${libxmp_lite_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${libxmp_lite_INCLUDE_PATH}" + INTERFACE_COMPILE_OPTIONS "${libxmp_lite_COMPILE_OPTIONS}" + INTERFACE_LINK_LIBRARIES "${libxmp_lite_LINK_LIBRARIES}" + INTERFACE_LINK_FLAGS "${libxmp_lite_LINK_FLAGS}" + ) + endif() + endif() +endif() diff --git a/cmake/Findlibxmp.cmake b/cmake/Findlibxmp.cmake new file mode 100644 index 00000000..c2c44882 --- /dev/null +++ b/cmake/Findlibxmp.cmake @@ -0,0 +1,30 @@ +find_library(libxmp_LIBRARY + NAMES xmp +) + +find_path(libxmp_INCLUDE_PATH + NAMES xmp.h +) + +set(libxmp_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of libxmp") + +set(libxmp_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of libxmp") + +set(libxmp_LINK_FLAGS "" CACHE STRING "Extra link flags of libxmp") + +find_package_handle_standard_args(libxmp + REQUIRED_VARS libxmp_LIBRARY libxmp_INCLUDE_PATH +) + +if(libxmp_FOUND) + if(NOT TARGET libxmp::libxmp) + add_library(libxmp::libxmp UNKNOWN IMPORTED) + set_target_properties(libxmp::libxmp PROPERTIES + IMPORTED_LOCATION "${libxmp_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${libxmp_INCLUDE_PATH}" + INTERFACE_COMPILE_OPTIONS "${libxmp_COMPILE_OPTIONS}" + INTERFACE_LINK_LIBRARIES "${libxmp_LINK_LIBRARIES}" + INTERFACE_LINK_FLAGS "${libxmp_LINK_FLAGS}" + ) + endif() +endif() diff --git a/cmake/Findmodplug.cmake b/cmake/Findmodplug.cmake new file mode 100644 index 00000000..3a74546a --- /dev/null +++ b/cmake/Findmodplug.cmake @@ -0,0 +1,33 @@ +include(FindPackageHandleStandardArgs) + +find_library(modplug_LIBRARY + NAMES modplug +) + +find_path(modplug_INCLUDE_PATH + NAMES libmodplug/modplug.h +) + +set(modplug_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of modplug") + +set(modplug_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of modplug") + +set(modplug_LINK_FLAGS "" CACHE STRING "Extra link flags of modplug") + +find_package_handle_standard_args(modplug + REQUIRED_VARS modplug_LIBRARY modplug_INCLUDE_PATH +) + +if (modplug_FOUND) + if (NOT TARGET modplug::modplug) + add_library(modplug::modplug UNKNOWN IMPORTED) + set_target_properties(modplug::modplug PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${modplug_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${modplug_INCLUDE_PATH}" + INTERFACE_COMPILE_OPTIONS "${modplug_COMPILE_OPTIONS}" + INTERFACE_LINK_LIBRARIES "${modplug_LINK_LIBRARIES}" + INTERFACE_LINK_FLAGS "${modplug_LINK_FLAGS}" + ) + endif() +endif() diff --git a/cmake/Findopusfile.cmake b/cmake/Findopusfile.cmake new file mode 100644 index 00000000..40648d3b --- /dev/null +++ b/cmake/Findopusfile.cmake @@ -0,0 +1,37 @@ +include(FindPackageHandleStandardArgs) + +find_library(opusfile_LIBRARY + NAMES opusfile +) + +set(opusfile_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of opusfile") + +set(opusfile_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of opusfile") + +set(opusfile_LINK_FLAGS "" CACHE STRING "Extra link flags of opusfile") + +find_path(opusfile_INCLUDE_PATH + NAMES opusfile.h + PATH_SUFFIXES opus +) + +find_package_handle_standard_args(opusfile + REQUIRED_VARS opusfile_LIBRARY opusfile_INCLUDE_PATH +) + +if (opusfile_FOUND) + set(opusfile_dirs ${opusfile_INCLUDE_PATH}) + if(EXISTS "${opusfile_INCLUDE_PATH}/opus") + list(APPEND opusfile_dirs "${opusfile_INCLUDE_PATH}/opus") + endif() + if (NOT TARGET opusfile::opusfile) + add_library(opusfile::opusfile UNKNOWN IMPORTED) + set_target_properties(opusfile::opusfile PROPERTIES + IMPORTED_LOCATION "${opusfile_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${opusfile_dirs}" + INTERFACE_COMPILE_OPTIONS "${opusfile_COMPILE_OPTIONS}" + INTERFACE_LINK_LIBRARIES "${opusfile_LINK_LIBRARIES}" + INTERFACE_LINK_FLAGS "${opusfile_LINK_FLAGS}" + ) + endif() +endif() diff --git a/cmake/Findtremor.cmake b/cmake/Findtremor.cmake new file mode 100644 index 00000000..8bdacfd1 --- /dev/null +++ b/cmake/Findtremor.cmake @@ -0,0 +1,32 @@ +include(FindPackageHandleStandardArgs) + +find_library(tremor_LIBRARY + NAMES vorbisidec libvorbisidec +) + +find_path(tremor_INCLUDE_PATH + NAMES tremor/ivorbisfile.h +) + +set(tremor_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of vorbis") + +set(tremor_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of vorbis") + +set(tremor_LINK_FLAGS "" CACHE STRING "Extra link flags of vorbis") + +find_package_handle_standard_args(tremor + REQUIRED_VARS tremor_LIBRARY tremor_INCLUDE_PATH +) + +if (tremor_FOUND) + if (NOT TARGET tremor::tremor) + add_library(tremor::tremor UNKNOWN IMPORTED) + set_target_properties(tremor::tremor PROPERTIES + IMPORTED_LOCATION "${tremor_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${tremor_INCLUDE_PATH}" + INTERFACE_COMPILE_OPTIONS "${tremor_COMPILE_OPTIONS}" + INTERFACE_LINK_LIBRARIES "${tremor_LINK_LIBRARIES}" + INTERFACE_LINK_FLAGS "${tremor_LINK_FLAGS}" + ) + endif() +endif() diff --git a/cmake/Findvorbisfile.cmake b/cmake/Findvorbisfile.cmake new file mode 100644 index 00000000..83a47603 --- /dev/null +++ b/cmake/Findvorbisfile.cmake @@ -0,0 +1,32 @@ +include(FindPackageHandleStandardArgs) + +find_library(vorbisfile_LIBRARY + NAMES vorbisfile +) + +set(vorbisfile_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of vorbisfile") + +set(vorbisfile_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of vorbisfile") + +set(vorbisfile_LINK_FLAGS "" CACHE STRING "Extra link flags of vorbisfile") + +find_path(vorbisfile_INCLUDE_PATH + NAMES vorbis/vorbisfile.h +) + +find_package_handle_standard_args(vorbisfile + REQUIRED_VARS vorbisfile_LIBRARY vorbisfile_INCLUDE_PATH +) + +if (vorbisfile_FOUND) + if (NOT TARGET vorbisfile::vorbisfile) + add_library(vorbisfile::vorbisfile UNKNOWN IMPORTED) + set_target_properties(vorbisfile::vorbisfile PROPERTIES + IMPORTED_LOCATION "${vorbisfile_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${vorbisfile_INCLUDE_PATH}" + INTERFACE_COMPILE_OPTIONS "${vorbisfile_COMPILE_OPTIONS}" + INTERFACE_LINK_LIBRARIES "${vorbisfile_LINK_LIBRARIES}" + INTERFACE_LINK_FLAGS "${vorbisfile_LINK_FLAGS}" + ) + endif() +endif() diff --git a/cmake/PrivateSdlFunctions.cmake b/cmake/PrivateSdlFunctions.cmake new file mode 100644 index 00000000..398770b9 --- /dev/null +++ b/cmake/PrivateSdlFunctions.cmake @@ -0,0 +1,243 @@ +# This file is shared amongst SDL_image/SDL_mixer/SDL_net/SDL_ttf + +macro(sdl_calculate_derived_version_variables) + if (NOT DEFINED MAJOR_VERSION OR NOT DEFINED MINOR_VERSION OR NOT DEFINED MICRO_VERSION) + message(FATAL_ERROR "MAJOR_VERSION, MINOR_VERSION and MICRO_VERSION need to be defined") + endif() + + set(FULL_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}") + + # Calculate a libtool-like version number + math(EXPR BINARY_AGE "${MINOR_VERSION} * 100 + ${MICRO_VERSION}") + math(EXPR IS_DEVELOPMENT "${MINOR_VERSION} % 2") + if (IS_DEVELOPMENT) + # Development branch, 2.5.1 -> libSDL2_XXXXX-2.0.so.0.501.0 + set(INTERFACE_AGE 0) + else() + # Stable branch, 2.6.1 -> libSDL2_XXXXX-2.0.so.0.600.1 + set(INTERFACE_AGE ${MICRO_VERSION}) + endif() + + # Increment this if there is an incompatible change - but if that happens, + # we should rename the library from SDL2 to SDL3, at which point this would + # reset to 0 anyway. + set(LT_MAJOR "0") + + math(EXPR LT_AGE "${BINARY_AGE} - ${INTERFACE_AGE}") + math(EXPR LT_CURRENT "${LT_MAJOR} + ${LT_AGE}") + set(LT_REVISION "${INTERFACE_AGE}") + # For historical reasons, the library name redundantly includes the major + # version twice: libSDL2_XXXXX-2.0.so.0. + # TODO: in SDL 3, set the OUTPUT_NAME to plain SDL3_XXXXX, which will simplify + # it to libSDL2_XXXXX.so.0 + set(LT_RELEASE "2.0") + set(LT_VERSION "${LT_MAJOR}.${LT_AGE}.${LT_REVISION}") + + # The following should match the versions in the Xcode project file. + # Each version is 1 higher than you might expect, for compatibility + # with libtool: macOS ABI versioning is 1-based, unlike other platforms + # which are normally 0-based. + math(EXPR DYLIB_CURRENT_VERSION_MAJOR "${LT_MAJOR} + ${LT_AGE} + 1") + math(EXPR DYLIB_CURRENT_VERSION_MINOR "${LT_REVISION}") + math(EXPR DYLIB_COMPAT_VERSION_MAJOR "${LT_MAJOR} + 1") + set(DYLIB_CURRENT_VERSION "${DYLIB_CURRENT_VERSION_MAJOR}.${DYLIB_CURRENT_VERSION_MINOR}.0") +endmacro() + +macro(sdl_find_sdl2 TARGET VERSION) + if(NOT TARGET ${TARGET}) + # FIXME: can't add REQUIRED since not all SDL2 installs ship SDL2ConfigVersion.cmake (or sdl2-config-version.cmake) + find_package(SDL2 ${VERSION} QUIET) + endif() + if(NOT TARGET ${TARGET}) + # FIXME: can't add REQUIRED since not all SDL2 installs ship SDL2Config.cmake (or sdl2-config.cmake) + find_package(SDL2 QUIET) + if(SDL2_FOUND) + message(WARNING "Could not verify SDL2 version. Assuming SDL2 has version of at least ${VERSION}.") + endif() + endif() + + # Use Private FindSDL2.cmake module to find SDL2 for installations where no SDL2Config.cmake is available, + # or for those installations where no target is generated. + if (NOT TARGET ${TARGET}) + message(STATUS "Using private SDL2 find module") + find_package(PrivateSDL2 ${VERSION} REQUIRED) + add_library(${TARGET} INTERFACE IMPORTED) + set_target_properties(${TARGET} PROPERTIES + INTERFACE_LINK_LIBRARIES "PrivateSDL2::PrivateSDL2" + ) + endif() +endmacro() + +function(read_absolute_symlink DEST PATH) + file(READ_SYMLINK "${PATH}" p) + if (NOT IS_ABSOLUTE p) + get_filename_component(pdir "${PATH}" DIRECTORY) + set(p "${pdir}/${p}") + endif() + set("${DEST}" "${p}" PARENT_SCOPE) +endfunction() + +function(win32_implib_identify_dll DEST IMPLIB) + cmake_parse_arguments(ARGS "NOTFATAL" "" "" ${ARGN}) + if (CMAKE_DLLTOOL) + execute_process( + COMMAND "${CMAKE_DLLTOOL}" --identify "${IMPLIB}" + RESULT_VARIABLE retcode + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr) + if (NOT retcode EQUAL 0) + if (NOT ARGS_NOTFATAL) + message(FATAL_ERROR "${CMAKE_DLLTOOL} failed.") + else() + set("${DEST}" "${DEST}-NOTFOUND" PARENT_SCOPE) + return() + endif() + endif() + string(STRIP "${stdout}" result) + set(${DEST} "${result}" PARENT_SCOPE) + elseif (MSVC) + get_filename_component(CMAKE_C_COMPILER_DIRECTORY "${CMAKE_C_COMPILER}" DIRECTORY CACHE) + find_program(CMAKE_DUMPBIN NAMES dumpbin PATHS "${CMAKE_C_COMPILER_DIRECTORY}") + if (CMAKE_DUMPBIN) + execute_process( + COMMAND "${CMAKE_DUMPBIN}" "-headers" "${IMPLIB}" + RESULT_VARIABLE retcode + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr) + if (NOT retcode EQUAL 0) + if (NOT ARGS_NOTFATAL) + message(FATAL_ERROR "dumpbin failed.") + else() + set(${DEST} "${DEST}-NOTFOUND" PARENT_SCOPE) + return() + endif() + endif() + string(REGEX MATCH "DLL name[ ]+:[ ]+([^\n]+)\n" match "${stdout}") + if (NOT match) + if (NOT ARGS_NOTFATAL) + message(FATAL_ERROR "dumpbin did not find any associated dll for ${IMPLIB}.") + else() + set(${DEST} "${DEST}-NOTFOUND" PARENT_SCOPE) + return() + endif() + endif() + set(result "${CMAKE_MATCH_1}") + set(${DEST} "${result}" PARENT_SCOPE) + else() + message(FATAL_ERROR "Cannot find dumpbin, please set CMAKE_DUMPBIN cmake variable") + endif() + else() + if (NOT ARGS_NOTFATAL) + message(FATAL_ERROR "Don't know how to identify dll from import library. Set CMAKE_DLLTOOL (for mingw) or CMAKE_DUMPBIN (for MSVC)") + else() + set(${DEST} "${DEST}-NOTFOUND") + endif() + endif() +endfunction() + +function(target_get_dynamic_library DEST TARGET) + set(result) + get_target_property(alias "${TARGET}" ALIASED_TARGET) + while (alias) + set(TARGET "${alias}") + get_target_property(alias "${TARGET}" ALIASED_TARGET) + endwhile() + if (WIN32) + # Use the target dll of the import library + set(props_to_check IMPORTED_IMPLIB) + if (CMAKE_BUILD_TYPE) + list(APPEND props_to_check IMPORTED_IMPLIB_${CMAKE_BUILD_TYPE}) + endif() + list(APPEND props_to_check IMPORTED_LOCATION) + if (CMAKE_BUILD_TYPE) + list(APPEND props_to_check IMPORTED_LOCATION_${CMAKE_BUILD_TYPE}) + endif() + foreach (config_type ${CMAKE_CONFIGURATION_TYPES} RELEASE DEBUG RELWITHDEBINFO MINSIZEREL) + list(APPEND props_to_check IMPORTED_IMPLIB_${config_type}) + list(APPEND props_to_check IMPORTED_LOCATION_${config_type}) + endforeach() + + foreach(prop_to_check ${props_to_check}) + if (NOT result) + get_target_property(propvalue "${TARGET}" ${prop_to_check}) + if (propvalue AND EXISTS "${propvalue}") + win32_implib_identify_dll(result "${propvalue}" NOTFATAL) + endif() + endif() + endforeach() + else() + # 1. find the target library a file might be symbolic linking to + # 2. find all other files in the same folder that symolic link to it + # 3. sort all these files, and select the 2nd item + set(props_to_check IMPORTED_LOCATION) + if (CMAKE_BUILD_TYPE) + list(APPEND props_to_check IMPORTED_LOCATION_${CMAKE_BUILD_TYPE}) + endif() + foreach (config_type ${CMAKE_CONFIGURATION_TYPES} RELEASE DEBUG RELWITHDEBINFO MINSIZEREL) + list(APPEND props_to_check IMPORTED_LOCATION_${config_type}) + endforeach() + foreach(prop_to_check ${props_to_check}) + if (NOT result) + get_target_property(propvalue "${TARGET}" ${prop_to_check}) + if (EXISTS "${propvalue}") + while (IS_SYMLINK "${propvalue}") + read_absolute_symlink(propvalue "${propvalue}") + endwhile() + get_filename_component(libdir "${propvalue}" DIRECTORY) + file(GLOB subfiles "${libdir}/*") + set(similar_files "${propvalue}") + foreach(subfile ${subfiles}) + if (IS_SYMLINK "${subfile}") + read_absolute_symlink(subfile_target "${subfile}") + if (subfile_target STREQUAL propvalue) + list(APPEND similar_files "${subfile}") + endif() + endif() + endforeach() + list(SORT similar_files) + list(LENGTH similar_files eq_length) + if (eq_length GREATER 1) + list(GET similar_files 1 item) + else() + list(GET similar_files 0 item) + endif() + get_filename_component(result "${item}" NAME) + endif() + endif() + endforeach() + endif() + if (NOT result) + set (result "$") + endif() + set(${DEST} ${result} PARENT_SCOPE) +endfunction() + +macro(sdl_check_project_in_subfolder relative_subfolder name vendored_option) + if(NOT EXISTS "${PROJECT_SOURCE_DIR}/${relative_subfolder}/CMakeLists.txt") + message(FATAL_ERROR "No cmake project for ${name} found in ${relative_subfolder}.\n" + "Run the download script in the external folder, or re-configure with -D${vendored_option}=OFF to use system packages.") + endif() +endmacro() + +macro(sdl_check_linker_flag flag var) + # FIXME: Use CheckLinkerFlag module once cmake minimum version >= 3.18 + include(CMakePushCheckState) + include(CheckCSourceCompiles) + cmake_push_check_state(RESET) + set(CMAKE_REQUIRED_LINK_OPTIONS "-Wl,--no-undefined") + check_c_source_compiles("int main() { return 0; }" ${var}) + cmake_pop_check_state() +endmacro() + +function(sdl_target_link_options_no_undefined TARGET) + if(NOT MSVC) + if(CMAKE_C_COMPILER_ID MATCHES "AppleClang") + target_link_options(${TARGET} PRIVATE "-Wl,-undefined,error") + else() + sdl_check_linker_flag("-Wl,--no-undefined" HAVE_WL_NO_UNDEFINED) + if(HAVE_WL_NO_UNDEFINED) + target_link_options(${TARGET} PRIVATE "-Wl,--no-undefined") + endif() + endif() + endif() +endfunction() diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt new file mode 100644 index 00000000..bbcdfb95 --- /dev/null +++ b/cmake/test/CMakeLists.txt @@ -0,0 +1,49 @@ +# This cmake build script is meant for verifying the various CMake configuration script. + +cmake_minimum_required(VERSION 3.12) +project(sdl_test LANGUAGES C) + +cmake_policy(SET CMP0074 NEW) + +# Override CMAKE_FIND_ROOT_PATH_MODE to allow search for SDL2_mixer outside of sysroot +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER) + +include(FeatureSummary) + +option(TEST_SHARED "Test linking to shared SDL2_mixer library" ON) +add_feature_info("TEST_SHARED" TEST_SHARED "Test linking with shared library") + +option(TEST_STATIC "Test linking to static SDL2_mixer libary" ON) +add_feature_info("TEST_STATIC" TEST_STATIC "Test linking with static library") + +if(TEST_SHARED) + # FIXME: in the distant future, must become REQUIRED + find_package(SDL2 CONFIG COMPONENTS SDL2) + # FIXME: and the following should be removed + if(NOT TARGET SDL2::SDL2) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/..") + include(PrivateSdlFunctions) + sdl_find_sdl2(SDL2::SDL2 2.0) + endif() + find_package(SDL2_mixer REQUIRED CONFIG) + add_executable(main_shared main.c) + target_link_libraries(main_shared PRIVATE SDL2::SDL2 SDL2_mixer::SDL2_mixer) +endif() + +if(TEST_STATIC) + # FIXME: in the distant future, must become REQUIRED + find_package(SDL2 CONFIG COMPONENTS SDL2-static) + # FIXME: and the following should be removed + if(NOT TARGET SDL2::SDL2-static) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/..") + include(PrivateSdlFunctions) + sdl_find_sdl2(SDL2::SDL2-static 2.0) + endif() + # some static vendored libraries use c++ (enable CXX after `find_package` might show a warning) + enable_language(CXX) + find_package(SDL2_mixer REQUIRED CONFIG) + add_executable(main_static main.c) + target_link_libraries(main_static PRIVATE SDL2::SDL2-static SDL2_mixer::SDL2_mixer-static) +endif() + +feature_summary(WHAT ALL) diff --git a/cmake/test/main.c b/cmake/test/main.c new file mode 100644 index 00000000..abc296c1 --- /dev/null +++ b/cmake/test/main.c @@ -0,0 +1,18 @@ +#define SDL_MAIN_HANDLED +#include "SDL.h" +#include "SDL_mixer.h" +#include + +int main(int argc, char *argv[]) { + SDL_SetMainReady(); + if (SDL_Init(0) < 0) { + fprintf(stderr, "SDL_Init: could not initialize SDL: %s\n", SDL_GetError()); + return 1; + } + if (Mix_Init(0) == 0) { + fprintf(stderr, "Mix_Init: no sound/music loaders supported (%s)\n", Mix_GetError()); + } + Mix_Quit(); + SDL_Quit(); + return 0; +} diff --git a/configure b/configure index d97d5eb0..fb005494 100755 --- a/configure +++ b/configure @@ -1,6 +1,8 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.71. +# Generated by GNU Autoconf 2.71 for SDL2_mixer 2.5.1. +# +# Report bugs to . # # # Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation, @@ -265,10 +267,11 @@ then : printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should" printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later." else - printf "%s\n" "$0: Please tell bug-autoconf@gnu.org about your system, -$0: including any error possibly output before this -$0: message. Then install a modern shell, or manually run -$0: the script under such a shell if you do have one." + printf "%s\n" "$0: Please tell bug-autoconf@gnu.org and +$0: https://github.com/libsdl-org/SDL_mixer/issues about +$0: your system, including any error possibly output before +$0: this message. Then install a modern shell, or manually +$0: run the script under such a shell if you do have one." fi exit 1 fi @@ -755,11 +758,11 @@ MFLAGS= MAKEFLAGS= # Identity of this package. -PACKAGE_NAME='' -PACKAGE_TARNAME='' -PACKAGE_VERSION='' -PACKAGE_STRING='' -PACKAGE_BUGREPORT='' +PACKAGE_NAME='SDL2_mixer' +PACKAGE_TARNAME='SDL2_mixer' +PACKAGE_VERSION='2.5.1' +PACKAGE_STRING='SDL2_mixer 2.5.1' +PACKAGE_BUGREPORT='https://github.com/libsdl-org/SDL_mixer/issues' PACKAGE_URL='' ac_unique_file="src/mixer.c" @@ -797,6 +800,22 @@ ac_includes_default="\ ac_header_c_list= ac_subst_vars='LTLIBOBJS LIBOBJS +SDL2MIXER_WAVE +SDL2MIXER_VORBIS_VORBISFILE +SDL2MIXER_VORBIS_TREMOR +SDL2MIXER_VORBIS_STB +SDL2MIXER_OPUS +SDL2MIXER_MIDI_TIMIDITY +SDL2MIXER_MIDI_NATIVE +SDL2MIXER_MIDI_FLUIDSYNTH +SDL2MIXER_MP3_MPG123 +SDL2MIXER_MP3_DRMP3 +SDL2MIXER_MOD_XMP_LITE +SDL2MIXER_MOD_XMP +SDL2MIXER_MOD_MODPLUG +SDL2MIXER_FLAC_LIBFLAC +SDL2MIXER_FLAC_DRFLAC +SDL2MIXER_CMD PC_LIBS PC_REQUIRES SDL_VERSION @@ -810,6 +829,7 @@ PLAYWAVE_OBJECTS VERSION_OBJECTS OBJECTS ac_aux_dir +cmake_prefix_relpath OPUSFILE_LIBS OPUSFILE_CFLAGS MPG123_LIBS @@ -1046,7 +1066,7 @@ localstatedir='${prefix}/var' runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE}' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' @@ -1553,7 +1573,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures this package to adapt to many kinds of systems. +\`configure' configures SDL2_mixer 2.5.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1602,7 +1622,7 @@ Fine tuning of the installation directories: --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] + --docdir=DIR documentation root [DATAROOTDIR/doc/SDL2_mixer] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] @@ -1618,7 +1638,9 @@ _ACEOF fi if test -n "$ac_init_help"; then - + case $ac_init_help in + short | recursive ) echo "Configuration of SDL2_mixer 2.5.1:";; + esac cat <<\_ACEOF Optional Features: @@ -1740,7 +1762,7 @@ Some influential environment variables: Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. -Report bugs to the package provider. +Report bugs to . _ACEOF ac_status=$? fi @@ -1804,7 +1826,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -configure +SDL2_mixer configure 2.5.1 generated by GNU Autoconf 2.71 Copyright (C) 2021 Free Software Foundation, Inc. @@ -2189,7 +2211,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by $as_me, which was +It was created by SDL2_mixer $as_me 2.5.1, which was generated by GNU Autoconf 2.71. Invocation command line was $ $0$ac_configure_args_raw @@ -3163,12 +3185,12 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu - -# See release_checklist.md MAJOR_VERSION=2 + MINOR_VERSION=5 + MICRO_VERSION=1 -VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION + BINARY_AGE=`expr $MINOR_VERSION \* 100 + $MICRO_VERSION` case "$MINOR_VERSION" in #( @@ -4907,13 +4929,13 @@ then : else $as_nop lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:4910: $ac_compile\"" >&5) + (eval echo "\"\$as_me:4932: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:4913: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:4935: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:4916: output\"" >&5) + (eval echo "\"\$as_me:4938: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -6172,7 +6194,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 6175 "configure"' > conftest.$ac_ext + echo '#line 6197 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -7845,11 +7867,11 @@ else $as_nop -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7848: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7870: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7852: \$? = $ac_status" >&5 + echo "$as_me:7874: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -8195,11 +8217,11 @@ else $as_nop -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8198: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8220: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8202: \$? = $ac_status" >&5 + echo "$as_me:8224: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -8302,11 +8324,11 @@ else $as_nop -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8305: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8327: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:8309: \$? = $ac_status" >&5 + echo "$as_me:8331: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -8358,11 +8380,11 @@ else $as_nop -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8361: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8383: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:8365: \$? = $ac_status" >&5 + echo "$as_me:8387: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -10801,7 +10823,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10804 "configure" +#line 10826 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10898,7 +10920,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10901 "configure" +#line 10923 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -14559,11 +14581,11 @@ else $as_nop -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14562: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14584: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14566: \$? = $ac_status" >&5 + echo "$as_me:14588: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14660,11 +14682,11 @@ else $as_nop -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14663: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14685: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14667: \$? = $ac_status" >&5 + echo "$as_me:14689: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -14713,11 +14735,11 @@ else $as_nop -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14716: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14738: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14720: \$? = $ac_status" >&5 + echo "$as_me:14742: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -16884,6 +16906,7 @@ fi done +SDL2MIXER_CMD=0 # Check whether --enable-music-cmd was given. if test ${enable_music_cmd+y} then : @@ -16917,9 +16940,11 @@ fi fi if test "x$enable_music_cmd" != xno; then EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_CMD" + SDL2MIXER_CMD=1 fi fi +SDL2MIXER_WAVE=0 # Check whether --enable-music-wave was given. if test ${enable_music_wave+y} then : @@ -16930,6 +16955,7 @@ fi if test x$enable_music_wave = xyes; then EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_WAV" + SDL2MIXER_WAVE=1 fi # Check whether --enable-music-mod was given. @@ -16941,6 +16967,7 @@ else $as_nop fi +SDL2MIXER_MOD_MODPLUG=0 # Check whether --enable-music-mod-modplug was given. if test ${enable_music_mod_modplug+y} then : @@ -17153,12 +17180,15 @@ fi PC_LIBS="$PC_LIBS $MODPLUG_LIBS" fi fi + SDL2MIXER_MOD_MODPLUG=1 else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)" >&5 printf "%s\n" "$as_me: WARNING: *** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)" >&2;} fi fi +SDL2MIXER_MOD_XMP=0 +SDL2MIXER_MOD_XMP_LITE=0 # Check whether --enable-music-mod-xmp was given. if test ${enable_music_mod_xmp+y} then : @@ -17383,6 +17413,10 @@ fi PC_LIBS="$PC_LIBS $XMP_LIBS" fi fi + SDL2MIXER_MOD_XMP=1 + if test x$enable_music_mod_xmp_lite = xyes; then + SDL2MIXER_MOD_XMP_LITE=1 + fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find xmp library (http://xmp.sourceforge.net/)" >&5 printf "%s\n" "$as_me: WARNING: *** Unable to find xmp library (http://xmp.sourceforge.net/)" >&2;} @@ -17394,6 +17428,9 @@ if test x$have_libmodplug != xyes -a x$have_libxmp != xyes; then printf "%s\n" "$as_me: WARNING: MOD support disabled" >&2;} fi +SDL2MIXER_MIDI_FLUIDSYNTH=0 +SDL2MIXER_MIDI_NATIVE=0 +SDL2MIXER_MIDI_TIMIDITY=0 # Check whether --enable-music-midi was given. if test ${enable_music_midi+y} then : @@ -17426,6 +17463,7 @@ fi if test x$timidity_cfg != xyes -a x$timidity_cfg != xno; then EXTRA_CFLAGS="$EXTRA_CFLAGS -DTIMIDITY_CFG=\\\"$timidity_cfg\\\"" fi + SDL2MIXER_MIDI_TIMIDITY=1 fi # Check whether --enable-music-midi-native was given. if test ${enable_music_midi_native+y} @@ -17457,10 +17495,12 @@ fi if test x$use_music_midi_native = xyes; then EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/src/codecs/native_midi" SOURCES="$SOURCES $srcdir/src/codecs/native_midi/*.c" + SDL2MIXER_MIDI_NATIVE=1 elif test x$use_music_midi_native = xyes_cpp; then EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/src/codecs/native_midi" SOURCES="$SOURCES $srcdir/src/codecs/native_midi/*.c" SOURCES_CXX="$SOURCES_CXX $srcdir/src/codecs/native_midi/*.cpp" + SDL2MIXER_MIDI_NATIVE=1 fi fi # Check whether --enable-music-midi-fluidsynth was given. @@ -17677,6 +17717,7 @@ fi PC_LIBS="$PC_LIBS $FLUIDSYNTH_LIBS" fi fi + SDL2MIXER_MIDI_FLUIDSYNTH=1 else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find FluidSynth library (http://www.fluidsynth.org/)" >&5 printf "%s\n" "$as_me: WARNING: *** Unable to find FluidSynth library (http://www.fluidsynth.org/)" >&2;} @@ -17702,6 +17743,7 @@ else $as_nop fi +SDL2MIXER_VORBIS_STB=0 # Check whether --enable-music-ogg-stb was given. if test ${enable_music_ogg_stb+y} then : @@ -17713,8 +17755,10 @@ fi if test x$enable_music_ogg = xyes -a x$enable_music_ogg_stb = xyes; then have_stb_vorbis=yes EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG -DOGG_USE_STB" + SDL2MIXER_VORBIS_STB=1 fi +SDL2MIXER_VORBIS_VORBISFILE=0 # Check whether --enable-music-ogg-vorbis was given. if test ${enable_music_ogg_vorbis+y} then : @@ -17929,12 +17973,14 @@ fi PC_LIBS="$PC_LIBS $VORBIS_LIBS" fi fi + SDL2MIXER_VORBIS_VORBISFILE=1 else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find Ogg Vorbis library (http://www.xiph.org/)" >&5 printf "%s\n" "$as_me: WARNING: *** Unable to find Ogg Vorbis library (http://www.xiph.org/)" >&2;} fi fi +SDL2MIXER_VORBIS_TREMOR=0 # Check whether --enable-music-ogg-tremor was given. if test ${enable_music_ogg_tremor+y} then : @@ -18152,6 +18198,7 @@ fi PC_LIBS="$PC_LIBS $TREMOR_LIBS" fi fi + SDL2MIXER_VORBIS_TREMOR=1 else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)" >&5 printf "%s\n" "$as_me: WARNING: *** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)" >&2;} @@ -18164,6 +18211,7 @@ if test x$enable_music_ogg = xyes -a \ printf "%s\n" "$as_me: WARNING: Ogg Vorbis support disabled" >&2;} fi +SDL2MIXER_FLAC_DRFLAC=0 # Check whether --enable-music-flac was given. if test ${enable_music_flac+y} then : @@ -18184,8 +18232,10 @@ fi if test x$enable_music_flac = xyes -a x$enable_music_flac_drflac = xyes; then have_drflac=yes EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_FLAC_DRFLAC" + SDL2MIXER_FLAC_DRFLAC=1 fi +SDL2MIXER_FLAC_LIBFLAC=0 # Check whether --enable-music-flac-libflac was given. if test ${enable_music_flac_libflac+y} then : @@ -18434,6 +18484,7 @@ printf "%s\n" "$have_flac_ver" >&6; } PC_LIBS="$PC_LIBS $FLAC_LIBS" fi fi + SDL2MIXER_FLAC_LIBFLAC=1 else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find FLAC library (https://xiph.org/flac/)" >&5 printf "%s\n" "$as_me: WARNING: *** Unable to find FLAC library (https://xiph.org/flac/)" >&2;} @@ -18455,6 +18506,7 @@ else $as_nop fi +SDL2MIXER_MP3_DRMP3=0 # Check whether --enable-music-mp3-drmp3 was given. if test ${enable_music_mp3_drmp3+y} then : @@ -18466,8 +18518,10 @@ fi if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_drmp3 = xyes; then have_drmp3=yes EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_DRMP3" + SDL2MIXER_MP3_DRMP3=1 fi +SDL2MIXER_MP3_MPG123=0 # Check whether --enable-music-mp3-mpg123 was given. if test ${enable_music_mp3_mpg123+y} then : @@ -18676,6 +18730,7 @@ fi PC_LIBS="$PC_LIBS $MPG123_LIBS" fi fi + SDL2MIXER_MP3_MPG123=1 else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find mpg123 library (https://www.mpg123.de)" >&5 printf "%s\n" "$as_me: WARNING: *** Unable to find mpg123 library (https://www.mpg123.de)" >&2;} @@ -18687,6 +18742,7 @@ if test x$enable_music_mp3 = xyes -a x$have_drmp3 != xyes -a x$have_libmpg123 != printf "%s\n" "$as_me: WARNING: MP3 support disabled" >&2;} fi +SDL2MIXER_OPUS=0 # Check whether --enable-music-opus was given. if test ${enable_music_opus+y} then : @@ -18901,6 +18957,7 @@ fi PC_LIBS="$PC_LIBS $OPUSFILE_LIBS" fi fi + SDL2MIXER_OPUS=1 else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find opusfile library (http://opus-codec.org/)" >&5 printf "%s\n" "$as_me: WARNING: *** Unable to find opusfile library (http://opus-codec.org/)" >&2;} @@ -18956,6 +19013,28 @@ $(objects)/\2.lo: \1/\2.c \$(objects)/.created\\ \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'` PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\\$,\\\\$,g'` +eval pkg_prefix=$prefix +eval pkg_cmakedir=$libdir/cmake/SDL2_mixer +cmake_prefix_relpath="$(echo -n "$pkg_cmakedir" | sed -E "s#^$pkg_prefix##" | sed -E "s#[A-Za-z0-9_ .-]+#..#g")" + + + + + + + + + + + + + + + + + + + @@ -18972,7 +19051,7 @@ PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\\$,\\\\$,g'` -ac_config_files="$ac_config_files Makefile SDL2_mixer.spec SDL2_mixer.pc" +ac_config_files="$ac_config_files Makefile SDL2_mixer.spec SDL2_mixer.pc sdl2_mixer-config.cmake sdl2_mixer-config-version.cmake" ac_config_commands="$ac_config_commands default" @@ -19511,7 +19590,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by $as_me, which was +This file was extended by SDL2_mixer $as_me 2.5.1, which was generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -19562,7 +19641,7 @@ $config_files Configuration commands: $config_commands -Report bugs to the package provider." +Report bugs to ." _ACEOF ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"` @@ -19570,7 +19649,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -config.status +SDL2_mixer config.status 2.5.1 configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" @@ -20131,6 +20210,8 @@ do "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "SDL2_mixer.spec") CONFIG_FILES="$CONFIG_FILES SDL2_mixer.spec" ;; "SDL2_mixer.pc") CONFIG_FILES="$CONFIG_FILES SDL2_mixer.pc" ;; + "sdl2_mixer-config.cmake") CONFIG_FILES="$CONFIG_FILES sdl2_mixer-config.cmake" ;; + "sdl2_mixer-config-version.cmake") CONFIG_FILES="$CONFIG_FILES sdl2_mixer-config-version.cmake" ;; "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; diff --git a/configure.ac b/configure.ac index 66c65dde..4622fc9d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,15 +1,21 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT -AC_CONFIG_SRCDIR([src/mixer.c]) -AC_CONFIG_AUX_DIR(build-scripts) dnl Set various version strings - taken gratefully from the GTk sources - # See release_checklist.md -MAJOR_VERSION=2 -MINOR_VERSION=5 -MICRO_VERSION=1 -VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION +m4_define([MAJOR_VERSION_MACRO], [2]) +m4_define([MINOR_VERSION_MACRO], [5]) +m4_define([MICRO_VERSION_MACRO], [1]) + +AC_INIT([SDL2_mixer], + MAJOR_VERSION_MACRO.MINOR_VERSION_MACRO.MICRO_VERSION_MACRO, + [https://github.com/libsdl-org/SDL_mixer/issues], + [SDL2_mixer]) +AC_CONFIG_SRCDIR([src/mixer.c]) +AC_CONFIG_AUX_DIR(build-scripts) + +AC_SUBST([MAJOR_VERSION], MAJOR_VERSION_MACRO) +AC_SUBST([MINOR_VERSION], MINOR_VERSION_MACRO) +AC_SUBST([MICRO_VERSION], MICRO_VERSION_MACRO) BINARY_AGE=`expr $MINOR_VERSION \* 100 + $MICRO_VERSION` AS_CASE(["$MINOR_VERSION"], @@ -292,6 +298,7 @@ AC_CHECK_FUNCS(setbuf, [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SETBUF"]) dnl Check command-line options +SDL2MIXER_CMD=0 AC_ARG_ENABLE([music-cmd], [AS_HELP_STRING([--enable-music-cmd], [support an external music player [default=yes]])], [], [enable_music_cmd=detect]) @@ -308,20 +315,24 @@ if test "x$enable_music_cmd" != xno; then fi if test "x$enable_music_cmd" != xno; then EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_CMD" + SDL2MIXER_CMD=1 fi fi +SDL2MIXER_WAVE=0 AC_ARG_ENABLE([music-wave], [AS_HELP_STRING([--enable-music-wave], [enable streaming WAVE music [default=yes]])], [], [enable_music_wave=yes]) if test x$enable_music_wave = xyes; then EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_WAV" + SDL2MIXER_WAVE=1 fi AC_ARG_ENABLE([music-mod], [AS_HELP_STRING([--enable-music-mod], [enable MOD music [default=yes]])], [], [enable_music_mod=yes]) +SDL2MIXER_MOD_MODPLUG=0 AC_ARG_ENABLE([music-mod-modplug], [AS_HELP_STRING([--enable-music-mod-modplug], [enable MOD music via modplug [default=yes]])], [], [enable_music_mod_modplug=yes]) @@ -366,11 +377,14 @@ if test x$enable_music_mod = xyes -a x$enable_music_mod_modplug = xyes; then PC_LIBS="$PC_LIBS $MODPLUG_LIBS" fi fi + SDL2MIXER_MOD_MODPLUG=1 else AC_MSG_WARN([*** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)]) fi fi +SDL2MIXER_MOD_XMP=0 +SDL2MIXER_MOD_XMP_LITE=0 AC_ARG_ENABLE([music-mod-xmp], [AS_HELP_STRING([--enable-music-mod-xmp], [enable MOD music via libxmp [default=no]])], [], [enable_music_mod_xmp=no]) @@ -422,6 +436,10 @@ if test x$enable_music_mod = xyes -a x$enable_music_mod_xmp = xyes; then PC_LIBS="$PC_LIBS $XMP_LIBS" fi fi + SDL2MIXER_MOD_XMP=1 + if test x$enable_music_mod_xmp_lite = xyes; then + SDL2MIXER_MOD_XMP_LITE=1 + fi else AC_MSG_WARN([*** Unable to find xmp library (http://xmp.sourceforge.net/)]) fi @@ -431,6 +449,9 @@ if test x$have_libmodplug != xyes -a x$have_libxmp != xyes; then AC_MSG_WARN([MOD support disabled]) fi +SDL2MIXER_MIDI_FLUIDSYNTH=0 +SDL2MIXER_MIDI_NATIVE=0 +SDL2MIXER_MIDI_TIMIDITY=0 AC_ARG_ENABLE([music-midi], [AS_HELP_STRING([--enable-music-midi], [enable MIDI music [default=yes]])], [], [enable_music_midi=yes]) @@ -448,6 +469,7 @@ if test x$enable_music_midi = xyes; then if test x$timidity_cfg != xyes -a x$timidity_cfg != xno; then EXTRA_CFLAGS="$EXTRA_CFLAGS -DTIMIDITY_CFG=\\\"$timidity_cfg\\\"" fi + SDL2MIXER_MIDI_TIMIDITY=1 fi AC_ARG_ENABLE([music-midi-native], [AS_HELP_STRING([--enable-music-midi-native], [enable native MIDI music output [default=yes]])], @@ -474,10 +496,12 @@ if test x$enable_music_midi = xyes; then if test x$use_music_midi_native = xyes; then EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/src/codecs/native_midi" SOURCES="$SOURCES $srcdir/src/codecs/native_midi/*.c" + SDL2MIXER_MIDI_NATIVE=1 elif test x$use_music_midi_native = xyes_cpp; then EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/src/codecs/native_midi" SOURCES="$SOURCES $srcdir/src/codecs/native_midi/*.c" SOURCES_CXX="$SOURCES_CXX $srcdir/src/codecs/native_midi/*.cpp" + SDL2MIXER_MIDI_NATIVE=1 fi fi AC_ARG_ENABLE([music-midi-fluidsynth], @@ -526,6 +550,7 @@ if test x$enable_music_midi = xyes; then PC_LIBS="$PC_LIBS $FLUIDSYNTH_LIBS" fi fi + SDL2MIXER_MIDI_FLUIDSYNTH=1 else AC_MSG_WARN([*** Unable to find FluidSynth library (http://www.fluidsynth.org/)]) AC_MSG_WARN([FluidSynth support disabled]) @@ -543,14 +568,17 @@ AC_ARG_ENABLE([music-ogg], [AS_HELP_STRING([--enable-music-ogg], [enable Ogg Vorbis music [default=yes]])], [], [enable_music_ogg=yes]) +SDL2MIXER_VORBIS_STB=0 AC_ARG_ENABLE(music-ogg-stb, [AS_HELP_STRING([--enable-music-ogg-stb], [enable OGG Vorbis music via stb_vorbis [default=yes]])], [], enable_music_ogg_stb=yes) if test x$enable_music_ogg = xyes -a x$enable_music_ogg_stb = xyes; then have_stb_vorbis=yes EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG -DOGG_USE_STB" + SDL2MIXER_VORBIS_STB=1 fi +SDL2MIXER_VORBIS_VORBISFILE=0 AC_ARG_ENABLE(music-ogg-vorbis, [AS_HELP_STRING([--enable-music-ogg-vorbis], [enable OGG Vorbis music via libvorbis [default=no]])], [], enable_music_ogg_vorbis=no) @@ -597,11 +625,13 @@ if test x$enable_music_ogg = xyes -a x$enable_music_ogg_vorbis = xyes; then PC_LIBS="$PC_LIBS $VORBIS_LIBS" fi fi + SDL2MIXER_VORBIS_VORBISFILE=1 else AC_MSG_WARN([*** Unable to find Ogg Vorbis library (http://www.xiph.org/)]) fi fi +SDL2MIXER_VORBIS_TREMOR=0 AC_ARG_ENABLE(music-ogg-tremor, [AS_HELP_STRING([--enable-music-ogg-tremor], [enable OGG Vorbis music via Tremor [default=no]])], [], enable_music_ogg_tremor=no) @@ -651,6 +681,7 @@ if test x$enable_music_ogg = xyes -a x$enable_music_ogg_tremor = xyes; then PC_LIBS="$PC_LIBS $TREMOR_LIBS" fi fi + SDL2MIXER_VORBIS_TREMOR=1 else AC_MSG_WARN([*** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)]) fi @@ -661,6 +692,7 @@ if test x$enable_music_ogg = xyes -a \ AC_MSG_WARN([Ogg Vorbis support disabled]) fi +SDL2MIXER_FLAC_DRFLAC=0 AC_ARG_ENABLE([music-flac], [AS_HELP_STRING([--enable-music-flac], [enable FLAC music [default=yes]])], [], [enable_music_flac=yes]) @@ -671,8 +703,10 @@ AC_ARG_ENABLE(music-flac-drflac, if test x$enable_music_flac = xyes -a x$enable_music_flac_drflac = xyes; then have_drflac=yes EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_FLAC_DRFLAC" + SDL2MIXER_FLAC_DRFLAC=1 fi +SDL2MIXER_FLAC_LIBFLAC=0 AC_ARG_ENABLE(music-flac-libflac, [AS_HELP_STRING([--enable-music-flac-libflac], [enable FLAC music via libFLAC [default=no]])], [], [enable_music_flac_libflac=no]) @@ -734,6 +768,7 @@ if test x$enable_music_flac = xyes -a x$enable_music_flac_libflac = xyes; then PC_LIBS="$PC_LIBS $FLAC_LIBS" fi fi + SDL2MIXER_FLAC_LIBFLAC=1 else AC_MSG_WARN([*** Unable to find FLAC library (https://xiph.org/flac/)]) fi @@ -748,14 +783,17 @@ AC_ARG_ENABLE(music-mp3, [AS_HELP_STRING([--enable-music-mp3], [enable MP3 music [default=yes]])], [], enable_music_mp3=yes) +SDL2MIXER_MP3_DRMP3=0 AC_ARG_ENABLE(music-mp3-drmp3, [AS_HELP_STRING([--enable-music-mp3-drmp3], [enable MP3 music via dr_mp3 [default=yes]])], [], [enable_music_mp3_drmp3=yes]) if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_drmp3 = xyes; then have_drmp3=yes EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_DRMP3" + SDL2MIXER_MP3_DRMP3=1 fi +SDL2MIXER_MP3_MPG123=0 AC_ARG_ENABLE(music-mp3-mpg123, [AS_HELP_STRING([--enable-music-mp3-mpg123], [enable MP3 music via mpg123 [default=no]])], [], [enable_music_mp3_mpg123=no]) @@ -796,6 +834,7 @@ if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_mpg123 = xyes; then PC_LIBS="$PC_LIBS $MPG123_LIBS" fi fi + SDL2MIXER_MP3_MPG123=1 else AC_MSG_WARN([*** Unable to find mpg123 library (https://www.mpg123.de)]) fi @@ -805,6 +844,7 @@ if test x$enable_music_mp3 = xyes -a x$have_drmp3 != xyes -a x$have_libmpg123 != AC_MSG_WARN([MP3 support disabled]) fi +SDL2MIXER_OPUS=0 AC_ARG_ENABLE([music-opus], [AS_HELP_STRING([--enable-music-opus], [enable Opus music [default=yes]])], [], [enable_music_opus=yes]) @@ -851,6 +891,7 @@ if test x$enable_music_opus = xyes; then PC_LIBS="$PC_LIBS $OPUSFILE_LIBS" fi fi + SDL2MIXER_OPUS=1 else AC_MSG_WARN([*** Unable to find opusfile library (http://opus-codec.org/)]) AC_MSG_WARN([Opus support disabled]) @@ -905,6 +946,12 @@ $(objects)/\2.lo: \1/\2.c \$(objects)/.created\\ \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'` PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\\$,\\\\$,g'` +dnl Calculate the location of the prefix, relative to the cmake folder +eval pkg_prefix=$prefix +eval pkg_cmakedir=$libdir/cmake/SDL2_mixer +cmake_prefix_relpath="$(echo -n "$pkg_cmakedir" | sed -E "s#^$pkg_prefix##" | sed -E "s#[A-Za-z0-9_ .-]+#..#g")" +AC_SUBST([cmake_prefix_relpath]) + dnl Expand the sources and objects needed to build the library AC_SUBST(ac_aux_dir) AC_SUBST(OBJECTS) @@ -922,8 +969,29 @@ AC_SUBST(SDL_LIBS) AC_SUBST(PC_REQUIRES) AC_SUBST(PC_LIBS) +AC_SUBST(SDL2MIXER_CMD) +AC_SUBST(SDL2MIXER_FLAC_DRFLAC) +AC_SUBST(SDL2MIXER_FLAC_LIBFLAC) +AC_SUBST(SDL2MIXER_MOD_MODPLUG) +AC_SUBST(SDL2MIXER_MOD_XMP) +AC_SUBST(SDL2MIXER_MOD_XMP_LITE) +AC_SUBST(SDL2MIXER_MP3_DRMP3) +AC_SUBST(SDL2MIXER_MP3_MPG123) +AC_SUBST(SDL2MIXER_MIDI_FLUIDSYNTH) +AC_SUBST(SDL2MIXER_MIDI_NATIVE) +AC_SUBST(SDL2MIXER_MIDI_TIMIDITY) +AC_SUBST(SDL2MIXER_OPUS) +AC_SUBST(SDL2MIXER_VORBIS_STB) +AC_SUBST(SDL2MIXER_VORBIS_TREMOR) +AC_SUBST(SDL2MIXER_VORBIS_VORBISFILE) +AC_SUBST(SDL2MIXER_WAVE) + AC_CONFIG_FILES([ - Makefile SDL2_mixer.spec SDL2_mixer.pc +Makefile +SDL2_mixer.spec +SDL2_mixer.pc +sdl2_mixer-config.cmake +sdl2_mixer-config-version.cmake ]) AC_CONFIG_COMMANDS([default], [cat >>Makefile <<__EOF__ diff --git a/external/flac b/external/flac index ae6551da..7283eed5 160000 --- a/external/flac +++ b/external/flac @@ -1 +1 @@ -Subproject commit ae6551da0c7a7bda50d6642c4701f5559132697f +Subproject commit 7283eed5ea79635ba3f723175ef44c7ba3341463 diff --git a/external/ogg b/external/ogg index c8749966..790939ca 160000 --- a/external/ogg +++ b/external/ogg @@ -1 +1 @@ -Subproject commit c87499661ed3e3827c0fdfd012d4f61b87d4fa0e +Subproject commit 790939cacc9a571bd2d3ca6c8fd49ddce5435399 diff --git a/external/opusfile b/external/opusfile index 9ba5cc3d..b3f3d2c8 160000 --- a/external/opusfile +++ b/external/opusfile @@ -1 +1 @@ -Subproject commit 9ba5cc3dc920fb98f1b4068888d3c4e8617ef9b6 +Subproject commit b3f3d2c8977e506e0c673aee72b3901e4c3db8c7 diff --git a/external/tremor b/external/tremor index f6448ec8..7afc8484 160000 --- a/external/tremor +++ b/external/tremor @@ -1 +1 @@ -Subproject commit f6448ec8edaf3a516f82901de5cffb14fbcb287d +Subproject commit 7afc84841ffa2e9610b65950fd233e6c428699c7 diff --git a/mingw/pkg-support/cmake/sdl2_mixer-config-version.cmake b/mingw/pkg-support/cmake/sdl2_mixer-config-version.cmake new file mode 100644 index 00000000..da39d11f --- /dev/null +++ b/mingw/pkg-support/cmake/sdl2_mixer-config-version.cmake @@ -0,0 +1,19 @@ +# SDL2_mixer CMake version configuration file: +# This file is meant to be placed in a cmake subfolder of SDL2_mixer-devel-2.x.y-mingw + +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(sdl2_mixer_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL2_mixer/sdl2_mixer-config-version.cmake") +elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(sdl2_mixer_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL2_mixer/sdl2_mixer-config-version.cmake") +else("${CMAKE_SIZEOF_VOID_P}" STREQUAL "") + set(PACKAGE_VERSION_UNSUITABLE TRUE) + return() +endif() + +if(NOT EXISTS "${sdl2_mixer_config_path}") + message(WARNING "${sdl2_mixer_config_path} does not exist: MinGW development package is corrupted") + set(PACKAGE_VERSION_UNSUITABLE TRUE) + return() +endif() + +include("${sdl2_mixer_config_path}") diff --git a/mingw/pkg-support/cmake/sdl2_mixer-config.cmake b/mingw/pkg-support/cmake/sdl2_mixer-config.cmake new file mode 100644 index 00000000..c1f19fb7 --- /dev/null +++ b/mingw/pkg-support/cmake/sdl2_mixer-config.cmake @@ -0,0 +1,22 @@ +# SDL2_mixer CMake configuration file: +# This file is meant to be placed in a cmake subfolder of SDL2_mixer-devel-2.x.y-mingw + +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(sdl2_mixer_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL2_mixer/sdl2_mixer-config.cmake") +elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(sdl2_mixer_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL2_mixer/sdl2_mixer-config.cmake") +else("${CMAKE_SIZEOF_VOID_P}" STREQUAL "") + set(SDL2_mixer_FOUND FALSE) + return() +endif() + +if(NOT EXISTS "${sdl2_mixer_config_path}") + message(WARNING "${sdl2_mixer_config_path} does not exist: MinGW development package is corrupted") + set(SDL2_mixer_FOUND FALSE) + return() +endif() + +include("${sdl2_mixer_config_path}") + +# The SDL_mixer MinGW development package ships with vendored libraries +set(SDL2MIXER_VENDORED 1) diff --git a/sdl2_mixer-config-version.cmake.in b/sdl2_mixer-config-version.cmake.in new file mode 100644 index 00000000..70951516 --- /dev/null +++ b/sdl2_mixer-config-version.cmake.in @@ -0,0 +1,12 @@ +# sdl2_mixer cmake project-config-version input for ./configure scripts + +set(PACKAGE_VERSION "@MAJOR_VERSION@.@MINOR_VERSION@.@MICRO_VERSION@") + +if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/sdl2_mixer-config.cmake.in b/sdl2_mixer-config.cmake.in new file mode 100644 index 00000000..8211fa31 --- /dev/null +++ b/sdl2_mixer-config.cmake.in @@ -0,0 +1,145 @@ +# sdl2_mixer cmake project-config input for ./configure scripts + +include(FeatureSummary) +set_package_properties(SDL2_mixer PROPERTIES + URL "https://www.libsdl.org/projects/SDL_mixer/" + DESCRIPTION "SDL_mixer is a sample multi-channel audio mixer library" +) + +set(SDL2_mixer_FOUND TRUE) + +set(SDL2MIXER_VENDORED 0) + +set(SDL2MIXER_CMD @SDL2MIXER_CMD@) + +set(SDL2MIXER_FLAC_LIBFLAC @SDL2MIXER_FLAC_LIBFLAC@) +set(SDL2MIXER_FLAC_DRFLAC @SDL2MIXER_FLAC_DRFLAC@) +if(SDL2MIXER_FLAC_LIBFLAC OR SDL2MIXER_FLAC_DRFLAC) + set(SDL2MIXER_FLAC 1) +else() + set(SDL2MIXER_FLAC 0) +endif() + +set(SDL2MIXER_MOD_MODPLUG @SDL2MIXER_MOD_MODPLUG@) +set(SDL2MIXER_MOD_XMP @SDL2MIXER_MOD_XMP@) +set(SDL2MIXER_MOD_XMP_LITE @SDL2MIXER_MOD_XMP_LITE@) +if(SDL2MIXER_MOD_MODPLUG OR SDL2MIXER_MOD_XMP OR SDL2MIXER_MOD_XMP_LITE) + set(SDL2MIXER_MOD 1) +else() + set(SDL2MIXER_MOD 0) +endif() + +set(SDL2MIXER_MP3_DRMP3 @SDL2MIXER_MP3_DRMP3@) +set(SDL2MIXER_MP3_MPG123 @SDL2MIXER_MP3_MPG123@) +if(SDL2MIXER_MP3_DRMP3 OR SDL2MIXER_MP3_MPG123) + set(SDL2MIXER_MP3 1) +else() + set(SDL2MIXER_MP3 0) +endif() + +set(SDL2MIXER_MIDI_FLUIDSYNTH @SDL2MIXER_MIDI_FLUIDSYNTH@) +set(SDL2MIXER_MIDI_NATIVE @SDL2MIXER_MIDI_NATIVE@) +set(SDL2MIXER_MIDI_TIMIDITY @SDL2MIXER_MIDI_TIMIDITY@) +if(SDL2MIXER_MIDI_FLUIDSYNTH OR SDL2MIXER_MIDI_NATIVE OR SDL2MIXER_MIDI_TIMIDITY) + set(SDL2MIXER_MIDI 1) +else() + set(SDL2MIXER_MIDI 0) +endif() + +set(SDL2MIXER_OPUS @SDL2MIXER_OPUS@) + +set(SDL2MIXER_VORBIS) +set(SDL2MIXER_VORBIS_STB @SDL2MIXER_VORBIS_STB@) +set(SDL2MIXER_VORBIS_VORBISFILE @SDL2MIXER_VORBIS_VORBISFILE@) +set(SDL2MIXER_VORBIS_TREMOR @SDL2MIXER_VORBIS_TREMOR@) +if(SDL2MIXER_VORBIS_STB) + set(SDL2MIXER_VORBIS STB) +endif() +if(SDL2MIXER_VORBIS_VORBISFILE) + set(SDL2MIXER_VORBIS VORBISFILE) +endif() +if(SDL2MIXER_VORBIS_TREMOR) + set(SDL2MIXER_VORBIS TREMOR) +endif() + +set(SDL2MIXER_WAVE @SDL2MIXER_WAVE@) + +set(SDL2MIXER_SDL2_REQUIRED_VERSION @SDL_VERSION@) + +get_filename_component(prefix "${CMAKE_CURRENT_LIST_DIR}@cmake_prefix_relpath@" ABSOLUTE) +set(exec_prefix "@exec_prefix@") +set(bindir "@bindir@") +set(includedir "@includedir@") +set(libdir "@libdir@") +set(_sdl2mixer_extra_static_libraries "@PC_LIBS@") +string(STRIP "${_sdl2mixer_extra_static_libraries}" _sdl2mixer_extra_static_libraries) + +set(_sdl2mixer_bindir "${bindir}") +set(_sdl2mixer_libdir "${libdir}") +set(_sdl2mixer_incdir "${includedir}/SDL2") + +# Convert _sdl2mixer_extra_static_libraries to list and keep only libraries +string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._]+))|(-Wl,[^ ]*framework[^ ]*)" _sdl2mixer_extra_static_libraries "${_sdl2mixer_extra_static_libraries}") +string(REGEX REPLACE "^-l" "" _sdl2mixer_extra_static_libraries "${_sdl2mixer_extra_static_libraries}") +string(REGEX REPLACE ";-l" ";" _sdl2mixer_extra_static_libraries "${_sdl2mixer_extra_static_libraries}") + +unset(prefix) +unset(exec_prefix) +unset(bindir) +unset(includedir) +unset(libdir) + +include(CMakeFindDependencyMacro) + +if(NOT TARGET SDL2_mixer::SDL2_mixer) + if(WIN32) + set(_sdl2mixer_dll "${_sdl2mixer_bindir}/SDL2_mixer.dll") + set(_sdl2mixer_imp "${_sdl2mixer_libdir}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2_mixer.dll${CMAKE_STATIC_LIBRARY_SUFFIX}") + if(EXISTS "${_sdl2mixer_dll}" AND EXISTS "${_sdl2mixer_imp}") + add_library(SDL2_mixer::SDL2_mixer SHARED IMPORTED) + set_target_properties(SDL2_mixer::SDL2_mixer + PROPERTIES + IMPORTED_LOCATION "${_sdl2mixer_dll}" + IMPORTED_IMPLIB "${_sdl2mixer_imp}" + ) + endif() + unset(_sdl2mixer_dll) + unset(_sdl2mixer_imp) + else() + set(_sdl2mixer_shl "${_sdl2mixer_libdir}/${CMAKE_SHARED_LIBRARY_PREFIX}SDL2_mixer${CMAKE_SHARED_LIBRARY_SUFFIX}") + if(EXISTS "${_sdl2mixer_shl}") + add_library(SDL2_mixer::SDL2_mixer SHARED IMPORTED) + set_target_properties(SDL2_mixer::SDL2_mixer + PROPERTIES + IMPORTED_LOCATION "${_sdl2mixer_shl}" + ) + endif() + endif() + if(TARGET SDL2_mixer::SDL2_mixer) + set_target_properties(SDL2_mixer::SDL2_mixer + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_sdl2mixer_incdir}" + COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED" + INTERFACE_SDL2_SHARED "ON" + ) + endif() +endif() + +if(NOT TARGET SDL2_mixer::SDL2_mixer-static) + set(_sdl2mixer_stl "${_sdl2mixer_libdir}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2_mixer${CMAKE_STATIC_LIBRARY_SUFFIX}") + if(EXISTS "${_sdl2mixer_stl}") + add_library(SDL2_mixer::SDL2_mixer-static STATIC IMPORTED) + set_target_properties(SDL2_mixer::SDL2_mixer-static + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_sdl2mixer_incdir}" + IMPORTED_LOCATION "${_sdl2mixer_stl}" + INTERFACE_LINK_LIBRARIES "${_sdl2mixer_extra_static_libraries}" + ) + endif() + unset(_sdl2mixer_stl) +endif() + +unset(_sdl2mixer_extra_static_libraries) +unset(_sdl2mixer_bindir) +unset(_sdl2mixer_libdir) +unset(_sdl2mixer_incdir) diff --git a/src/codecs/music_cmd.c b/src/codecs/music_cmd.c index c80b6467..a293f92a 100644 --- a/src/codecs/music_cmd.c +++ b/src/codecs/music_cmd.c @@ -160,8 +160,10 @@ static int MusicCMD_Play(void *context, int play_count) music->play_count = play_count; #ifdef HAVE_FORK music->pid = fork(); -#else +#elif defined(HAVE_VFORK) music->pid = vfork(); +#else + music->pid = -1; #endif switch(music->pid) { /* Failed fork() system call */ diff --git a/test-versioning.sh b/test-versioning.sh index b7ff6533..b817133f 100755 --- a/test-versioning.sh +++ b/test-versioning.sh @@ -26,9 +26,10 @@ not_ok () { failed=1 } -major=$(sed -ne 's/^MAJOR_VERSION=//p' configure.ac) -minor=$(sed -ne 's/^MINOR_VERSION=//p' configure.ac) -micro=$(sed -ne 's/^MICRO_VERSION=//p' configure.ac) +major=$(sed -Ene 's/^m4_define\(\[MAJOR_VERSION_MACRO\], \[([0-9]*)\]\)$/\1/p' configure.ac) +minor=$(sed -Ene 's/^m4_define\(\[MINOR_VERSION_MACRO\], \[([0-9]*)\]\)$/\1/p' configure.ac) +micro=$(sed -Ene 's/^m4_define\(\[MICRO_VERSION_MACRO\], \[([0-9]*)\]\)$/\1/p' configure.ac) +ref_sdl_req=$(sed -ne 's/^SDL_VERSION=//p' configure.ac) version="${major}.${minor}.${micro}" if [ "$ref_version" = "$version" ]; then @@ -40,6 +41,7 @@ fi major=$(sed -ne 's/^set(MAJOR_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt) minor=$(sed -ne 's/^set(MINOR_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt) micro=$(sed -ne 's/^set(MICRO_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt) +sdl_req=$(sed -ne 's/^set(SDL_REQUIRED_VERSION \([0-9.]*\))$/\1/p' CMakeLists.txt) version="${major}.${minor}.${micro}" if [ "$ref_version" = "$version" ]; then @@ -48,6 +50,12 @@ else not_ok "CMakeLists.txt $version disagrees with SDL_mixer.h $ref_version" fi +if [ "$ref_sdl_req" = "$sdl_req" ]; then + ok "CMakeLists.txt $sdl_req" +else + not_ok "CMakeLists.txt SDL_REQUIRED_VERSION=$sdl_req disagrees with configure.ac SDL_VERSION=$ref_sdl_req" +fi + major=$(sed -ne 's/^MAJOR_VERSION *= *//p' Makefile.os2) minor=$(sed -ne 's/^MINOR_VERSION *= *//p' Makefile.os2) micro=$(sed -ne 's/^MICRO_VERSION *= *//p' Makefile.os2) @@ -144,5 +152,11 @@ else not_ok "project.pbxproj DYLIB_CURRENT_VERSION is inconsistent" fi +if [ "$ref_sdl_req" = "$sdl_req" ]; then + ok ".github/fetch_sdl_vc.ps1 $sdl_req" +else + not_ok ".github/fetch_sdl_vc.ps1 sdl2_version=$sdl_req disagrees with configure.ac SDL_VERSION=$ref_sdl_req" +fi + echo "1..$tests" exit "$failed"