Load fluidsynth entrypoints dynamically (and make them optional)

This removes the static dependency on fluidsynth being present
at buildtime (even headers aren't needed anymore).

Even though midi is a default format for the RPG XP/VX series,
it has fallen more and more out of use, with VX Ace completely
abandoning it from the RTP and making ogg vorbis the de facto
standard. Midi support is kept for legacy reasons, but isn't
encouraged. On top of all this, fluidsynth together with glib
is a heavy dependency that often times won't even be used.
Making it optional at build time is an attempt to unify and
keep build config fragmentation low.

In RGSS3, fluidsynth / midi is not initialized at all by
default, but rather on demand when either a midi track is
played back or Audio.setup_midi is called.
This commit is contained in:
Jonas Kulla 2014-09-07 05:23:10 +02:00
parent 673a25f811
commit 757a1d5e39
13 changed files with 223 additions and 120 deletions

View file

@ -3,7 +3,7 @@ Project(mkxp)
## Setup options ##
option(MIDI "Enable midi support" ON)
option(SHARED_FLUID "Dynamically link fluidsynth at build time" OFF)
option(WORKDIR_CURRENT "Keep current directory on startup" OFF)
option(FORCE32 "Force 32bit compile on 64bit OS" OFF)
set(BINDING "MRI" CACHE STRING "The Binding Type (MRI, MRUBY, NULL)")
@ -151,6 +151,8 @@ set(MAIN_HEADERS
src/windowvx.h
src/tilemapvx.h
src/tileatlasvx.h
src/sharedmidistate.h
src/fluid-fun.h
)
set(MAIN_SOURCE
@ -193,6 +195,8 @@ set(MAIN_SOURCE
src/tilemapvx.cpp
src/tileatlasvx.cpp
src/autotilesvx.cpp
src/midisource.cpp
src/fluid-fun.cpp
)
source_group("MKXP Source" FILES ${MAIN_SOURCE} ${MAIN_HEADERS})
@ -227,16 +231,10 @@ if (RGSS2)
)
endif()
if (MIDI)
pkg_check_modules(MIDI REQUIRED fluidsynth)
if (SHARED_FLUID)
pkg_check_modules(FLUID REQUIRED fluidsynth)
list(APPEND DEFINES
MIDI
)
list(APPEND MAIN_HEADERS
src/sharedmidistate.h
)
list(APPEND MAIN_SOURCE
src/midisource.cpp
SHARED_FLUID
)
endif()
@ -400,7 +398,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE
${Boost_INCLUDE_DIR}
${MRI_INCLUDE_DIRS}
${VORBISFILE_INCLUDE_DIRS}
${MIDI_INCLUDE_DIRS}
${FLUID_INCLUDE_DIRS}
${OPENAL_INCLUDE_DIR}
)
@ -415,7 +413,7 @@ target_link_libraries(${PROJECT_NAME}
${Boost_LIBRARIES}
${MRI_LIBRARIES}
${VORBISFILE_LIBRARIES}
${MIDI_LIBRARIES}
${FLUID_LIBRARIES}
${OPENAL_LIBRARY}
${ZLIB_LIBRARY}