diff --git a/libraries/zmusic/CMakeLists.txt b/libraries/zmusic/CMakeLists.txt index f7da61a5b6..dd30c8a7bc 100644 --- a/libraries/zmusic/CMakeLists.txt +++ b/libraries/zmusic/CMakeLists.txt @@ -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/.+") diff --git a/libraries/zmusic/mididevices/music_fluidsynth_mididevice.cpp b/libraries/zmusic/mididevices/music_fluidsynth_mididevice.cpp index 2021b7451d..6377e4b7d9 100644 --- a/libraries/zmusic/mididevices/music_fluidsynth_mididevice.cpp +++ b/libraries/zmusic/mididevices/music_fluidsynth_mididevice.cpp @@ -43,6 +43,8 @@ FluidConfig fluidConfig; +#ifdef HAVE_FLUIDSYNTH + #if !defined DYN_FLUIDSYNTH #include #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 diff --git a/libraries/zmusic/musicformats/music_midi.cpp b/libraries/zmusic/musicformats/music_midi.cpp index d01ff7ac9e..c76b13e4d1 100644 --- a/libraries/zmusic/musicformats/music_midi.cpp +++ b/libraries/zmusic/musicformats/music_midi.cpp @@ -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()); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a82fdd2d1e..1366aa53af 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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