Skip to content
Permalink
Browse files

- restored ability to link with thirdparty sound libraries explicitly

DYN_SNDFILE=NO and DYN_MPG123=NO were ignored while DYN_FLUIDSYNTH=NO broke compilation
These options should be applied to ZMusic target instead of the main executable
As a bonus, it's now possible to build GZDoom without FluidSynth
  • Loading branch information...
alexey-lysiuk committed Oct 3, 2019
1 parent ad3327b commit 1d9b5cb2395e18fe5a46c2e90f0315724425929f
@@ -21,20 +21,32 @@ endif()

if( DYN_SNDFILE)
add_definitions( -DHAVE_SNDFILE -DDYN_SNDFILE )
elseif( SNDFILE_FOUND )
add_definitions( -DHAVE_SNDFILE )
else()
find_package( SndFile )

if( SNDFILE_FOUND )
add_definitions( -DHAVE_SNDFILE )
endif()
endif()

if( DYN_MPG123)
add_definitions( -DHAVE_MPG123 -DDYN_MPG123 )
elseif( MPG123_FOUND )
add_definitions( -DHAVE_MPG123 )
else()
find_package( MPG123 )

if( MPG123_FOUND )
add_definitions( -DHAVE_MPG123 )
endif()
endif()

if( DYN_FLUIDSYNTH )
add_definitions( -DHAVE_FLUIDSYNTH -DDYN_FLUIDSYNTH )
elseif( FLUIDSYNTH_FOUND )
add_definitions( -DHAVE_FLUIDSYNTH )
else()
find_package( FluidSynth )

if( FLUIDSYNTH_FOUND )
add_definitions( -DHAVE_FLUIDSYNTH )
endif()
endif()


@@ -93,6 +105,20 @@ add_library( zmusic STATIC
)
target_link_libraries( zmusic adl dumb gme oplsynth opn timidity timidityplus wildmidi )

if( NOT DYN_SNDFILE AND SNDFILE_FOUND )
include_directories( "${SNDFILE_INCLUDE_DIRS}" )
target_link_libraries( zmusic ${SNDFILE_LIBRARIES} )
endif()

if( NOT DYN_MPG123 AND MPG123_FOUND )
include_directories( "${MPG123_INCLUDE_DIR}" )
target_link_libraries( zmusic ${MPG123_LIBRARIES} )
endif()

if( NOT DYN_FLUIDSYNTH AND FLUIDSYNTH_FOUND )
include_directories( "${FLUIDSYNTH_INCLUDE_DIR}" )
target_link_libraries( zmusic ${FLUIDSYNTH_LIBRARIES} )
endif()

source_group("MIDI Devices" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/mididevices/.+")
source_group("MIDI Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/midisources/.+")
@@ -43,6 +43,8 @@

FluidConfig fluidConfig;

#ifdef HAVE_FLUIDSYNTH

#if !defined DYN_FLUIDSYNTH
#include <fluidsynth.h>
#else
@@ -671,3 +673,5 @@ MIDIDevice *CreateFluidSynthMIDIDevice(int samplerate, const char *Args)
Fluid_SetupConfig(Args, fluid_patchset, true);
return new FluidSynthMIDIDevice(samplerate, fluid_patchset, musicCallbacks.Fluid_MessageFunc);
}

#endif // HAVE_FLUIDSYNTH
@@ -276,9 +276,11 @@ MIDIDevice *MIDIStreamer::CreateMIDIDevice(EMidiDevice devtype, int samplerate)
#endif
// Intentional fall-through for non-Windows systems.

#ifdef HAVE_FLUIDSYNTH
case MDEV_FLUIDSYNTH:
dev = CreateFluidSynthMIDIDevice(samplerate, Args.c_str());
break;
#endif // HAVE_FLUIDSYNTH

case MDEV_OPL:
dev = CreateOplMIDIDevice(Args.c_str());
@@ -204,27 +204,8 @@ endif()

if( NO_OPENAL )
add_definitions( -DNO_OPENAL=1 )

set(MPG123_FOUND NO)
set(SNDFILE_FOUND NO)
else()
# Search for libSndFile

if ( NOT DYN_SNDFILE )
find_package( SndFile )
endif()

# Search for libmpg123

if ( NOT DYN_MPG123 )
find_package( MPG123 )
endif()
endif()

# Search for FluidSynth

find_package( FluidSynth )

# Decide on SSE setup

set( SSE_MATTERS NO )
@@ -458,7 +439,6 @@ add_custom_target( revision_check ALL

# Libraries ZDoom needs

message( STATUS "Fluid synth libs: ${FLUIDSYNTH_LIBRARIES}" )
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_LIBRARIES}" "${GME_LIBRARIES}" "${CMAKE_DL_LIBS}" )
if (HAVE_VULKAN)
set( ZDOOM_LIBS ${ZDOOM_LIBS} "glslang" "SPIRV" "OGLCompiler")
@@ -471,21 +451,6 @@ if( ${HAVE_VM_JIT} )
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${ASMJIT_LIBRARIES}")
endif()

if( SNDFILE_FOUND )
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${SNDFILE_LIBRARIES}" )
include_directories( "${SNDFILE_INCLUDE_DIRS}" )
endif()
if( MPG123_FOUND )
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${MPG123_LIBRARIES}" )
include_directories( "${MPG123_INCLUDE_DIR}" )
endif()
if( NOT DYN_FLUIDSYNTH )
if( FLUIDSYNTH_FOUND )
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${FLUIDSYNTH_LIBRARIES}" )
include_directories( "${FLUIDSYNTH_INCLUDE_DIR}" )
endif()
endif()

# Start defining source files for ZDoom
set( PLAT_WIN32_SOURCES
win32/hardware.cpp

0 comments on commit 1d9b5cb

Please sign in to comment.
You can’t perform that action at this time.