mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-02-26 05:40:49 +00:00
CMake build system fix: unset the variables created by check_pkg_modules() allowing to disable optional features that were formerly enabled
New macro: unset_pkg_config() The unset() command requires CMake 2.6.3 or newer
This commit is contained in:
parent
a4e04f982a
commit
e6eeb05b28
4 changed files with 95 additions and 65 deletions
|
@ -20,7 +20,7 @@
|
|||
# CMake based build system. Pedro Lopez-Cabanillas <plcl@users.sf.net>
|
||||
|
||||
project ( FluidSynth C )
|
||||
cmake_minimum_required ( VERSION 2.6 )
|
||||
cmake_minimum_required ( VERSION 2.6.3 )
|
||||
set ( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_admin )
|
||||
|
||||
# FluidSynth package name
|
||||
|
@ -122,10 +122,10 @@ include ( TestVLA )
|
|||
include ( TestBigEndian )
|
||||
test_big_endian ( WORDS_BIGENDIAN )
|
||||
|
||||
set ( LIBFLUID_CPPFLAGS )
|
||||
set ( LIBFLUID_LIBS )
|
||||
set ( FLUID_CPPFLAGS )
|
||||
set ( FLUID_LIBS )
|
||||
unset ( LIBFLUID_CPPFLAGS CACHE )
|
||||
unset ( LIBFLUID_LIBS CACHE )
|
||||
unset ( FLUID_CPPFLAGS CACHE )
|
||||
unset ( FLUID_LIBS CACHE )
|
||||
|
||||
# Options for the GNU C compiler only
|
||||
if ( CMAKE_COMPILER_IS_GNUCC )
|
||||
|
@ -142,9 +142,9 @@ if ( CMAKE_COMPILER_IS_GNUCC )
|
|||
endif ( CMAKE_COMPILER_IS_GNUCC )
|
||||
|
||||
# Windows
|
||||
set ( WINDOWS_SUPPORT )
|
||||
set ( WINDOWS_LIBS )
|
||||
set ( MINGW32 )
|
||||
unset ( WINDOWS_SUPPORT CACHE )
|
||||
unset ( WINDOWS_LIBS CACHE )
|
||||
unset ( MINGW32 CACHE )
|
||||
if ( WIN32 )
|
||||
include ( CheckIncludeFiles )
|
||||
check_include_file ( windows.h HAVE_WINDOWS_H )
|
||||
|
@ -169,15 +169,16 @@ else ( WIN32 )
|
|||
endif ( WIN32 )
|
||||
|
||||
# IBM OS/2
|
||||
set ( DART_SUPPORT )
|
||||
set ( DART_LIBS )
|
||||
unset ( DART_SUPPORT CACHE )
|
||||
unset ( DART_LIBS CACHE )
|
||||
unset ( DART_INCLUDE_DIRS CACHE )
|
||||
if ( ${CMAKE_SYSTEM} MATCHES "os2" )
|
||||
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Zbin-files" )
|
||||
set ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Zbin-files -no-undefined" )
|
||||
if ( enable-dart )
|
||||
check_include_file ( os2me.h HAVE_DART_H )
|
||||
set ( DART_SUPPORT ${HAVE_DART_H} )
|
||||
set ( DART_INCLUDE_DIRS )
|
||||
unset ( DART_INCLUDE_DIRS CACHE )
|
||||
endif ( enable-dart )
|
||||
endif ( ${CMAKE_SYSTEM} MATCHES "os2" )
|
||||
|
||||
|
@ -188,12 +189,12 @@ if ( ${CMAKE_SYSTEM} MATCHES "SunOS" )
|
|||
endif ( ${CMAKE_SYSTEM} MATCHES "SunOS" )
|
||||
|
||||
# Apple Mac OSX
|
||||
set ( COREAUDIO_SUPPORT )
|
||||
set ( COREAUDIO_LIBS )
|
||||
set ( COREMIDI_SUPPORT )
|
||||
set ( COREMIDI_LIBS )
|
||||
set ( DARWIN )
|
||||
set ( MACOSX_FRAMEWORK )
|
||||
unset ( COREAUDIO_SUPPORT CACHE )
|
||||
unset ( COREAUDIO_LIBS CACHE )
|
||||
unset ( COREMIDI_SUPPORT CACHE )
|
||||
unset ( COREMIDI_LIBS CACHE )
|
||||
unset ( DARWIN CACHE )
|
||||
unset ( MACOSX_FRAMEWORK CACHE )
|
||||
if ( ${CMAKE_SYSTEM} MATCHES "Darwin" )
|
||||
set ( DARWIN 1 )
|
||||
set ( CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} )
|
||||
|
@ -216,18 +217,18 @@ if ( ${CMAKE_SYSTEM} MATCHES "Darwin" )
|
|||
endif ( enable-framework )
|
||||
endif ( ${CMAKE_SYSTEM} MATCHES "Darwin" )
|
||||
|
||||
set ( WITH_FLOAT )
|
||||
unset ( WITH_FLOAT CACHE )
|
||||
if ( enable-floats )
|
||||
set ( WITH_FLOAT 1 )
|
||||
endif ( enable-floats )
|
||||
|
||||
set ( WITH_PROFILING )
|
||||
unset ( WITH_PROFILING CACHE )
|
||||
if ( enable-profiling )
|
||||
set ( WITH_PROFILING 1 )
|
||||
endif ( enable-profiling )
|
||||
|
||||
set ( HAVE_LIBDL )
|
||||
set ( LADSPA_SUPPORT )
|
||||
unset ( HAVE_LIBDL CACHE )
|
||||
unset ( LADSPA_SUPPORT CACHE )
|
||||
if ( enable-ladspa )
|
||||
check_include_file ( ladspa.h LADSPA_SUPPORT )
|
||||
if ( LADSPA_SUPPORT )
|
||||
|
@ -239,15 +240,15 @@ if ( enable-ladspa )
|
|||
endif ( LADSPA_SUPPORT )
|
||||
endif ( enable-ladspa )
|
||||
|
||||
set ( ENABLE_TRAPONFPE )
|
||||
set ( TRAP_ON_FPE )
|
||||
unset ( ENABLE_TRAPONFPE CACHE )
|
||||
unset ( TRAP_ON_FPE CACHE )
|
||||
if ( enable-trap-on-fpe AND NOT APPLE AND NOT WIN32 )
|
||||
set ( ENABLE_TRAPONFPE 1 )
|
||||
set ( TRAP_ON_FPE 1 )
|
||||
endif ( enable-trap-on-fpe AND NOT APPLE AND NOT WIN32 )
|
||||
|
||||
set ( ENABLE_FPECHECK )
|
||||
set ( FPE_CHECK )
|
||||
unset ( ENABLE_FPECHECK CACHE )
|
||||
unset ( FPE_CHECK CACHE )
|
||||
if ( enable-fpe-check )
|
||||
set ( ENABLE_FPECHECK 1 )
|
||||
set ( FPE_CHECK 1 )
|
||||
|
@ -258,8 +259,8 @@ if ( enable-debug )
|
|||
"Choose the build type, options: Debug Release RelWithDebInfo" FORCE )
|
||||
endif ( enable-debug )
|
||||
|
||||
set ( ENABLE_DEBUG )
|
||||
set ( DEBUG )
|
||||
unset ( ENABLE_DEBUG CACHE )
|
||||
unset ( DEBUG CACHE )
|
||||
if ( CMAKE_BUILD_TYPE MATCHES "Debug" )
|
||||
set ( ENABLE_DEBUG 1 )
|
||||
set ( DEBUG 1 )
|
||||
|
@ -269,67 +270,74 @@ endif ( CMAKE_BUILD_TYPE MATCHES "Debug" )
|
|||
find_package ( PkgConfig REQUIRED )
|
||||
|
||||
# Mandatory libraries: glib and gthread
|
||||
set ( GLIB_LIBRARIES )
|
||||
pkg_check_modules ( GLIB REQUIRED glib-2.0>=2.6.5 gthread-2.0>=2.6.5 )
|
||||
|
||||
include ( UnsetPkgConfig )
|
||||
|
||||
# Optional features
|
||||
set ( LIBSNDFILE_SUPPORT )
|
||||
set ( LIBSNDFILE_HASVORBIS )
|
||||
set ( LIBSNDFILE_LIBRARIES )
|
||||
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 )
|
||||
endif ( LIBSNDFILE_SUPPORT )
|
||||
else ( enable-libsndfile )
|
||||
unset_pkg_config ( LIBSNDFILE )
|
||||
unset_pkg_config ( LIBSNDFILE_VORBIS )
|
||||
endif ( enable-libsndfile )
|
||||
|
||||
set ( AUFILE_SUPPORT )
|
||||
unset ( AUFILE_SUPPORT CACHE )
|
||||
if ( enable-aufile )
|
||||
set ( AUFILE_SUPPORT 1 )
|
||||
endif ( enable-aufile )
|
||||
|
||||
set ( PULSE_SUPPORT )
|
||||
set ( PULSE_LIBRARIES )
|
||||
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 )
|
||||
|
||||
set ( ALSA_SUPPORT )
|
||||
set ( ALSA_LIBRARIES )
|
||||
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 )
|
||||
|
||||
set ( PORTAUDIO_SUPPORT )
|
||||
set ( PORTAUDIO_LIBRARIES )
|
||||
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} )
|
||||
|
||||
set ( MIDISHARE_SUPPORT )
|
||||
set ( MidiShare_LIBS )
|
||||
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 )
|
||||
|
||||
set ( JACK_SUPPORT )
|
||||
set ( JACK_LIBRARIES )
|
||||
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 )
|
||||
|
||||
set ( WITH_READLINE )
|
||||
set ( READLINE_LIBS )
|
||||
unset ( WITH_READLINE CACHE )
|
||||
if ( enable-readline )
|
||||
find_package ( Readline )
|
||||
set ( FOUND_READLINE ${HAVE_READLINE} )
|
||||
|
@ -337,30 +345,36 @@ if ( enable-readline )
|
|||
set ( WITH_READLINE 1 )
|
||||
set ( READLINE_LIBS ${READLINE_LIBRARIES} )
|
||||
endif ( HAVE_READLINE )
|
||||
else ( enable-readline )
|
||||
unset ( READLINE_LIBS CACHE )
|
||||
endif ( enable-readline )
|
||||
|
||||
set ( LASH_SUPPORT )
|
||||
set ( LASH_LIBRARIES )
|
||||
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 )
|
||||
|
||||
set ( LADCCA_SUPPORT )
|
||||
set ( LADCCA_LIBRARIES )
|
||||
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 )
|
||||
|
||||
set ( DBUS_SUPPORT )
|
||||
set ( DBUS_LIBRARIES )
|
||||
unset ( DBUS_SUPPORT CACHE )
|
||||
if ( enable-dbus )
|
||||
pkg_check_modules ( DBUS dbus-1>=1.0.0 )
|
||||
set ( DBUS_SUPPORT ${DBUS_FOUND} )
|
||||
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
|
||||
|
|
|
@ -22,7 +22,7 @@ Linux and other systems at:
|
|||
How to use it?
|
||||
==============
|
||||
|
||||
1. You need CMake 2.6 or later to build FluidSynth
|
||||
1. You need CMake 2.6.3 or later to build FluidSynth
|
||||
|
||||
2. Unpack the FluidSynth sources somewhere, or checkout the repository,
|
||||
and create a build directory. For instance, using a command line shell:
|
||||
|
@ -103,21 +103,22 @@ file CMakeLists.txt, line 64:
|
|||
Now, let's check if the dbus-1 library and headers are installed, using
|
||||
pkg-config:
|
||||
|
||||
file CMakeLists.txt, lines 329-334:
|
||||
file CMakeLists.txt, lines 371-377:
|
||||
|
||||
set ( DBUS_SUPPORT )
|
||||
set ( DBUS_LIBRARIES )
|
||||
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 )
|
||||
|
||||
The two first lines clear the values of the CMake variables DBUS_LIBRARIES and
|
||||
DBUS_SUPPORT. If the value of the option "enable-dbus" is true, then the macro
|
||||
pkg_check_modules() is used to test a package named "dbus-1" with version 1.0.0
|
||||
or later. This macro automatically defines the variables DBUS_LIBRARIES,
|
||||
DBUS_INCLUDEDIR, DBUS_FOUND and others. The value of the last one is assigned
|
||||
to our variable DBUS_SUPPORT for later use.
|
||||
The first line clears the value of the CMake variable DBUS_SUPPORT. If the
|
||||
value of the option "enable-dbus" is true, then the macro pkg_check_modules()
|
||||
is used to test a package named "dbus-1" with version 1.0.0 or later. This macro
|
||||
automatically defines the variables DBUS_LIBRARIES, DBUS_INCLUDEDIR, DBUS_FOUND
|
||||
and others. The value of the last one is assigned to our variable DBUS_SUPPORT
|
||||
for later use.
|
||||
|
||||
There is a report to summarize the performed checks and the enabled features
|
||||
after the configuration steps, so let's add a line in this report regarding
|
||||
|
@ -166,7 +167,7 @@ file src/CMakeLists.txt, lines 163-197
|
|||
${DBUS_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
add_library ( libfluidsynth SHARED
|
||||
add_library ( libfluidsynth
|
||||
...
|
||||
${fluid_dbus_SOURCES}
|
||||
...
|
||||
|
|
|
@ -11,4 +11,5 @@ EXTRA_DIST = CheckDIRSymbolExists.cmake \
|
|||
FindReadline.cmake \
|
||||
report.cmake \
|
||||
TestInline.cmake \
|
||||
TestVLA.cmake
|
||||
TestVLA.cmake \
|
||||
UnsetPkgConfig.cmake
|
||||
|
|
14
fluidsynth/cmake_admin/UnsetPkgConfig.cmake
Normal file
14
fluidsynth/cmake_admin/UnsetPkgConfig.cmake
Normal file
|
@ -0,0 +1,14 @@
|
|||
macro ( unset_pkg_config _prefix )
|
||||
unset ( ${_prefix}_VERSION CACHE )
|
||||
unset ( ${_prefix}_PREFIX CACHE )
|
||||
unset ( ${_prefix}_CFLAGS CACHE )
|
||||
unset ( ${_prefix}_CFLAGS_OTHER CACHE )
|
||||
unset ( ${_prefix}_LDFLAGS CACHE )
|
||||
unset ( ${_prefix}_LDFLAGS_OTHER CACHE )
|
||||
unset ( ${_prefix}_LIBRARIES CACHE )
|
||||
unset ( ${_prefix}_INCLUDEDIR CACHE )
|
||||
unset ( ${_prefix}_INCLUDE_DIRS CACHE )
|
||||
unset ( ${_prefix}_LIBDIR CACHE )
|
||||
unset ( ${_prefix}_LIBRARY_DIRS CACHE )
|
||||
unset ( __pkg_config_checked_${_prefix} CACHE )
|
||||
endmacro ( unset_pkg_config )
|
Loading…
Reference in a new issue