File: CMakeLists.txt

package info (click to toggle)
fluidsynth 1.1.11-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,356 kB
  • sloc: ansic: 31,563; xml: 705; sh: 523; makefile: 266; cpp: 262; java: 110
file content (575 lines) | stat: -rw-r--r-- 21,657 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
# FluidSynth - A Software Synthesizer
#
# Copyright (C) 2003-2011 Peter Hanappe and others.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307, USA

# CMake based build system. Pedro Lopez-Cabanillas <plcl@users.sf.net>

cmake_minimum_required ( VERSION 3.0.2 )
project ( FluidSynth C )
set ( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_admin )

# FluidSynth package name
set ( PACKAGE "fluidsynth" )

# FluidSynth package version
set ( FLUIDSYNTH_VERSION_MAJOR 1 )
set ( FLUIDSYNTH_VERSION_MINOR 1 )
set ( FLUIDSYNTH_VERSION_MICRO 11 )
set ( VERSION "${FLUIDSYNTH_VERSION_MAJOR}.${FLUIDSYNTH_VERSION_MINOR}.${FLUIDSYNTH_VERSION_MICRO}" )
set ( FLUIDSYNTH_VERSION "\"${VERSION}\"" )

# libfluidsynth - Library version
# *** NOTICE ***
# Update library version upon each release (follow these steps in order)
# if any source code changes: REVISION++
# if any interfaces added/removed/changed: REVISION=0
# if any interfaces removed/changed (compatibility broken): CURRENT++
# if any interfaces have been added: AGE++
# if any interfaces have been removed/changed (compatibility broken): AGE=0
# This is not exactly the same algorithm as the libtool one, but the results are the same.
set ( LIB_VERSION_CURRENT 1 )
set ( LIB_VERSION_AGE 7 )
set ( LIB_VERSION_REVISION 2 )
set ( LIB_VERSION_INFO
      "${LIB_VERSION_CURRENT}.${LIB_VERSION_AGE}.${LIB_VERSION_REVISION}" )

# Options disabled by default
option ( enable-debug "enable debugging (default=no)" off )
option ( enable-floats "enable type float instead of double for DSP samples" off )
option ( enable-profiling "profile the dsp code" off )
option ( enable-ladspa "enable LADSPA effect units" off )
option ( enable-fpe-check "enable Floating Point Exception checks and debug messages" off )
option ( enable-portaudio "compile PortAudio support" off )
option ( enable-trap-on-fpe "enable SIGFPE trap on Floating Point Exceptions" off )

# Options enabled by default
option ( enable-aufile "compile support for sound file output" on )
option ( BUILD_SHARED_LIBS "Build a shared object or DLL" on )
option ( enable-dbus "compile DBUS support (if it is available)" on )
option ( enable-ipv6  "enable ipv6 support" on )
option ( enable-jack "compile JACK support (if it is available)" on )
option ( enable-libsndfile "compile libsndfile support (if it is available)" on )
option ( enable-midishare "compile MidiShare support (if it is available)" on )
option ( enable-oss "compile OSS support (if it is available)" on )
option ( enable-pkgconfig "use pkg-config to locate fluidsynth's (mostly optional) dependencies" on )
option ( enable-pulseaudio "compile PulseAudio support (if it is available)" on )
option ( enable-readline "compile readline lib line editing (if it is available)" on )

# Platform specific options
if ( CMAKE_SYSTEM MATCHES "Linux" )
    option ( enable-ladcca "compile LADCCA support if it is available (deprecated)" off )
    option ( enable-lash "compile LASH support (if it is available)" on )
    option ( enable-alsa "compile ALSA support (if it is available)" on )
endif ( CMAKE_SYSTEM MATCHES "Linux" )

if ( CMAKE_SYSTEM MATCHES "Darwin" )
    option ( enable-coreaudio "compile CoreAudio support (if it is available)" on )
    option ( enable-coremidi "compile CoreMIDI support (if it is available)" on )
    option ( enable-framework "create a Mac OSX style FluidSynth.framework" on )
endif ( CMAKE_SYSTEM MATCHES "Darwin" )

if ( CMAKE_SYSTEM MATCHES "OS2" )
    option ( enable-dart "compile DART support (if it is available)" on )
    set ( enable-ipv6 off )
endif ( CMAKE_SYSTEM MATCHES "OS2" )

# Initialize the library directory name suffix.
if (NOT MINGW AND NOT MSVC)
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
  set ( _init_lib_suffix "64" )
else ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
  set ( _init_lib_suffix "" )
endif ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
else ()
  set ( _init_lib_suffix "" )
endif()
set ( LIB_SUFFIX ${_init_lib_suffix} CACHE STRING
      "library directory name suffix (32/64/nothing)" )
mark_as_advanced ( LIB_SUFFIX )

# Default install directory names
include ( DefaultDirs )

# Basic C library checks
include ( CheckSTDC )
include ( CheckIncludeFile )
include ( CheckFunctionExists )
check_include_file ( string.h HAVE_STRING_H )
check_include_file ( stdlib.h HAVE_STDLIB_H )
check_include_file ( stdio.h HAVE_STDIO_H )
check_include_file ( math.h HAVE_MATH_H )
check_include_file ( errno.h HAVE_ERRNO_H )
check_include_file ( stdarg.h HAVE_STDARG_H )
check_include_file ( unistd.h HAVE_UNISTD_H )
check_include_file ( memory.h HAVE_MEMORY_H )
check_include_file ( sys/mman.h HAVE_SYS_MMAN_H )
check_include_file ( sys/types.h HAVE_SYS_TYPES_H )
check_include_file ( sys/time.h HAVE_SYS_TIME_H )
check_include_file ( sys/stat.h HAVE_SYS_STAT_H )
check_include_file ( sys/ioctl.h HAVE_SYS_IOCTL_H )
check_include_file ( fcntl.h HAVE_FCNTL_H )
check_include_file ( sys/socket.h HAVE_SYS_SOCKET_H )
check_include_file ( netinet/in.h HAVE_NETINET_IN_H )
check_include_file ( netinet/tcp.h HAVE_NETINET_TCP_H )
check_include_file ( arpa/inet.h HAVE_ARPA_INET_H )
check_include_file ( limits.h  HAVE_LIMITS_H )
check_include_file ( pthread.h HAVE_PTHREAD_H )
check_include_file ( signal.h HAVE_SIGNAL_H )
check_include_file ( getopt.h HAVE_GETOPT_H )
include ( TestInline )
include ( TestVLA )
include ( TestBigEndian )
test_big_endian ( WORDS_BIGENDIAN )

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 OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" )
  if ( NOT APPLE AND NOT OS2 )
    set ( CMAKE_EXE_LINKER_FLAGS
          "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed" )
    set ( CMAKE_SHARED_LINKER_FLAGS
          "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" )
  endif ( NOT APPLE AND NOT OS2 )
  
  if ( OS2 )
    set ( GNUCC_VISIBILITY_FLAG "" )
  else ( OS2 )
    set ( GNUCC_VISIBILITY_FLAG "-fvisibility=hidden" )
  endif ( OS2 )

  set ( GNUCC_WARNING_FLAGS "-Wall -W -Wpointer-arith -Wbad-function-cast -Wno-cast-qual -Wcast-align -Wstrict-prototypes -Wno-unused-parameter -Wdeclaration-after-statement" )
  set ( CMAKE_C_FLAGS_DEBUG "-std=gnu89 -g ${GNUCC_VISIBILITY_FLAG} -DDEBUG ${GNUCC_WARNING_FLAGS}" )
  set ( CMAKE_C_FLAGS_RELEASE "-std=gnu89 -O2 -fomit-frame-pointer -finline-functions ${GNUCC_VISIBILITY_FLAG} -DNDEBUG ${GNUCC_WARNING_FLAGS}" )
  set ( CMAKE_C_FLAGS_RELWITHDEBINFO "-std=gnu89 -O2 -g -fomit-frame-pointer -finline-functions ${GNUCC_VISIBILITY_FLAG} -DNDEBUG ${GNUCC_WARNING_FLAGS}" )
