From daa2112adff95f4e248c810d6a5f7180bab03949 Mon Sep 17 00:00:00 2001 From: StarManiaKG Date: Thu, 21 Mar 2024 22:36:39 -0400 Subject: [PATCH] Compiler improvements 3 --- cmake/Modules/FindMIXERX.cmake | 34 ++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 22 ++++++++++++++++++++++ src/sdl/mixer_sound.c | 4 ++-- 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 cmake/Modules/FindMIXERX.cmake diff --git a/cmake/Modules/FindMIXERX.cmake b/cmake/Modules/FindMIXERX.cmake new file mode 100644 index 000000000..926765fd1 --- /dev/null +++ b/cmake/Modules/FindMIXERX.cmake @@ -0,0 +1,34 @@ +# Find SDL2_MixerX +# Once done, this will define +# +# SDL2_MIXERX_FOUND - system has SDL2_MixerX +# SDL2_MIXERX_INCLUDE_DIRS - SDL2_MixerX include directories +# SDL2_MIXERX_LIBRARIES - link libraries + +include(LibFindMacros) + +libfind_pkg_check_modules(SDL2_MIXERX_PKGCONF SDL2_mixerx) + +# includes +find_path(SDL2_MIXERX_INCLUDE_DIR + NAMES SDL_mixer_ext.h + PATHS + ${SDL2_MIXERX_PKGCONF_INCLUDE_DIRS} + "/usr/include/SDL2" + "/usr/local/include/SDL2" +) + +# library +find_library(SDL2_MIXERX_LIBRARY + NAMES SDL2_mixer_ext + PATHS + ${SDL2_MIXERX_PKGCONF_LIBRARY_DIRS} + "/usr/lib" + "/usr/local/lib" +) + + +# set include dir variables +set(SDL2_MIXERX_PROCESS_INCLUDES SDL2_MIXERX_INCLUDE_DIR) +set(SDL2_MIXERX_PROCESS_LIBS SDL2_MIXERX_LIBRARY) +libfind_process(MIXERX) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 20caecf7b..f10f54ad2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -204,6 +204,28 @@ if("${SRB2_CONFIG_HWRENDER}") endif() endif() +if("${SRB2_CONFIG_HAVE_MIXERX}") + if("${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}") + set(MIXERX_FOUND ON) + if(${SRB2_SYSTEM_BITS} EQUAL 64) + set(MIXERX_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/x86_64-w64-mingw32/include/SDL2) + set(MIXERX_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDLMixerX/x86_64-w64-mingw32/lib -lSDL2_mixer_ext") + else() # 32-bit + set(MIXERX_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/include/SDL2) + set(MIXERX_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/lib -lSDL2_mixer_ext") + endif() + else() + find_package(MIXERX) + endif() + + if(${MIXERX_FOUND}) + set(SRB2_HAVE_MIXERX ON) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXERX) + else() + message(WARNING "You have specified that SDL Mixer X is available but it was not found.") + endif() +endif() + # Targets # If using CCACHE, then force it. diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 5f3d488f8..2e76d8144 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -713,7 +713,7 @@ void I_SetSfxVolume(UINT8 volume) static UINT32 get_real_volume(UINT8 volume) { #if defined (HAVE_MIXERX) && (_WIN32) -#if !defined(SDL_MIXER_VERSION_ATLEAST(2,6,0)) // StarManiaKG: recent SDL_Mixer_X builds fix whatever issue was here, apparently :p // +#ifndef SDL_MIXER_VERSION_ATLEAST(2,6,0) // StarManiaKG: recent SDL_Mixer_X builds fix whatever issue was here, apparently :p // if (I_SongType() == MU_MID) // HACK: Until we stop using native MIDI, // disable volume changes @@ -1610,7 +1610,7 @@ void I_SetMusicVolume(UINT8 volume) return; #if defined (HAVE_MIXERX) && (_WIN32) -#if !defined(SDL_MIXER_VERSION_ATLEAST(2,6,0)) // StarManiaKG: recent SDL_Mixer_X builds fix whatever issue was here, apparently :p // +#ifndef SDL_MIXER_VERSION_ATLEAST(2,6,0) // StarManiaKG: recent SDL_Mixer_X builds fix whatever issue was here, apparently :p // if (I_SongType() == MU_MID) // HACK: Until we stop using native MIDI, // disable volume changes