diff --git a/fluidsynth/CMakeLists.txt b/fluidsynth/CMakeLists.txt index be57479b..2b787e87 100644 --- a/fluidsynth/CMakeLists.txt +++ b/fluidsynth/CMakeLists.txt @@ -58,6 +58,7 @@ option ( enable-fpe-check "enable Floating Point Exception checks and debug mess option ( enable-debug "enable debugging (default=no)" off ) # Options enabled by default +option ( enable-pkgconfig "use pkg-config to locate fluidsynth's (mostly optional) dependencies" on ) option ( enable-libsndfile "compile libsndfile support (if it is available)" on ) option ( enable-aufile "compile support for sound file output" on ) option ( enable-pulseaudio "compile PulseAudio support (if it is available)" on ) @@ -160,8 +161,8 @@ if ( WIN32 ) check_include_files ( "windows.h;mmsystem.h" HAVE_MMSYSTEM_H ) set ( WINDOWS_SUPPORT ${HAVE_WINDOWS_H} ) set ( WINDOWS_LIBS "dsound;winmm;ws2_32" ) - set ( LIBFLUID_CPPFLAGS "-DFLUIDSYNTH_DLL_EXPORTS" ) set ( FLUID_CPPFLAGS "-DFLUIDSYNTH_NOT_A_DLL" ) + set ( LIBFLUID_CPPFLAGS "${FLUID_CPPFLAGS} -DFLUIDSYNTH_DLL_EXPORTS" ) set ( CMAKE_DEBUG_POSTFIX "_debug" ) # MinGW compiler (a Windows GCC port) if ( MINGW ) @@ -289,58 +290,118 @@ if ( CMAKE_BUILD_TYPE MATCHES "Debug" ) set ( DEBUG 1 ) endif ( CMAKE_BUILD_TYPE MATCHES "Debug" ) -# Mandatory tool: pkg-config -find_package ( PkgConfig REQUIRED ) -# Mandatory libraries: glib and gthread -pkg_check_modules ( GLIB REQUIRED glib-2.0>=2.6.5 gthread-2.0>=2.6.5 ) +if(NOT enable-pkgconfig) -include ( UnsetPkgConfig ) + FIND_LIBRARY( GLIB_LIB NAMES glib glib-2.0 PATH GLIB_LIBRARY_DIR NO_DEFAULT_PATH) + FIND_LIBRARY( GTHREAD_LIB NAMES gthread gthread-2.0 PATH GTHREAD_LIBRARY_DIR NO_DEFAULT_PATH ) + FIND_PATH( GLIBH_DIR glib.h PATH GLIB_INCLUDE_DIR NO_DEFAULT_PATH ) + FIND_PATH( GLIBCONF_DIR glibconfig.h PATH GLIBCONF_INCLUDE_DIR NO_DEFAULT_PATH ) + + IF( GLIB_LIB MATCHES "GLIB_LIB-NOTFOUND" OR + GTHREAD_LIB MATCHES "GTHREAD_LIB-NOTFOUND" OR + GLIBH_DIR MATCHES "GLIBH_DIR-NOTFOUND" OR + GLIBCONF_DIR MATCHES "GLIBCONF_DIR-NOTFOUND") + message( WARNING "Not sure if I found GLIB, continuing anyway.") + ENDIF() + + SET( GLIB_INCLUDE_DIRS ${GLIBH_DIR} ${GLIBCONF_DIR} ) + SET( GLIB_LIBRARIES ${GLIB_LIB} ${GTHREAD_LIB} ) + + message( STATUS "GLIB_INCLUDE_DIRS: " ${GLIB_INCLUDE_DIRS} ) + message( STATUS "GLIB_LIBRARIES: " ${GLIB_LIBRARIES} ) -# Optional features -unset ( LIBSNDFILE_SUPPORT CACHE ) -unset ( LIBSNDFILE_HASVORBIS CACHE ) -if ( enable-libsndfile ) - pkg_check_modules ( LIBSNDFILE sndfile>=1.0.0 ) - set ( LIBSNDFILE_SUPPORT ${LIBSNDFILE_FOUND} ) - if ( LIBSNDFILE_SUPPORT ) - pkg_check_modules ( LIBSNDFILE_VORBIS sndfile>=1.0.18 ) - set ( LIBSNDFILE_HASVORBIS ${LIBSNDFILE_VORBIS_FOUND} ) - endif ( LIBSNDFILE_SUPPORT ) -else ( enable-libsndfile ) - unset_pkg_config ( LIBSNDFILE ) - unset_pkg_config ( LIBSNDFILE_VORBIS ) -endif ( enable-libsndfile ) +else(NOT enable-pkgconfig) + + find_package ( PkgConfig REQUIRED ) + + # Mandatory libraries: glib and gthread + pkg_check_modules ( GLIB REQUIRED glib-2.0>=2.6.5 gthread-2.0>=2.6.5 ) + + include ( UnsetPkgConfig ) + + # Optional features + unset ( LIBSNDFILE_SUPPORT CACHE ) + unset ( LIBSNDFILE_HASVORBIS CACHE ) + if ( enable-libsndfile ) + pkg_check_modules ( LIBSNDFILE sndfile>=1.0.0 ) + set ( LIBSNDFILE_SUPPORT ${LIBSNDFILE_FOUND} ) + if ( LIBSNDFILE_SUPPORT ) + pkg_check_modules ( LIBSNDFILE_VORBIS sndfile>=1.0.18 ) + set ( LIBSNDFILE_HASVORBIS ${LIBSNDFILE_VORBIS_FOUND} ) + endif ( LIBSNDFILE_SUPPORT ) + else ( enable-libsndfile ) + unset_pkg_config ( LIBSNDFILE ) + unset_pkg_config ( LIBSNDFILE_VORBIS ) + endif ( enable-libsndfile ) + + unset ( PULSE_SUPPORT CACHE ) + if ( enable-pulseaudio ) + pkg_check_modules ( PULSE libpulse-simple>=0.9.8 ) + set ( PULSE_SUPPORT ${PULSE_FOUND} ) + else ( enable-pulseaudio ) + unset_pkg_config ( PULSE ) + endif ( enable-pulseaudio ) + + unset ( ALSA_SUPPORT CACHE ) + if ( enable-alsa ) + pkg_check_modules ( ALSA alsa>=0.9.1 ) + set ( ALSA_SUPPORT ${ALSA_FOUND} ) + else ( enable-alsa ) + unset_pkg_config ( ALSA ) + endif ( enable-alsa ) + + unset ( PORTAUDIO_SUPPORT CACHE ) + if ( enable-portaudio ) + pkg_check_modules ( PORTAUDIO portaudio-2.0>=19 ) + set ( PORTAUDIO_SUPPORT ${PORTAUDIO_FOUND} ) + else ( enable-portaudio ) + unset_pkg_config ( PORTAUDIO ) + endif ( enable-portaudio ) + + unset ( JACK_SUPPORT CACHE ) + if ( enable-jack ) + pkg_check_modules ( JACK jack ) + set ( JACK_SUPPORT ${JACK_FOUND} ) + else ( enable-jack ) + unset_pkg_config ( JACK ) + endif ( enable-jack ) + + unset ( LASH_SUPPORT CACHE ) + if ( enable-lash ) + pkg_check_modules ( LASH lash-1.0>=0.3 ) + if ( LASH_FOUND ) + set ( LASH_SUPPORT 1 ) + add_definitions ( -DHAVE_LASH ) + endif ( LASH_FOUND ) + else ( enable-lash ) + unset_pkg_config ( LASH ) + remove_definitions( -DHAVE_LASH ) + endif ( enable-lash ) + + unset ( LADCCA_SUPPORT CACHE ) + if ( enable-ladcca ) + pkg_check_modules ( LADCCA ladcca-1.0>=0.3 ) + set ( LADCCA_SUPPORT ${LADCCA_FOUND} ) + else ( enable-ladcca ) + unset_pkg_config ( LADCCA ) + endif ( enable-ladcca ) + + unset ( DBUS_SUPPORT CACHE ) + if ( enable-dbus ) + pkg_check_modules ( DBUS dbus-1>=1.0.0 ) + set ( DBUS_SUPPORT ${DBUS_FOUND} ) + else ( enable-dbus ) + unset_pkg_config ( DBUS ) + endif ( enable-dbus ) + +endif(NOT enable-pkgconfig) unset ( AUFILE_SUPPORT CACHE ) if ( enable-aufile ) set ( AUFILE_SUPPORT 1 ) endif ( enable-aufile ) -unset ( PULSE_SUPPORT CACHE ) -if ( enable-pulseaudio ) - pkg_check_modules ( PULSE libpulse-simple>=0.9.8 ) - set ( PULSE_SUPPORT ${PULSE_FOUND} ) -else ( enable-pulseaudio ) - unset_pkg_config ( PULSE ) -endif ( enable-pulseaudio ) - -unset ( ALSA_SUPPORT CACHE ) -if ( enable-alsa ) - pkg_check_modules ( ALSA alsa>=0.9.1 ) - set ( ALSA_SUPPORT ${ALSA_FOUND} ) -else ( enable-alsa ) - unset_pkg_config ( ALSA ) -endif ( enable-alsa ) - -unset ( PORTAUDIO_SUPPORT CACHE ) -if ( enable-portaudio ) - pkg_check_modules ( PORTAUDIO portaudio-2.0>=19 ) - set ( PORTAUDIO_SUPPORT ${PORTAUDIO_FOUND} ) -else ( enable-portaudio ) - unset_pkg_config ( PORTAUDIO ) -endif ( enable-portaudio ) - find_package ( OSS QUIET ) set ( OSS_SUPPORT ${OSS_FOUND} ) @@ -352,14 +413,6 @@ else ( enable_midishare ) unset ( MidiShare_LIBS CACHE ) endif ( enable_midishare ) -unset ( JACK_SUPPORT CACHE ) -if ( enable-jack ) - pkg_check_modules ( JACK jack ) - set ( JACK_SUPPORT ${JACK_FOUND} ) -else ( enable-jack ) - unset_pkg_config ( JACK ) -endif ( enable-jack ) - unset ( WITH_READLINE CACHE ) if ( enable-readline ) find_package ( Readline ) @@ -372,33 +425,6 @@ else ( enable-readline ) unset ( READLINE_LIBS CACHE ) endif ( enable-readline ) -unset ( LASH_SUPPORT CACHE ) -if ( enable-lash ) - pkg_check_modules ( LASH lash-1.0>=0.3 ) - if ( LASH_FOUND ) - set ( LASH_SUPPORT 1 ) - add_definitions ( -DHAVE_LASH ) - endif ( LASH_FOUND ) -else ( enable-lash ) - unset_pkg_config ( LASH ) - remove_definitions( -DHAVE_LASH ) -endif ( enable-lash ) - -unset ( LADCCA_SUPPORT CACHE ) -if ( enable-ladcca ) - pkg_check_modules ( LADCCA ladcca-1.0>=0.3 ) - set ( LADCCA_SUPPORT ${LADCCA_FOUND} ) -else ( enable-ladcca ) - unset_pkg_config ( LADCCA ) -endif ( enable-ladcca ) - -unset ( DBUS_SUPPORT CACHE ) -if ( enable-dbus ) - pkg_check_modules ( DBUS dbus-1>=1.0.0 ) - set ( DBUS_SUPPORT ${DBUS_FOUND} ) -else ( enable-dbus ) - unset_pkg_config ( DBUS ) -endif ( enable-dbus ) # General configuration file configure_file ( ${CMAKE_SOURCE_DIR}/src/config.cmake