1 cmake_minimum_required(VERSION 2.4)
2 include(CheckIncludeFiles)
3 include(CheckFunctionExists)
4 include(CheckLibraryExists)
6 macro(optional variable header library function source)
7 check_include_files(${header} ${variable}1)
9 check_library_exists(${library} ${function} "" ${variable})
11 set(optional_srcs ${optional_srcs} ${source})
12 set(optional_libs ${optional_libs} ${library})
17 macro(optional2 variable header library1 function1 library2 function2 source)
18 check_include_files(${header} ${variable}1)
20 check_library_exists(${library1} ${function1} "" ${variable}2)
22 check_library_exists(${library2} ${function2} "" ${variable})
24 set(optional_srcs ${optional_srcs} ${source})
25 set(optional_libs ${optional_libs} ${library1} ${library2})
31 macro(optional3 variable header library1 function1 library2 function2 library3 function3 source)
32 check_include_files(${header} ${variable}1)
34 check_library_exists(${library1} ${function1} "" ${variable}2)
36 check_library_exists(${library2} ${function2} "" ${variable}3)
38 check_library_exists(${library3} ${function3} "" ${variable})
40 set(optional_srcs ${optional_srcs} ${source})
41 set(optional_libs ${optional_libs} ${library1} ${library2} ${library3})
48 macro(optional4 variable header library1 function1 library2 function2 library3 function3 library4 function4 source)
49 check_include_files(${header} ${variable}1)
51 check_library_exists(${library1} ${function1} "" ${variable}2)
53 check_library_exists(${library2} ${function2} "" ${variable}3)
55 check_library_exists(${library3} ${function3} "" ${variable}4)
57 check_library_exists(${library4} ${function4} "" ${variable})
59 set(optional_srcs ${optional_srcs} ${source})
60 set(optional_libs ${optional_libs} ${library1} ${library2} ${library3} ${library4})
70 if(CMAKE_COMPILER_IS_GNUCC)
71 add_definitions(-fstack-protector -Wall -W -Wmissing-prototypes -Wstrict-prototypes -pedantic -Wno-format -Wno-long-long)
72 endif(CMAKE_COMPILER_IS_GNUCC)
74 include(TestBigEndian)
76 check_include_files("byteswap.h" HAVE_BYTESWAP_H)
77 check_include_files("inttypes.h" HAVE_INTTYPES_H)
78 check_include_files("fenv.h" HAVE_FENV_H)
79 check_include_files("glob.h" HAVE_GLOB_H)
80 check_include_files("io.h" HAVE_IO_H)
81 #check_include_files("ltdl.h" HAVE_LTDL_H) # no plug-ins as yet
82 check_include_files("stdint.h" HAVE_STDINT_H)
83 check_include_files("string.h" HAVE_STRING_H)
84 check_include_files("strings.h" HAVE_STRINGS_H)
85 check_include_files("sys/stat.h" HAVE_SYS_STAT_H)
86 check_include_files("sys/time.h" HAVE_SYS_TIME_H)
87 check_include_files("sys/timeb.h" HAVE_SYS_TIMEB_H)
88 check_include_files("sys/types.h" HAVE_SYS_TYPES_H)
89 check_include_files("sys/utsname.h" HAVE_SYS_UTSNAME_H)
90 check_include_files("termios.h" HAVE_TERMIOS_H)
91 check_include_files("unistd.h" HAVE_UNISTD_H)
93 check_function_exists("fmemopen" HAVE_FMEMOPEN)
94 check_function_exists("fseeko" HAVE_FSEEKO)
95 check_function_exists("gettimeofday" HAVE_GETTIMEOFDAY)
96 check_function_exists("mkstemp" HAVE_MKSTEMP)
97 check_function_exists("popen" HAVE_POPEN)
98 check_function_exists("strcasecmp" HAVE_STRCASECMP)
99 check_function_exists("strrstr" HAVE_STRRSTR)
100 check_function_exists("vsnprintf" HAVE_VSNPRINTF)
102 test_big_endian(WORDS_BIGENDIAN)
104 optional(NEED_LIBM math.h m pow "")
106 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -lm)
107 optional(HAVE_LRINT math.h m lrint "")
109 check_function_exists("lrint" HAVE_LRINT)
111 optional(EXTERNAL_GSM gsm/gsm.h gsm gsm_create "")
112 optional(EXTERNAL_LPC10 lpc10/lpc10.h lpc10 lpc10_create "")
113 optional(HAVE_ALSA alsa/asoundlib.h asound snd_pcm_open alsa)
114 optional(HAVE_AMRNB amrnb/sp_dec.h amrnb Decoder_Interface_init amr-nb)
115 optional(HAVE_AMRWB amrwb/dec.h amrwb D_IF_init amr-wb)
116 if(CMAKE_COMPILER_IS_GNUCC)
117 optional(HAVE_GOMP omp.h gomp omp_get_thread_num "")
119 add_definitions(-fopenmp)
121 endif(CMAKE_COMPILER_IS_GNUCC)
122 optional(HAVE_ID3TAG id3tag.h id3tag id3_file_open "")
123 optional(HAVE_SNDIO sndio.h sndio sio_open sndio)
124 optional(HAVE_AO ao/ao.h ao ao_play ao)
125 optional(HAVE_FLAC FLAC/all.h FLAC FLAC__stream_encoder_new flac)
126 optional(HAVE_MAD_H mad.h mad mad_stream_buffer mp3)
127 optional(HAVE_LAME_LAME_H lame/lame.h mp3lame lame_get_lametag_frame mp3)
128 if (NOT HAVE_LAME_LAME_H)
129 optional(HAVE_LAME_LAME_H lame.h mp3lame lame_get_lametag_frame mp3)
130 endif (NOT HAVE_LAME_LAME_H)
131 optional(HAVE_TWOLAME_H twolame.h twolame twolame_init mp3)
132 optional(HAVE_MAGIC magic.h magic magic_open "")
133 optional2(HAVE_PNG png.h png png_set_rows z uncompress spectrogram)
135 check_library_exists(z uncompress "" spectrogram1)
137 set(optional_libs ${optional_libs} z)
138 endif (${spectrogram1})
140 optional2(HAVE_PULSEAUDIO pulse/simple.h pulse-simple pa_simple_new pulse pa_strerror pulseaudio)
141 optional(HAVE_SNDFILE sndfile.h sndfile sf_open_virtual sndfile)
142 optional(HAVE_SNDFILE sndfile.h sndfile sf_open_virtual caf)
143 optional(HAVE_SNDFILE sndfile.h sndfile sf_open_virtual fap)
144 optional(HAVE_SNDFILE sndfile.h sndfile sf_open_virtual mat4)
145 optional(HAVE_SNDFILE sndfile.h sndfile sf_open_virtual mat5)
146 optional(HAVE_SNDFILE sndfile.h sndfile sf_open_virtual paf)
147 optional(HAVE_SNDFILE sndfile.h sndfile sf_open_virtual pvf)
148 optional(HAVE_SNDFILE sndfile.h sndfile sf_open_virtual sd2)
149 optional(HAVE_SNDFILE sndfile.h sndfile sf_open_virtual w64)
150 optional(HAVE_SNDFILE sndfile.h sndfile sf_open_virtual xi)
151 optional(HAVE_SPEEXDSP speex/speex_preprocess.h speexdsp speex_preprocess_run speexdsp)
152 optional(HAVE_SUN_AUDIOIO_H sun/audioio.h c ioctl sunaudio)
153 if (NOT HAVE_SUN_AUDIOIO_H)
154 optional(HAVE_SYS_AUDIOIO_H sys/audioio.h c ioctl sunaudio)
155 endif (NOT HAVE_SUN_AUDIOIO_H)
156 optional(HAVE_SYS_SOUNDCARD_H sys/soundcard.h c ioctl oss)
157 if (NOT HAVE_SYS_SOUNDCARD_H)
158 optional(HAVE_MACHINE_SOUNDCARD_H machine/soundcard.h ossaudio _oss_ioctl oss)
159 endif (NOT HAVE_SYS_SOUNDCARD_H)
160 optional(HAVE_WAVEAUDIO mmsystem.h winmm waveInGetDevCapsA waveaudio)
161 optional4(HAVE_OGG_VORBIS vorbis/codec.h ogg ogg_stream_flush vorbis vorbis_analysis_headerout vorbisfile ov_clear vorbisenc vorbis_encode_init_vbr vorbis)
162 optional3(HAVE_OPUS opusfile.h ogg ogg_stream_flush opus opus_encoder_create opusfile op_open_callbacks opus)
163 optional(HAVE_WAVPACK wavpack/wavpack.h wavpack WavpackGetSampleRate wavpack)
165 if (HAVE_LAME_LAME_H OR HAVE_MAD_H)
167 endif (HAVE_LAME_LAME_H OR HAVE_MAD_H)
169 set(CMAKE_REQUIRED_LIBRARIES mp3lame m)
170 check_function_exists("lame_set_VBR_quality" HAVE_LAME_SET_VBR_QUALITY)
172 if (HAVE_SUN_AUDIOIO_H OR HAVE_SYS_AUDIOIO_H)
173 set(HAVE_SUN_AUDIO 1)
174 endif (HAVE_SUN_AUDIOIO_H OR HAVE_SYS_AUDIOIO_H)
176 if (HAVE_SYS_SOUNDCARD_H OR HAVE_MACHINE_SOUNDCARD_H)
178 endif (HAVE_SYS_SOUNDCARD_H OR HAVE_MACHINE_SOUNDCARD_H)
180 configure_file(sox.pc.in sox.pc @ONLY)
181 install_files(/lib/pkgconfig FILES sox.pc)
185 if (NOT EXTERNAL_GSM)
186 add_subdirectory(libgsm)
187 endif (NOT EXTERNAL_GSM)
189 if (NOT EXTERNAL_LPC10)
190 add_subdirectory(lpc10)
191 endif (NOT EXTERNAL_LPC10)
194 find_library(COREAUDIO_LIBRARY CoreAudio)
195 mark_as_advanced(COREAUDIO_LIBRARY)
196 if(COREAUDIO_LIBRARY)
197 set(HAVE_COREAUDIO 1)
198 set(optional_srcs ${optional_srcs} coreaudio)
199 endif(COREAUDIO_LIBRARY)
200 set(optional_libs ${optional_libs} ${COREAUDIO_LIBRARY})