Added SDL Mixer X to CMAKE (Windows only)

This commit is contained in:
mazmazz 2020-06-06 22:05:25 -04:00
parent d2fefb6b9a
commit a449fa4a1d
2 changed files with 51 additions and 2 deletions

View file

@ -226,6 +226,12 @@ set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL
"Enable GME support.") "Enable GME support.")
set(SRB2_CONFIG_HAVE_OPENMPT ON CACHE BOOL set(SRB2_CONFIG_HAVE_OPENMPT ON CACHE BOOL
"Enable OpenMPT support.") "Enable OpenMPT support.")
if(${CMAKE_SYSTEM} MATCHES Windows)
set(SRB2_CONFIG_HAVE_MIXERX ON CACHE BOOL
"Enable SDL Mixer X support.")
else()
set(SRB2_CONFIG_HAVE_MIXERX OFF)
endif()
set(SRB2_CONFIG_HWRENDER ON CACHE BOOL set(SRB2_CONFIG_HWRENDER ON CACHE BOOL
"Enable hardware rendering through OpenGL.") "Enable hardware rendering through OpenGL.")
set(SRB2_CONFIG_USEASM OFF CACHE BOOL set(SRB2_CONFIG_USEASM OFF CACHE BOOL
@ -366,6 +372,30 @@ if(${SRB2_CONFIG_HAVE_OPENMPT})
endif() endif()
endif() endif()
if(${SRB2_CONFIG_HAVE_MIXERX})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(MIXERX_FOUND ON)
set(MIXERX_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/include/SDL2)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(MIXERX_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDLMixerX/x86_64-w64-mingw32/lib -lSDL2_mixer_ext")
else() # 32-bit
set(MIXERX_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/lib -lSDL2_mixer_ext")
endif()
else()
# No support for non-Windows (yet?)
#find_package(MIXERX)
message(WARNING "SDL Mixer X is not supported as an external library.")
set(MIXERX_FOUND OFF)
endif()
if(${MIXERX_FOUND})
set(SRB2_HAVE_MIXERX ON)
set(SRB2_SDL2_SOUNDIMPL mixer_sound.c)
add_definitions(-DHAVE_MIXERX)
else()
message(WARNING "You have specified that SDL Mixer X is available but it was not found.")
endif()
endif()
if(${SRB2_CONFIG_HAVE_ZLIB}) if(${SRB2_CONFIG_HAVE_ZLIB})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(ZLIB_FOUND ON) set(ZLIB_FOUND ON)

View file

@ -1,6 +1,10 @@
# Declare SDL2 interface sources # Declare SDL2 interface sources
set(SRB2_CONFIG_SDL2_USEMIXER ON CACHE BOOL "Use SDL2_mixer or regular sdl sound") if(NOT ${SRB2_CONFIG_HAVE_MIXERX})
set(SRB2_CONFIG_SDL2_USEMIXER ON CACHE BOOL "Use SDL2_mixer or regular sdl sound")
else()
set(SRB2_CONFIG_SDL2_USEMIXER OFF)
endif()
if(${SRB2_CONFIG_SDL2_USEMIXER}) if(${SRB2_CONFIG_SDL2_USEMIXER})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
@ -22,6 +26,8 @@ if(${SRB2_CONFIG_SDL2_USEMIXER})
message(WARNING "You specified that SDL2_mixer is available, but it was not found. Falling back to sdl sound.") message(WARNING "You specified that SDL2_mixer is available, but it was not found. Falling back to sdl sound.")
set(SRB2_SDL2_SOUNDIMPL sdl_sound.c) set(SRB2_SDL2_SOUNDIMPL sdl_sound.c)
endif() endif()
elseif(${MIXERX_FOUND})
set(SRB2_SDL2_SOUNDIMPL mixer_sound.c)
else() else()
set(SRB2_SDL2_SOUNDIMPL sdl_sound.c) set(SRB2_SDL2_SOUNDIMPL sdl_sound.c)
endif() endif()
@ -156,6 +162,7 @@ if(${SDL2_FOUND})
SDL2_mixer SDL2_mixer
${GME_LIBRARIES} ${GME_LIBRARIES}
${OPENMPT_LIBRARIES} ${OPENMPT_LIBRARIES}
${MIXERX_LIBRARIES}
${PNG_LIBRARIES} ${PNG_LIBRARIES}
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
${OPENGL_LIBRARIES} ${OPENGL_LIBRARIES}
@ -167,6 +174,7 @@ if(${SDL2_FOUND})
${SDL2_MIXER_LIBRARIES} ${SDL2_MIXER_LIBRARIES}
${GME_LIBRARIES} ${GME_LIBRARIES}
${OPENMPT_LIBRARIES} ${OPENMPT_LIBRARIES}
${MIXERX_LIBRARIES}
${PNG_LIBRARIES} ${PNG_LIBRARIES}
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
${OPENGL_LIBRARIES} ${OPENGL_LIBRARIES}
@ -247,12 +255,13 @@ if(${SDL2_FOUND})
${SDL2_MIXER_INCLUDE_DIRS} ${SDL2_MIXER_INCLUDE_DIRS}
${GME_INCLUDE_DIRS} ${GME_INCLUDE_DIRS}
${OPENMPT_INCLUDE_DIRS} ${OPENMPT_INCLUDE_DIRS}
${MIXERX_INCLUDE_DIRS}
${PNG_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}
${OPENGL_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIRS}
) )
if(${SRB2_HAVE_MIXER}) if((${SRB2_HAVE_MIXER}) OR (${SRB2_HAVE_MIXERX}))
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER) target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER)
endif() endif()
@ -294,6 +303,7 @@ if(${SDL2_FOUND})
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/bin HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/bin
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/x86_64-w64-mingw32/bin HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/x86_64-w64-mingw32/bin
HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86_64/mingw HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86_64/mingw
HINTS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/x86_64-w64-mingw32/bin
) )
else() else()
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}" find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}"
@ -301,6 +311,7 @@ if(${SDL2_FOUND})
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/bin HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/bin
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/i686-w64-mingw32/bin HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/i686-w64-mingw32/bin
HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86/mingw HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86/mingw
HINTS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/bin
) )
endif() endif()
else() else()
@ -310,6 +321,7 @@ if(${SDL2_FOUND})
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x64 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x64
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x64 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x64
HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86_64/mingw HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86_64/mingw
HINTS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/x86_64-w64-mingw32/bin
) )
else() else()
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}" find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}"
@ -317,6 +329,7 @@ if(${SDL2_FOUND})
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x86 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x86
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x86 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x86
HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86/mingw HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86/mingw
HINTS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/bin
) )
endif() endif()
endif() endif()
@ -340,6 +353,12 @@ if(${SDL2_FOUND})
if(${SRB2_CONFIG_HAVE_OPENMPT}) if(${SRB2_CONFIG_HAVE_OPENMPT})
getwinlib(libopenmpt "libopenmpt.dll") getwinlib(libopenmpt "libopenmpt.dll")
endif() endif()
if(${SRB2_CONFIG_HAVE_MIXERX})
getwinlib(SDL2_mixer_ext "SDL2_mixer_ext.dll")
getwinlib(libfluidsynth-2 "libfluidsynth-2.dll")
getwinlib(libgcc_s_sjlj-1 "libgcc_s_sjlj-1.dll")
getwinlib(libstdc++-6 "libstdc++-6.dll")
endif()
install(PROGRAMS install(PROGRAMS
${win_extra_dll_list} ${win_extra_dll_list}