cmake: make pkg-config optional

This commit is contained in:
derselbst 2017-08-28 20:03:42 +02:00
parent 597667b9c0
commit 3163300a9f
1 changed files with 105 additions and 79 deletions

View File

@ -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,7 +290,29 @@ if ( CMAKE_BUILD_TYPE MATCHES "Debug" )
set ( DEBUG 1 )
endif ( CMAKE_BUILD_TYPE MATCHES "Debug" )
# Mandatory tool: pkg-config
if(NOT enable-pkgconfig)
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} )
else(NOT enable-pkgconfig)
find_package ( PkgConfig REQUIRED )
# Mandatory libraries: glib and gthread
@ -312,11 +335,6 @@ else ( enable-libsndfile )
unset_pkg_config ( LIBSNDFILE_VORBIS )
endif ( enable-libsndfile )
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 )
@ -341,17 +359,6 @@ else ( enable-portaudio )
unset_pkg_config ( PORTAUDIO )
endif ( enable-portaudio )
find_package ( OSS QUIET )
set ( OSS_SUPPORT ${OSS_FOUND} )
unset ( MIDISHARE_SUPPORT CACHE )
if ( enable_midishare )
find_package ( MidiShare )
set ( MIDISHARE_SUPPORT ${MidiShare_FOUND} )
else ( enable_midishare )
unset ( MidiShare_LIBS CACHE )
endif ( enable_midishare )
unset ( JACK_SUPPORT CACHE )
if ( enable-jack )
pkg_check_modules ( JACK jack )
@ -360,18 +367,6 @@ else ( enable-jack )
unset_pkg_config ( JACK )
endif ( enable-jack )
unset ( WITH_READLINE CACHE )
if ( enable-readline )
find_package ( Readline )
set ( FOUND_READLINE ${HAVE_READLINE} )
if ( HAVE_READLINE )
set ( WITH_READLINE 1 )
set ( READLINE_LIBS ${READLINE_LIBRARIES} )
endif ( HAVE_READLINE )
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 )
@ -400,6 +395,37 @@ 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 )
find_package ( OSS QUIET )
set ( OSS_SUPPORT ${OSS_FOUND} )
unset ( MIDISHARE_SUPPORT CACHE )
if ( enable_midishare )
find_package ( MidiShare )
set ( MIDISHARE_SUPPORT ${MidiShare_FOUND} )
else ( enable_midishare )
unset ( MidiShare_LIBS CACHE )
endif ( enable_midishare )
unset ( WITH_READLINE CACHE )
if ( enable-readline )
find_package ( Readline )
set ( FOUND_READLINE ${HAVE_READLINE} )
if ( HAVE_READLINE )
set ( WITH_READLINE 1 )
set ( READLINE_LIBS ${READLINE_LIBRARIES} )
endif ( HAVE_READLINE )
else ( enable-readline )
unset ( READLINE_LIBS CACHE )
endif ( enable-readline )
# General configuration file
configure_file ( ${CMAKE_SOURCE_DIR}/src/config.cmake
${CMAKE_BINARY_DIR}/config.h )