endif ( CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" )

# Windows
unset ( WINDOWS_SUPPORT CACHE )
unset ( WINDOWS_LIBS CACHE )
unset ( MINGW32 CACHE )
if ( WIN32 )
  include ( CheckIncludeFiles )
  check_include_file ( windows.h HAVE_WINDOWS_H )
  check_include_file ( io.h HAVE_IO_H )
  check_include_file ( dsound.h HAVE_DSOUND_H )
  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" )
  if (NOT MSVC)
    set ( CMAKE_DEBUG_POSTFIX "_debug" )
  endif()
  # MinGW compiler (a Windows GCC port)
  if ( MINGW )
    set ( MINGW32 1 )
    add_definitions ( -mms-bitfields )
  endif  ( MINGW )
else ( WIN32 )
# Check PThreads, but not in Windows
  find_package ( Threads REQUIRED )
  set ( HAVE_LIBPTHREAD ${Threads_FOUND} )
  set ( LIBFLUID_LIBS "m" ${CMAKE_THREAD_LIBS_INIT} )
endif ( WIN32 )

# IBM OS/2
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" )
  if ( enable-dart )
    check_include_files ( "os2.h;os2me.h" HAVE_DART_H )
    set ( DART_SUPPORT ${HAVE_DART_H} )
    unset ( DART_INCLUDE_DIRS CACHE )
  endif ( enable-dart )
endif ( CMAKE_SYSTEM MATCHES "OS2" )

# Solaris / SunOS
if ( CMAKE_SYSTEM MATCHES "SunOS" )
  set ( FLUID_LIBS "${FLUID_LIBS};nsl;socket" )
  set ( LIBFLUID_LIBS "${LIBFLUID_LIBS};nsl;socket" )
endif ( CMAKE_SYSTEM MATCHES "SunOS" )

# Apple Mac OSX
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_INSTALL_DIR} )
  if ( enable-coreaudio )
    check_include_file ( CoreAudio/AudioHardware.h COREAUDIO_FOUND )
    if ( COREAUDIO_FOUND )
      set ( COREAUDIO_SUPPORT ${COREAUDIO_FOUND} )
      set ( COREAUDIO_LIBS "-Wl,-framework,CoreAudio,-framework,AudioUnit" )
    endif ( COREAUDIO_FOUND )
  endif ( enable-coreaudio )
  if ( enable-coremidi )
    check_include_file ( CoreMIDI/MIDIServices.h COREMIDI_FOUND )
    if ( COREMIDI_FOUND )
      set ( COREMIDI_SUPPORT ${COREMIDI_FOUND} )
      set ( COREMIDI_LIBS "-Wl,-framework,CoreMIDI,-framework,CoreServices" )
    endif ( COREMIDI_FOUND )
  endif ( enable-coremidi )
  if ( enable-framework )
    set ( MACOSX_FRAMEWORK 1 )
  endif ( enable-framework )
endif ( CMAKE_SYSTEM MATCHES "Darwin" )


unset ( HAVE_INETNTOP CACHE )
unset ( IPV6_SUPPORT CACHE )
CHECK_FUNCTION_EXISTS ( "inet_ntop" HAVE_INETNTOP )
if ( enable-ipv6 )
  if ( HAVE_INETNTOP )
    set ( IPV6_SUPPORT 1 )
  endif ( HAVE_INETNTOP )
endif ( enable-ipv6 )

unset ( WITH_FLOAT CACHE )
if ( enable-floats )
    set ( WITH_FLOAT 1 )
endif ( enable-floats )

unset ( WITH_PROFILING CACHE )
if ( enable-profiling )
    set ( WITH_PROFILING 1 )
endif ( enable-profiling )

unset ( HAVE_LIBDL CACHE )
unset ( LADSPA_SUPPORT CACHE )
if ( enable-ladspa )
  check_include_file ( ladspa.h LADSPA_SUPPORT )
  if ( LADSPA_SUPPORT )
    set ( LADSPA 1 )
    if ( CMAKE_DL_LIBS )
      set ( HAVE_LIBDL 1 )
      set ( LIBFLUID_LIBS "${LIBFLUID_LIBS};${CMAKE_DL_LIBS}" )
    endif ( CMAKE_DL_LIBS )
  endif ( LADSPA_SUPPORT )
endif ( enable-ladspa )

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 )

unset ( ENABLE_FPECHECK CACHE )
unset ( FPE_CHECK CACHE )
if ( enable-fpe-check )
    set ( ENABLE_FPECHECK 1 )
    set ( FPE_CHECK 1 )
endif ( enable-fpe-check )

if ( enable-debug )
    set ( CMAKE_BUILD_TYPE "Debug" CACHE STRING
          "Choose the build type, options: Debug Release RelWithDebInfo" FORCE )
endif ( enable-debug )

if ( NOT CMAKE_BUILD_TYPE )
    set ( CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
          "Choose the build type, options: Debug Release RelWithDebInfo" FORCE )
endif ( NOT CMAKE_BUILD_TYPE )

