- 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
This commit is contained in:
alexey.lysiuk 2019-10-03 12:22:46 +03:00
parent ad3327bdf5
commit 1d9b5cb239
4 changed files with 38 additions and 41 deletions

View file

@ -21,21 +21,33 @@ endif()
if( DYN_SNDFILE)
add_definitions( -DHAVE_SNDFILE -DDYN_SNDFILE )
elseif( SNDFILE_FOUND )
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 )
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 )
else()
find_package( FluidSynth )
if( FLUIDSYNTH_FOUND )
add_definitions( -DHAVE_FLUIDSYNTH )
endif()
endif()
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/../libraries/dumb/include" "${ZLIB_INCLUDE_DIR}" "${ADL_INCLUDE_DIR}" "${OPN_INCLUDE_DIR}" "${TIMIDITYPP_INCLUDE_DIR}" "${TIMIDITY_INCLUDE_DIR}" "${WILDMIDI_INCLUDE_DIR}" "${OPLSYNTH_INCLUDE_DIR}" "${GME_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" )
@ -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/.+")

View file

@ -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

View file

@ -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());

View file

@ -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