unset ( ENABLE_DEBUG CACHE )
unset ( DEBUG CACHE )
if ( CMAKE_BUILD_TYPE MATCHES "Debug" )
    set ( ENABLE_DEBUG 1 )
    set ( DEBUG 1 )
endif ( CMAKE_BUILD_TYPE MATCHES "Debug" )


if(NOT enable-pkgconfig)

    FIND_LIBRARY( GLIB_LIB NAMES glib glib-2.0 PATH GLIB_LIBRARY_DIR )
    FIND_LIBRARY( GTHREAD_LIB NAMES gthread gthread-2.0 PATH GTHREAD_LIBRARY_DIR )
    FIND_PATH( GLIBH_DIR glib.h PATH GLIB_INCLUDE_DIR )
    FIND_PATH( GLIBCONF_DIR glibconfig.h PATH GLIBCONF_INCLUDE_DIR )
    
    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
    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 ( OSS_SUPPORT CACHE )
if ( enable-oss )
  find_package ( OSS QUIET )
  set ( OSS_SUPPORT ${OSS_FOUND} )
endif ( enable-oss )

unset ( MIDISHARE_SUPPORT CACHE )
if ( enable-midishare )
  find_package ( MidiShare QUIET )
  set ( MIDISHARE_SUPPORT ${MidiShare_FOUND} )
  if ( MidiShare_FOUND )
    set ( MidiShare_LIBS ${MidiShare_LIBRARIES} )
  else ( MidiShare_FOUND )
    unset ( MidiShare_LIBS CACHE )
  endif ( 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 )
configure_file ( ${CMAKE_SOURCE_DIR}/include/fluidsynth.cmake
                 ${CMAKE_BINARY_DIR}/include/fluidsynth.h )
add_definitions ( -DHAVE_CONFIG_H )

# Extra configuration file for MS VisualC compiler
if ( MSVC )
  configure_file ( ${CMAKE_SOURCE_DIR}/src/config_win32.cmake
                   ${CMAKE_BINARY_DIR}/config_win32.h )
endif ( MSVC )

# Process subdirectories
add_subdirectory ( src )
add_subdirectory ( include )
add_subdirectory ( doc )

# pkg-config support
set ( prefix "${CMAKE_INSTALL_PREFIX}" )
set ( exec_prefix "\${prefix}" )
if ( IS_ABSOLUTE "${LIB_INSTALL_DIR}" )
  set ( libdir "${LIB_INSTALL_DIR}" )
else ()
  set ( libdir "\${exec_prefix}/${LIB_INSTALL_DIR}" )
endif ()
if ( IS_ABSOLUTE "${INCLUDE_INSTALL_DIR}" )
  set ( includedir "${INCLUDE_INSTALL_DIR}" )
else ()
  set ( includedir "\${prefix}/${INCLUDE_INSTALL_DIR}" )
endif ()
configure_file ( fluidsynth.pc.in
	${CMAKE_BINARY_DIR}/fluidsynth.pc IMMEDIATE @ONLY )
install ( FILES ${CMAKE_BINARY_DIR}/fluidsynth.pc
	DESTINATION ${LIB_INSTALL_DIR}/pkgconfig )

# Extra targets for Unix build environments
if ( UNIX )
    # RPM spec
    configure_file ( fluidsynth.spec.in
        ${CMAKE_BINARY_DIR}/fluidsynth.spec IMMEDIATE @ONLY )

    if ( DEFINED FLUID_DAEMON_ENV_FILE)
        configure_file ( fluidsynth.service.in
        ${CMAKE_BINARY_DIR}/fluidsynth.service @ONLY )

        configure_file ( fluidsynth.conf.in
        ${CMAKE_BINARY_DIR}/fluidsynth.conf @ONLY )

    endif ( DEFINED FLUID_DAEMON_ENV_FILE )

    # uninstall custom target
    configure_file ( "${CMAKE_SOURCE_DIR}/cmake_admin/cmake_uninstall.cmake.in"
      "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
    add_custom_target ( uninstall
      "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")

    # tarball custom target
    add_custom_target ( tarball
        COMMAND mkdir -p ${PACKAGE}-${VERSION}
        COMMAND cp -r bindings ${PACKAGE}-${VERSION}
        COMMAND cp -r cmake_admin ${PACKAGE}-${VERSION}
        COMMAND cp -r doc ${PACKAGE}-${VERSION}
        COMMAND cp -r include ${PACKAGE}-${VERSION}
        COMMAND cp -r src ${PACKAGE}-${VERSION}
        COMMAND cp AUTHORS ChangeLog CMakeLists.txt LICENSE ${PACKAGE}.* INSTALL NEWS README* THANKS TODO ${PACKAGE}-${VERSION}
#       COMMAND tar -cj --exclude .svn --exclude Makefile.am -f ${PACKAGE}-${VERSION}.tar.bz2 ${PACKAGE}-${VERSION}
#       COMMAND tar -cz --exclude .svn --exclude Makefile.am -f ${PACKAGE}-${VERSION}.tar.gz ${PACKAGE}-${VERSION}
#       COMMAND zip -qr ${PACKAGE}-${VERSION}.zip ${PACKAGE}-${VERSION} -x '*.svn*' -x '*Makefile.am'
        COMMAND tar -cj --exclude .svn -f ${PACKAGE}-${VERSION}.tar.bz2 ${PACKAGE}-${VERSION}
        COMMAND tar -cz --exclude .svn -f ${PACKAGE}-${VERSION}.tar.gz ${PACKAGE}-${VERSION}
        COMMAND zip -qr ${PACKAGE}-${VERSION}.zip ${PACKAGE}-${VERSION} -x '*.svn*'
        COMMAND rm -rf ${PACKAGE}-${VERSION}
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
    )

    # tarball custom target
    add_custom_target ( tarball-autotools
        COMMAND mkdir -p ${PACKAGE}-${VERSION}
        COMMAND cp -r bindings ${PACKAGE}-${VERSION}
        COMMAND cp -r cmake_admin ${PACKAGE}-${VERSION}
        COMMAND cp -r doc ${PACKAGE}-${VERSION}
        COMMAND cp -r include ${PACKAGE}-${VERSION}
        COMMAND cp -r src ${PACKAGE}-${VERSION}
        COMMAND cp AUTHORS ChangeLog CMakeLists.txt ../LICENSE ${PACKAGE}.* INSTALL NEWS README* ../README.md THANKS TODO ${PACKAGE}-${VERSION}
        COMMAND cp acinclude.m4 autogen.sh configure.ac install-sh missing mkinstalldirs Makefile.am ${PACKAGE}-${VERSION}
        # Files below are added when running autogen.sh
        # COMMAND cp -r autom4te.cache ${PACKAGE}-${VERSION}
        COMMAND cp -r m4 ${PACKAGE}-${VERSION}
        COMMAND cp aclocal.m4 compile config.guess config.sub configure depcomp ltmain.sh Makefile.in ${PACKAGE}-${VERSION}
        COMMAND tar -cj --exclude .svn -f ${PACKAGE}-${VERSION}.tar.bz2 ${PACKAGE}-${VERSION}
        COMMAND tar -cz --exclude .svn -f ${PACKAGE}-${VERSION}.tar.gz ${PACKAGE}-${VERSION}
        COMMAND zip -qr ${PACKAGE}-${VERSION}.zip ${PACKAGE}-${VERSION} -x '*.svn*'
        COMMAND rm -rf ${PACKAGE}-${VERSION}
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
    )

endif ( UNIX )

include ( report )

# CPack support
set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "FluidSynth real-time synthesizer" )
set ( CPACK_PACKAGE_VENDOR "fluidsynth.org" )
set ( CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md" )
set ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE" )
set ( CPACK_PACKAGE_VERSION_MAJOR ${FLUIDSYNTH_VERSION_MAJOR} )
set ( CPACK_PACKAGE_VERSION_MINOR ${FLUIDSYNTH_VERSION_MINOR} )
set ( CPACK_PACKAGE_VERSION_PATCH ${FLUIDSYNTH_VERSION_MICRO} )
set ( CPACK_PACKAGE_EXECUTABLES "fluidsynth" "FluidSynth CLI" )

# source packages
set ( CPACK_SOURCE_GENERATOR TGZ;TBZ2;ZIP )
set ( CPACK_SOURCE_IGNORE_FILES "/.svn/;/build/;~$;.cproject;.project;/.settings/;${CPACK_SOURCE_IGNORE_FILES}" )
set ( CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}" )
set ( CPACK_SOURCE_STRIP_FILES OFF )

# binary packages
include ( InstallRequiredSystemLibraries )
set ( CPACK_GENERATOR STGZ;TGZ;TBZ2;ZIP )
set ( CPACK_PACKAGE_NAME ${PACKAGE} )
set ( CPACK_STRIP_FILES ON )

include ( CPack )