Industry Compat keymap: Use Move, Rotate, Scale tools for UV transform, instead of...
[blender.git] / extern / audaspace / CMakeLists.txt
1 ################################################################################
2 # Copyright 2009-2016 Jörg Müller
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #   http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 ################################################################################
16
17 cmake_minimum_required(VERSION 3.0)
18 include(CMakeDependentOption)
19
20 if(POLICY CMP0054)
21         cmake_policy(SET CMP0054 NEW)
22 endif()
23
24 project(audaspace)
25
26 set(AUDASPACE_VERSION 1.3)
27 set(AUDASPACE_LONG_VERSION ${AUDASPACE_VERSION}.0)
28
29 if(DEFINED AUDASPACE_CMAKE_CFG)
30         include(${AUDASPACE_CMAKE_CFG})
31 endif()
32
33 if(NOT DEFINED AUDASPACE_STANDALONE)
34         set(AUDASPACE_STANDALONE TRUE)
35 endif()
36
37 # sources
38
39 set(SRC
40         src/devices/DefaultSynchronizer.cpp
41         src/devices/DeviceManager.cpp
42         src/devices/NULLDevice.cpp
43         src/devices/ReadDevice.cpp
44         src/devices/SoftwareDevice.cpp
45         src/Exception.cpp
46         src/file/File.cpp
47         src/file/FileManager.cpp
48         src/file/FileWriter.cpp
49         src/fx/Accumulator.cpp
50         src/fx/ADSR.cpp
51         src/fx/ADSRReader.cpp
52         src/fx/BaseIIRFilterReader.cpp
53         src/fx/ButterworthCalculator.cpp
54         src/fx/Butterworth.cpp
55         src/fx/CallbackIIRFilterReader.cpp
56         src/fx/Delay.cpp
57         src/fx/DelayReader.cpp
58         src/fx/DynamicIIRFilter.cpp
59         src/fx/DynamicIIRFilterReader.cpp
60         src/fx/DynamicMusic.cpp
61         src/fx/Effect.cpp
62         src/fx/EffectReader.cpp
63         src/fx/Envelope.cpp
64         src/fx/Fader.cpp
65         src/fx/FaderReader.cpp
66         src/fx/HighpassCalculator.cpp
67         src/fx/Highpass.cpp
68         src/fx/IIRFilter.cpp
69         src/fx/IIRFilterReader.cpp
70         src/fx/Limiter.cpp
71         src/fx/LimiterReader.cpp
72         src/fx/Loop.cpp
73         src/fx/LoopReader.cpp
74         src/fx/LowpassCalculator.cpp
75         src/fx/Lowpass.cpp
76         src/fx/Modulator.cpp
77         src/fx/ModulatorReader.cpp
78         src/fx/MutableReader.cpp
79         src/fx/MutableSound.cpp
80         src/fx/Pitch.cpp
81         src/fx/PitchReader.cpp
82         src/fx/PlaybackManager.cpp
83         src/fx/PlaybackCategory.cpp
84         src/fx/Reverse.cpp
85         src/fx/ReverseReader.cpp
86         src/fx/SoundList.cpp
87         src/fx/Source.cpp
88         src/fx/Sum.cpp
89         src/fx/Threshold.cpp
90         src/fx/Volume.cpp
91         src/fx/VolumeReader.cpp
92         src/fx/VolumeSound.cpp
93         src/fx/VolumeStorage.cpp
94         src/generator/Sawtooth.cpp
95         src/generator/SawtoothReader.cpp
96         src/generator/Silence.cpp
97         src/generator/SilenceReader.cpp
98         src/generator/Sine.cpp
99         src/generator/SineReader.cpp
100         src/generator/Square.cpp
101         src/generator/SquareReader.cpp
102         src/generator/Triangle.cpp
103         src/generator/TriangleReader.cpp
104         src/respec/ChannelMapper.cpp
105         src/respec/ChannelMapperReader.cpp
106         src/respec/Converter.cpp
107         src/respec/ConverterFunctions.cpp
108         src/respec/ConverterReader.cpp
109         src/respec/JOSResample.cpp
110         src/respec/JOSResampleReaderCoeff.cpp
111         src/respec/JOSResampleReader.cpp
112         src/respec/LinearResample.cpp
113         src/respec/LinearResampleReader.cpp
114         src/respec/Mixer.cpp
115         src/respec/ResampleReader.cpp
116         src/respec/SpecsChanger.cpp
117         src/sequence/AnimateableProperty.cpp
118         src/sequence/Double.cpp
119         src/sequence/DoubleReader.cpp
120         src/sequence/PingPong.cpp
121         src/sequence/Sequence.cpp
122         src/sequence/SequenceData.cpp
123         src/sequence/SequenceEntry.cpp
124         src/sequence/SequenceHandle.cpp
125         src/sequence/SequenceReader.cpp
126         src/sequence/Superpose.cpp
127         src/sequence/SuperposeReader.cpp
128         src/util/Barrier.cpp
129         src/util/Buffer.cpp
130         src/util/BufferReader.cpp
131         src/util/StreamBuffer.cpp
132         src/util/ThreadPool.cpp
133 )
134
135 set(PRIVATE_HDR
136         src/sequence/SequenceHandle.h
137 )
138
139 set(PUBLIC_HDR
140         include/devices/DefaultSynchronizer.h
141         include/devices/DeviceManager.h
142         include/devices/I3DDevice.h
143         include/devices/I3DHandle.h
144         include/devices/IDeviceFactory.h
145         include/devices/IDevice.h
146         include/devices/IHandle.h
147         include/devices/ISynchronizer.h
148         include/devices/NULLDevice.h
149         include/devices/ReadDevice.h
150         include/devices/SoftwareDevice.h
151         include/Exception.h
152         include/file/File.h
153         include/file/FileManager.h
154         include/file/FileWriter.h
155         include/file/IFileInput.h
156         include/file/IFileOutput.h
157         include/file/IWriter.h
158         include/fx/Accumulator.h
159         include/fx/ADSR.h
160         include/fx/ADSRReader.h
161         include/fx/BaseIIRFilterReader.h
162         include/fx/ButterworthCalculator.h
163         include/fx/Butterworth.h
164         include/fx/CallbackIIRFilterReader.h
165         include/fx/Delay.h
166         include/fx/DelayReader.h
167         include/fx/DynamicIIRFilter.h
168         include/fx/DynamicIIRFilterReader.h
169         include/fx/DynamicMusic.h
170         include/fx/Effect.h
171         include/fx/EffectReader.h
172         include/fx/Envelope.h
173         include/fx/Fader.h
174         include/fx/FaderReader.h
175         include/fx/HighpassCalculator.h
176         include/fx/Highpass.h
177         include/fx/IDynamicIIRFilterCalculator.h
178         include/fx/IIRFilter.h
179         include/fx/IIRFilterReader.h
180         include/fx/Limiter.h
181         include/fx/LimiterReader.h
182         include/fx/Loop.h
183         include/fx/LoopReader.h
184         include/fx/LowpassCalculator.h
185         include/fx/Lowpass.h
186         include/fx/Modulator.h
187         include/fx/ModulatorReader.h
188         include/fx/MutableReader.h
189         include/fx/MutableSound.h
190         include/fx/Pitch.h
191         include/fx/PitchReader.h
192         include/fx/PlaybackManager.h
193         include/fx/PlaybackCategory.h
194         include/fx/Reverse.h
195         include/fx/ReverseReader.h
196         include/fx/SoundList.h
197         include/fx/Source.h
198         include/fx/Sum.h
199         include/fx/Threshold.h
200         include/fx/Volume.h
201         include/fx/VolumeReader.h
202         include/fx/VolumeSound.h
203         include/fx/VolumeStorage.h
204         include/generator/Sawtooth.h
205         include/generator/SawtoothReader.h
206         include/generator/Silence.h
207         include/generator/SilenceReader.h
208         include/generator/Sine.h
209         include/generator/SineReader.h
210         include/generator/Square.h
211         include/generator/SquareReader.h
212         include/generator/Triangle.h
213         include/generator/TriangleReader.h
214         include/IReader.h
215         include/ISound.h
216         include/plugin/PluginManager.h
217         include/respec/ChannelMapper.h
218         include/respec/ChannelMapperReader.h
219         include/respec/ConverterFunctions.h
220         include/respec/Converter.h
221         include/respec/ConverterReader.h
222         include/respec/JOSResample.h
223         include/respec/JOSResampleReader.h
224         include/respec/LinearResample.h
225         include/respec/LinearResampleReader.h
226         include/respec/Mixer.h
227         include/respec/ResampleReader.h
228         include/respec/Specification.h
229         include/respec/SpecsChanger.h
230         include/sequence/AnimateableProperty.h
231         include/sequence/Double.h
232         include/sequence/DoubleReader.h
233         include/sequence/PingPong.h
234         include/sequence/SequenceData.h
235         include/sequence/SequenceEntry.h
236         include/sequence/Sequence.h
237         include/sequence/SequenceReader.h
238         include/sequence/Superpose.h
239         include/sequence/SuperposeReader.h
240         include/util/Barrier.h
241         include/util/Buffer.h
242         include/util/BufferReader.h
243         include/util/ILockable.h
244         include/util/Math3D.h
245         include/util/StreamBuffer.h
246         include/util/ThreadPool.h
247 )
248
249 set(HDR ${PRIVATE_HDR} ${PUBLIC_HDR})
250
251 set(INCLUDE ${CMAKE_CURRENT_BINARY_DIR} include)
252
253 if(WIN32)
254         set(LIBRARIES)
255         if(AUDASPACE_STANDALONE)
256                 set(DLLS)
257                 set(LIBRARY_PATH "../lib" CACHE PATH "Path which contains the libraries.")
258                 file(GLOB LIBRARY_DIRS ${LIBRARY_PATH}/*)
259                 list(APPEND CMAKE_PREFIX_PATH ${LIBRARY_DIRS})
260         endif()
261 else()
262         set(LIBRARIES ${CMAKE_DL_LIBS} -lpthread)
263 endif()
264
265 set(STATIC_PLUGINS "")
266
267 # dependencies
268
269 if(AUDASPACE_STANDALONE)
270         set(PACKAGE_OPTION QUIET)
271         list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
272
273         option(BUILD_DEMOS "Build and install demos" TRUE)
274
275         option(SHARED_LIBRARY "Build Shared Library" TRUE)
276
277         option(WITH_C "Build C Module" TRUE)
278         option(WITH_DOCS "Build C++ HTML Documentation with Doxygen" TRUE)
279         option(WITH_FFMPEG "Build With FFMPEG" TRUE)
280         option(WITH_FFTW "Build With FFTW" TRUE)
281         option(WITH_JACK "Build With Plugin" TRUE)
282         option(WITH_LIBSNDFILE "Build With LibSndFile" TRUE)
283         option(WITH_OPENAL "Build With OpenAL" TRUE)
284         option(WITH_PYTHON "Build With Python Library" TRUE)
285         option(WITH_SDL "Build With SDL" TRUE)
286         option(WITH_STRICT_DEPENDENCIES "Error and abort instead of warning if a library is not found." FALSE)
287
288         if(WITH_STRICT_DEPENDENCIES)
289                 set(PACKAGE_OPTION REQUIRED)
290         endif()
291 endif()
292
293 if(AUDASPACE_STANDALONE)
294         if(WIN32)
295                 set(DEFAULT_PLUGIN_PATH "." CACHE STRING "Default plugin installation and loading path.")
296                 set(DOCUMENTATION_INSTALL_PATH "doc" CACHE PATH "Path where the documentation is installed.")
297         else()
298                 set(DEFAULT_PLUGIN_PATH "${CMAKE_INSTALL_PREFIX}/share/audaspace/plugins" CACHE STRING "Default plugin installation and loading path.")
299                 set(DOCUMENTATION_INSTALL_PATH "share/doc/audaspace" CACHE PATH "Path where the documentation is installed.")
300         endif()
301 endif()
302
303 if(AUDASPACE_STANDALONE)
304         cmake_dependent_option(SEPARATE_C "Build C Binding as separate library" TRUE "WITH_C" FALSE)
305         cmake_dependent_option(PLUGIN_FFMPEG "Build FFMPEG Plugin" TRUE "WITH_FFMPEG;SHARED_LIBRARY" FALSE)
306         cmake_dependent_option(PLUGIN_JACK "Build JACK Plugin" TRUE "WITH_JACK;SHARED_LIBRARY" FALSE)
307         cmake_dependent_option(PLUGIN_LIBSNDFILE "Build LibSndFile Plugin" TRUE "WITH_LIBSNDFILE;SHARED_LIBRARY" FALSE)
308         cmake_dependent_option(PLUGIN_OPENAL "Build OpenAL Plugin" TRUE "WITH_OPENAL;SHARED_LIBRARY" FALSE)
309         cmake_dependent_option(PLUGIN_SDL "Build SDL Plugin" TRUE "WITH_SDL;SHARED_LIBRARY" FALSE)
310         cmake_dependent_option(WITH_PYTHON_MODULE "Build Python Module" TRUE "WITH_PYTHON" FALSE)
311         cmake_dependent_option(USE_SDL2 "Use SDL2 instead of 1 if available" TRUE "WITH_SDL" FALSE)
312         cmake_dependent_option(DYNLOAD_JACK "Dynamically load JACK" FALSE "WITH_JACK" FALSE)
313         cmake_dependent_option(WITH_BINDING_DOCS "Build C/Python HTML Documentation with Sphinx" TRUE "WITH_PYTHON_MODULE" FALSE)
314 endif()
315
316 # compiler options
317
318 if(AUDASPACE_STANDALONE)
319         if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
320                 add_definitions(-std=c++11)
321                 list(APPEND CMAKE_C_COMPILER_FLAGS "-fvisibility=hidden")
322                 list(APPEND CMAKE_CXX_COMPILER_FLAGS "-fvisibility=hidden")
323         endif()
324
325         if(MSVC)
326                 list(APPEND CMAKE_C_FLAGS_DEBUG "/Zi /Od")
327                 list(APPEND CMAKE_CXX_FLAGS_DEBUG "/Zi /Od")
328                 list(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG "/DEBUG")
329                 list(APPEND CMAKE_STATIC_LINKER_FLAGS_DEBUG "/DEBUG")
330                 list(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG")
331
332                 if(SHARED_LIBRARY)
333                         include(GenerateExportHeader)
334                 endif()
335         endif()
336
337         if(APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET)
338                 set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE)
339         endif()
340 endif()
341
342 if(MSVC)
343         add_definitions(
344                 /D_USE_MATH_DEFINES
345                 /EHsc
346                 /DNOMINMAX
347                 /D_STDINT_H
348         )
349 endif()
350
351 # platform specific options
352
353 if(MSYS OR MINGW)
354         add_definitions(-D_USE_MATH_DEFINES)
355 endif()
356
357 # C
358 if(WITH_C)
359         set(C_SRC
360                 bindings/C/AUD_ThreadPool.cpp
361                 bindings/C/AUD_Source.cpp
362                 bindings/C/AUD_Device.cpp
363                 bindings/C/AUD_DynamicMusic.cpp
364                 bindings/C/AUD_Handle.cpp
365                 bindings/C/AUD_PlaybackManager.cpp
366                 bindings/C/AUD_Sequence.cpp
367                 bindings/C/AUD_Sound.cpp
368                 bindings/C/AUD_Special.cpp
369         )
370         set(C_HDR
371                 bindings/C/AUD_ThreadPool.h
372                 bindings/C/AUD_Source.h
373                 bindings/C/AUD_Device.h
374                 bindings/C/AUD_DynamicMusic.h
375                 bindings/C/AUD_Handle.h
376                 bindings/C/AUD_PlaybackManager.h
377                 bindings/C/AUD_Sequence.h
378                 bindings/C/AUD_Sound.h
379                 bindings/C/AUD_Special.h
380                 bindings/C/AUD_Types.h
381         )
382
383 if(WITH_FFTW)
384         list(APPEND C_SRC
385                         bindings/C/AUD_HRTF.cpp
386                         bindings/C/AUD_ImpulseResponse.cpp
387                         )
388
389                 list(APPEND C_HDR
390                         bindings/C/AUD_HRTF.h
391                         bindings/C/AUD_ImpulseResponse.h
392                         )
393         endif()
394
395         if(NOT SEPARATE_C)
396                 list(APPEND SRC ${C_SRC})
397                 list(APPEND HDR ${C_HDR})
398         else()
399                 set(AUDASPACE_C_LIBRARY -laudaspace-c)
400         endif()
401 endif()
402
403 # FFMPEG
404 if(WITH_FFMPEG)
405         if(AUDASPACE_STANDALONE)
406                 find_package(FFMPEG ${PACKAGE_OPTION})
407         endif()
408
409         if(FFMPEG_FOUND)
410                 set(FFMPEG_SRC
411                         plugins/ffmpeg/FFMPEG.cpp
412                         plugins/ffmpeg/FFMPEGReader.cpp
413                         plugins/ffmpeg/FFMPEGWriter.cpp
414                 )
415                 set(FFMPEG_HDR
416                         plugins/ffmpeg/FFMPEG.h
417                         plugins/ffmpeg/FFMPEGReader.h
418                         plugins/ffmpeg/FFMPEGWriter.h
419                 )
420
421                 if(NOT PLUGIN_FFMPEG)
422                         list(APPEND INCLUDE ${FFMPEG_INCLUDE_DIRS})
423                         list(APPEND LIBRARIES ${FFMPEG_LIBRARIES})
424                         list(APPEND SRC ${FFMPEG_SRC})
425                         list(APPEND HDR ${FFMPEG_HDR})
426                         list(APPEND STATIC_PLUGINS FFMPEG)
427                 endif()
428
429                 if(WIN32 AND AUDASPACE_STANDALONE)
430                         file(GLOB FFMPEG_DLLS ${LIBRARY_PATH}/ffmpeg/bin/*.dll)
431                         list(APPEND DLLS ${FFMPEG_DLLS})
432                 endif()
433         else()
434                 set(WITH_FFMPEG FALSE CACHE BOOL "Build With FFMPEG" FORCE)
435                 message(WARNING "FFMPEG not found, plugin will not be built.")
436         endif()
437 endif()
438
439 # FFTW
440 if(WITH_FFTW)
441         if(AUDASPACE_STANDALONE)
442                 find_package(FFTW ${PACKAGE_OPTION})
443         endif()
444
445         if(FFTW_FOUND)
446                 set(FFTW_SRC
447                         src/fx/BinauralSound.cpp
448                         src/fx/BinauralReader.cpp
449                         src/fx/Convolver.cpp
450                         src/fx/ConvolverReader.cpp
451                         src/fx/ConvolverSound.cpp
452                         src/fx/FFTConvolver.cpp
453                         src/fx/HRTF.cpp
454                         src/fx/ImpulseResponse.cpp
455                         src/util/FFTPlan.cpp
456                 )
457         set(FFTW_HDR
458                 include/fx/BinauralSound.h
459                         include/fx/BinauralReader.h
460                         include/fx/Convolver.h
461                         include/fx/ConvolverReader.h
462                         include/fx/ConvolverSound.h
463                         include/fx/FFTConvolver.h
464                         include/fx/HRTF.h
465                         include/fx/HRTFLoader.h
466                         include/fx/ImpulseResponse.h
467                         include/util/FFTPlan.h
468                 )
469
470                 add_definitions(-DWITH_CONVOLUTION)
471
472                 list(APPEND INCLUDE ${FFTW_INCLUDE_DIR})
473                 list(APPEND LIBRARIES ${FFTW_LIBRARY})
474
475                 list(APPEND SRC ${FFTW_SRC})
476                 list(APPEND HDR ${FFTW_HDR})
477
478                 if(WIN32 AND AUDASPACE_STANDALONE)
479                         file(GLOB FFTW_DLLS ${LIBRARY_PATH}/fftw/bin/*.dll)
480                         list(APPEND DLLS ${FFTW_DLLS})
481                 endif()
482         else()
483                 set(WITH_FFTW FALSE CACHE BOOL "Build With FFTW" FORCE)
484                 message(WARNING "FFTW not found, convolution functionality will not be built.")
485         endif()
486 endif()
487
488 # JACK
489 if(WITH_JACK)
490         if(AUDASPACE_STANDALONE)
491                 find_package(Jack ${PACKAGE_OPTION})
492         endif()
493
494         if(JACK_FOUND)
495                 set(JACK_SRC
496                         plugins/jack/JackDevice.cpp
497                         plugins/jack/JackSynchronizer.cpp
498                         plugins/jack/JackLibrary.cpp
499                 )
500                 set(JACK_HDR
501                         plugins/jack/JackDevice.h
502                         plugins/jack/JackSynchronizer.h
503                         plugins/jack/JackLibrary.h
504                         plugins/jack/JackSymbols.h
505                 )
506
507         if(DYNLOAD_JACK)
508                         add_definitions(-DDYNLOAD_JACK)
509                 endif()
510
511                 if(NOT PLUGIN_JACK)
512                         list(APPEND INCLUDE ${JACK_INCLUDE_DIRS})
513                         if(NOT DYNLOAD_JACK)
514                                 list(APPEND LIBRARIES ${JACK_LIBRARIES})
515                         endif()
516                         list(APPEND SRC ${JACK_SRC})
517                         list(APPEND HDR ${JACK_HDR})
518                         list(APPEND STATIC_PLUGINS JackDevice)
519                 endif()
520
521                 if(WIN32 AND AUDASPACE_STANDALONE)
522                         file(GLOB JACK_DLLS ${LIBRARY_PATH}/jack/bin/*.dll)
523                         list(APPEND DLLS ${JACK_DLLS})
524                 endif()
525         else()
526                 set(WITH_JACK FALSE CACHE BOOL "Build With JACK" FORCE)
527                 message(WARNING "JACK not found, plugin will not be built.")
528         endif()
529 endif()
530
531 # LibSndFile
532 if(WITH_LIBSNDFILE)
533         if(AUDASPACE_STANDALONE)
534                 find_package(LibSndFile ${PACKAGE_OPTION})
535         endif()
536
537         if(LIBSNDFILE_FOUND)
538                 set(LIBSNDFILE_SRC
539                         plugins/libsndfile/SndFile.cpp
540                         plugins/libsndfile/SndFileReader.cpp
541                         plugins/libsndfile/SndFileWriter.cpp
542                 )
543                 set(LIBSNDFILE_HDR
544                         plugins/libsndfile/SndFile.h
545                         plugins/libsndfile/SndFileReader.h
546                         plugins/libsndfile/SndFileWriter.h
547                 )
548
549                 if(NOT PLUGIN_LIBSNDFILE)
550                         list(APPEND INCLUDE ${LIBSNDFILE_INCLUDE_DIRS})
551                         list(APPEND LIBRARIES ${LIBSNDFILE_LIBRARIES})
552                         list(APPEND SRC ${LIBSNDFILE_SRC})
553                         list(APPEND HDR ${LIBSNDFILE_HDR})
554                         list(APPEND STATIC_PLUGINS SndFile)
555                 endif()
556
557                 if(WIN32 AND AUDASPACE_STANDALONE)
558                         file(GLOB LIBSNDFILE_DLLS ${LIBRARY_PATH}/libsndfile/bin/*.dll)
559                         list(APPEND DLLS ${LIBSNDFILE_DLLS})
560                 endif()
561         else()
562                 set(WITH_LIBSNDFILE FALSE CACHE BOOL "Build With LibSndFile" FORCE)
563                 message(WARNING "LibSndFile not found, plugin will not be built.")
564         endif()
565 endif()
566
567 # OpenAL
568 if(WITH_OPENAL)
569         if(AUDASPACE_STANDALONE)
570                 find_package(OpenAL ${PACKAGE_OPTION})
571         endif()
572
573         if(OPENAL_FOUND)
574                 set(OPENAL_SRC
575                         plugins/openal/OpenALDevice.cpp
576                         plugins/openal/OpenALReader.cpp
577                 )
578                 set(OPENAL_HDR
579                         plugins/openal/OpenALDevice.h
580                         plugins/openal/OpenALReader.h
581                 )
582
583                 if(NOT PLUGIN_OPENAL)
584                         list(APPEND INCLUDE ${OPENAL_INCLUDE_DIR})
585                         list(APPEND LIBRARIES ${OPENAL_LIBRARY})
586                         list(APPEND SRC ${OPENAL_SRC})
587                         list(APPEND HDR ${OPENAL_HDR})
588                         list(APPEND STATIC_PLUGINS OpenALDevice)
589                 endif()
590
591                 if(WIN32 AND AUDASPACE_STANDALONE)
592                         file(GLOB OPENAL_DLLS ${LIBRARY_PATH}/OpenAL/bin/*.dll)
593                         list(APPEND DLLS ${OPENAL_DLLS})
594                 endif()
595         else()
596                 set(WITH_OPENAL FALSE CACHE BOOL "Build With OpenAL" FORCE)
597                 message(WARNING "OpenAL not found, plugin will not be built.")
598         endif()
599 endif()
600
601 # Python
602 if(WITH_PYTHON)
603         if(AUDASPACE_STANDALONE)
604                 find_package(PythonLibs 3.2 ${PACKAGE_OPTION})
605                 find_package(NumPy ${PACKAGE_OPTION})
606         endif()
607
608         if(PYTHONLIBS_FOUND AND NUMPY_FOUND)
609                 list(APPEND INCLUDE ${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIRS})
610
611                 if(WITH_PYTHON_MODULE)
612                         find_package(PythonInterp 3.2 ${PACKAGE_OPTION})
613
614                         if(NOT PYTHONINTERP_FOUND)
615                                 set(WITH_PYTHON_MODULE FALSE)
616                                 message(WARNING "Python interpreter not found, module will not be built.")
617                         endif()
618                 endif()
619
620                 set(AUDASPACE_PY_LIBRARY -laudaspace-py)
621
622                 if(WIN32 AND AUDASPACE_STANDALONE)
623                         file(GLOB PYTHON_DLLS ${LIBRARY_PATH}/Python/bin/*.dll)
624                         list(APPEND DLLS ${PYTHON_DLLS})
625                 endif()
626         else()
627                 set(WITH_PYTHON FALSE CACHE BOOL "Build With Python Library" FORCE)
628                 message(WARNING "Python libraries not found, language binding will not be built.")
629         endif()
630 endif()
631
632 # SDL
633 if(WITH_SDL)
634         if(AUDASPACE_STANDALONE)
635                 if(USE_SDL2)
636                         find_package(SDL2)
637                         if(SDL2_FOUND)
638                                 set(SDL_INCLUDE_DIR ${SDL2_INCLUDE_DIR})
639                                 set(SDL_LIBRARY ${SDL2_LIBRARY})
640                                 set(SDL_FOUND TRUE)
641                         else()
642                                 find_package(SDL ${PACKAGE_OPTION})
643                         endif()
644                 else()
645                         find_package(SDL ${PACKAGE_OPTION})
646                 endif()
647         endif()
648
649         if(SDL_FOUND)
650                 set(SDL_SRC
651                         plugins/sdl/SDLDevice.cpp
652                 )
653                 set(SDL_HDR
654                         plugins/sdl/SDLDevice.h
655                 )
656
657                 if(NOT PLUGIN_SDL)
658                         list(APPEND INCLUDE ${SDL_INCLUDE_DIR})
659                         list(APPEND LIBRARIES ${SDL_LIBRARY})
660                         list(APPEND SRC ${SDL_SRC})
661                         list(APPEND HDR ${SDL_HDR})
662                         list(APPEND STATIC_PLUGINS SDLDevice)
663                 endif()
664
665                 if(WIN32 AND AUDASPACE_STANDALONE)
666                         file(GLOB SDL_DLLS ${LIBRARY_PATH}/sdl/bin/*.dll)
667                         list(APPEND DLLS ${SDL_DLLS})
668                 endif()
669         else()
670                 set(WITH_SDL FALSE CACHE BOOL "Build With SDL" FORCE)
671                 message(WARNING "SDL not found, plugin will not be built.")
672         endif()
673 endif()
674
675 # library configuration
676
677 if(SHARED_LIBRARY)
678         set(AUD_LIBRARY_TYPE AUD_SHARED_LIBRARY)
679         set(LIBRARY_TYPE SHARED)
680         add_definitions(-DAUD_BUILD_SHARED_LIBRARY)
681 else()
682         set(AUD_LIBRARY_TYPE AUD_STATIC_LIBRARY)
683         set(LIBRARY_TYPE STATIC)
684 endif()
685
686 # file configuration
687
688 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/Audaspace.h.in ${CMAKE_CURRENT_BINARY_DIR}/Audaspace.h ESCAPE_QUOTES @ONLY)
689
690 list(APPEND HDR ${CMAKE_CURRENT_BINARY_DIR}/Audaspace.h)
691
692 set(STATIC_PLUGIN_CLASSES "")
693 set(STATIC_PLUGIN_REGISTERS "")
694
695 foreach(PLUGIN ${STATIC_PLUGINS})
696         list(APPEND STATIC_PLUGIN_CLASSES "STATIC_PLUGIN_CLASS(" ${PLUGIN} ")\n")
697         list(APPEND STATIC_PLUGIN_REGISTERS "\tSTATIC_PLUGIN_REGISTER(" ${PLUGIN} ")\n")
698 endforeach()
699
700 string(CONCAT STATIC_PLUGIN_CLASSES ${STATIC_PLUGIN_CLASSES})
701 string(CONCAT STATIC_PLUGIN_REGISTERS ${STATIC_PLUGIN_REGISTERS})
702
703 if(WIN32)
704         configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/plugin/PluginManagerWindows.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/PluginManager.cpp ESCAPE_QUOTES @ONLY)
705         if(WITH_FFTW)
706                 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/fx/HRTFLoaderWindows.cpp ${CMAKE_CURRENT_BINARY_DIR}/HRTFLoader.cpp COPYONLY)
707         endif()
708 else()
709         configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/plugin/PluginManagerUnix.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/PluginManager.cpp ESCAPE_QUOTES @ONLY)
710         if(WITH_FFTW)
711                 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/fx/HRTFLoaderUnix.cpp ${CMAKE_CURRENT_BINARY_DIR}/HRTFLoader.cpp COPYONLY)
712         endif()
713 endif()
714
715 list(APPEND SRC ${CMAKE_CURRENT_BINARY_DIR}/PluginManager.cpp)
716 if(WITH_FFTW)
717         list(APPEND SRC ${CMAKE_CURRENT_BINARY_DIR}/HRTFLoader.cpp)
718 endif()
719
720 # directories
721
722 include_directories(${INCLUDE})
723 link_directories()
724
725 # install configuration
726
727 if(WIN32)
728         set(BIN_DESTINATION ".")
729 else()
730         set(BIN_DESTINATION "bin")
731 endif()
732
733 set(LIB_DESTINATION "lib${LIB_SUFFIX}")
734
735 # library
736
737 add_library(audaspace ${LIBRARY_TYPE} ${SRC} ${HDR})
738 target_link_libraries(audaspace ${LIBRARIES})
739 set_target_properties(audaspace PROPERTIES SOVERSION ${AUDASPACE_VERSION})
740
741 if(AUDASPACE_STANDALONE)
742         install(TARGETS audaspace
743                 RUNTIME DESTINATION ${BIN_DESTINATION}
744                 LIBRARY DESTINATION ${LIB_DESTINATION}
745                 ARCHIVE DESTINATION ${LIB_DESTINATION}
746         )
747
748         install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include/audaspace)
749         install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Audaspace.h DESTINATION include/audaspace)
750
751         configure_file(${CMAKE_CURRENT_SOURCE_DIR}/packages/pkgconfig/audaspace.pc.in ${CMAKE_CURRENT_BINARY_DIR}/audaspace.pc @ONLY)
752
753         if(NOT WIN32 AND NOT APPLE)
754                 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/audaspace.pc DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
755         endif()
756 endif()
757
758 # plugins
759
760 if(WITH_FFMPEG AND PLUGIN_FFMPEG)
761         add_definitions(-DFFMPEG_PLUGIN)
762         include_directories(${INCLUDE} ${FFMPEG_INCLUDE_DIRS})
763         add_library(audffmpeg SHARED ${FFMPEG_SRC} ${FFMPEG_HDR} ${HDR})
764         target_link_libraries(audffmpeg audaspace ${FFMPEG_LIBRARIES})
765         set_target_properties(audffmpeg PROPERTIES SOVERSION ${AUDASPACE_VERSION})
766         install(TARGETS audffmpeg DESTINATION ${DEFAULT_PLUGIN_PATH})
767 endif()
768
769 if(WITH_JACK AND PLUGIN_JACK)
770         add_definitions(-DJACK_PLUGIN)
771         include_directories(${INCLUDE} ${JACK_INCLUDE_DIRS})
772         add_library(audjack SHARED ${JACK_SRC} ${JACK_HDR} ${HDR})
773         if(DYNLOAD_JACK)
774                 target_link_libraries(audjack audaspace)
775         else()
776                 target_link_libraries(audjack audaspace ${JACK_LIBRARIES})
777         endif()
778         set_target_properties(audjack PROPERTIES SOVERSION ${AUDASPACE_VERSION})
779         install(TARGETS audjack DESTINATION ${DEFAULT_PLUGIN_PATH})
780 endif()
781
782 if(WITH_LIBSNDFILE AND PLUGIN_LIBSNDFILE)
783         add_definitions(-DLIBSNDFILE_PLUGIN)
784         include_directories(${INCLUDE} ${LIBSNDFILE_INCLUDE_DIRS})
785         add_library(audlibsndfile SHARED ${LIBSNDFILE_SRC} ${LIBSNDFILE_HDR} ${HDR})
786         set_target_properties(audlibsndfile PROPERTIES SOVERSION ${AUDASPACE_VERSION})
787         target_link_libraries(audlibsndfile audaspace ${LIBSNDFILE_LIBRARIES})
788         install(TARGETS audlibsndfile DESTINATION ${DEFAULT_PLUGIN_PATH})
789 endif()
790
791 if(WITH_OPENAL AND PLUGIN_OPENAL)
792         add_definitions(-DOPENAL_PLUGIN)
793         include_directories(${INCLUDE} ${OPENAL_INCLUDE_DIR})
794         add_library(audopenal SHARED ${OPENAL_SRC} ${OPENAL_HDR} ${HDR})
795         set_target_properties(audopenal PROPERTIES SOVERSION ${AUDASPACE_VERSION})
796         target_link_libraries(audopenal audaspace ${OPENAL_LIBRARY})
797         install(TARGETS audopenal DESTINATION ${DEFAULT_PLUGIN_PATH})
798 endif()
799
800 if(WITH_SDL AND PLUGIN_SDL)
801         add_definitions(-DSDL_PLUGIN)
802         include_directories(${INCLUDE} ${SDL_INCLUDE_DIR})
803         add_library(audsdl SHARED ${SDL_SRC} ${SDL_HDR} ${HDR})
804         set_target_properties(audsdl PROPERTIES SOVERSION ${AUDASPACE_VERSION})
805         target_link_libraries(audsdl audaspace ${SDL_LIBRARY})
806         install(TARGETS audsdl DESTINATION ${DEFAULT_PLUGIN_PATH})
807 endif()
808
809 # dlls
810
811 if(WIN32)
812         if(DLLS)
813                 install(FILES ${DLLS} DESTINATION ${BIN_DESTINATION})
814         endif()
815 endif()
816
817 # demos
818
819 if(BUILD_DEMOS)
820         include_directories(${INCLUDE})
821
822         set(DEMOS audaplay audaconvert audaremap signalgen randsounds dynamicmusic playbackmanager)
823
824         add_executable(audaplay demos/audaplay.cpp)
825         target_link_libraries(audaplay audaspace)
826
827         add_executable(audaconvert demos/audaconvert.cpp)
828         target_link_libraries(audaconvert audaspace)
829
830         add_executable(audaremap demos/audaremap.cpp)
831         target_link_libraries(audaremap audaspace)
832
833         add_executable(signalgen demos/signalgen.cpp)
834         target_link_libraries(signalgen audaspace)
835
836         add_executable(randsounds demos/randsounds.cpp)
837         target_link_libraries(randsounds audaspace)
838
839         add_executable(dynamicmusic demos/dynamicmusic.cpp)
840         target_link_libraries(dynamicmusic audaspace)
841
842         add_executable(playbackmanager demos/playbackmanager.cpp)
843         target_link_libraries(playbackmanager audaspace)
844
845         if(WITH_FFTW)
846                 list(APPEND DEMOS convolution binaural)
847
848                 add_executable(convolution demos/convolution.cpp)
849                 target_link_libraries(convolution audaspace)
850
851                 add_executable(binaural demos/binaural.cpp)
852                 target_link_libraries(binaural audaspace)
853         endif()
854
855         if(WITH_OPENAL)
856                 list(APPEND DEMOS openaldevices)
857
858                 add_executable(openaldevices demos/openaldevices.cpp)
859                 if(PLUGIN_OPENAL)
860                         target_link_libraries(openaldevices audaspace audopenal)
861                 else()
862                         target_link_libraries(openaldevices audaspace)
863                 endif()
864         endif()
865
866         install(TARGETS ${DEMOS}
867                 RUNTIME DESTINATION ${BIN_DESTINATION}
868                 LIBRARY DESTINATION ${LIB_DESTINATION}
869                 ARCHIVE DESTINATION ${LIB_DESTINATION}
870         )
871 endif()
872
873 # bindings
874
875 if(WITH_C)
876         if(SEPARATE_C)
877                 add_library(audaspace-c ${LIBRARY_TYPE} ${C_SRC} ${C_HDR})
878                 target_link_libraries(audaspace-c audaspace)
879                 set_target_properties(audaspace-c PROPERTIES SOVERSION ${AUDASPACE_VERSION})
880                 install(TARGETS audaspace-c
881                         RUNTIME DESTINATION ${BIN_DESTINATION}
882                         LIBRARY DESTINATION ${LIB_DESTINATION}
883                         ARCHIVE DESTINATION ${LIB_DESTINATION}
884                 )
885         endif()
886
887         if(AUDASPACE_STANDALONE)
888                 install(FILES ${C_HDR} DESTINATION include/audaspace)
889         endif()
890 endif()
891
892 if(WITH_PYTHON)
893         set(PYTHON_SRC
894                 bindings/python/PyAPI.cpp
895                 bindings/python/PyDevice.cpp
896                 bindings/python/PyDynamicMusic.cpp
897                 bindings/python/PyHandle.cpp
898                 bindings/python/PyPlaybackManager.cpp
899                 bindings/python/PySequence.cpp
900                 bindings/python/PySequenceEntry.cpp
901                 bindings/python/PySound.cpp
902                 bindings/python/PySource.cpp
903                 bindings/python/PyThreadPool.cpp
904         )
905         set(PYTHON_HDR
906                 bindings/python/PyAPI.h
907                 bindings/python/PyDevice.h
908                 bindings/python/PyDynamicMusic.h
909                 bindings/python/PyHandle.h
910                 bindings/python/PyPlaybackManager.h
911                 bindings/python/PySequence.h
912                 bindings/python/PySequenceEntry.h
913                 bindings/python/PySound.h
914                 bindings/python/PySource.h
915                 bindings/python/PyThreadPool.h
916         )
917
918         if(WITH_FFTW)
919                 list(APPEND PYTHON_SRC
920                         bindings/python/PyHRTF.cpp
921                         bindings/python/PyImpulseResponse.cpp
922                         )
923                 list(APPEND PYTHON_HDR
924                         bindings/python/PyHRTF.h
925                         bindings/python/PyImpulseResponse.h
926                         )
927         endif()
928
929         add_library(audaspace-py ${LIBRARY_TYPE} ${PYTHON_SRC} ${PYTHON_HDR})
930         target_link_libraries(audaspace-py audaspace ${PYTHON_LIBRARIES})
931         set_target_properties(audaspace-py PROPERTIES SOVERSION ${AUDASPACE_VERSION})
932
933         if(AUDASPACE_STANDALONE)
934                 install(TARGETS audaspace-py
935                         RUNTIME DESTINATION ${BIN_DESTINATION}
936                         LIBRARY DESTINATION ${LIB_DESTINATION}
937                         ARCHIVE DESTINATION ${LIB_DESTINATION}
938                 )
939
940                 install(FILES ${PYTHON_HDR} DESTINATION include/audaspace/python)
941         endif()
942
943         if(WITH_PYTHON_MODULE)
944                 set(PYTHON_SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bindings/python)
945                 configure_file(${PYTHON_SOURCE_DIRECTORY}/setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py ESCAPE_QUOTES @ONLY)
946
947                 if(APPLE)
948                         add_custom_command(OUTPUT build COMMAND MACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR})
949                 elseif(WIN32)
950                         set(ENV{VS100COMNTOOLS} $ENV{VS120COMNTOOLS})
951                         add_custom_command(OUTPUT build COMMAND ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR})
952                 else()
953                         add_custom_command(OUTPUT build COMMAND ${PYTHON_EXECUTABLE} setup.py build DEPENDS ${PYTHON_SRC} ${PYTHON_HDR})
954                 endif()
955                 add_custom_target(pythonmodule ALL DEPENDS build SOURCES ${PYTHON_SOURCE_DIRECTORY}/setup.py.in ${PYTHON_SRC} ${PYTHON_HDR})
956                 add_dependencies(pythonmodule audaspace)
957
958                 install(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} setup.py install --root=\$ENV{DESTDIR} --prefix=${CMAKE_INSTALL_PREFIX})")
959         endif()
960 endif()
961
962 # docs
963
964 if(WITH_DOCS)
965         find_package(Doxygen ${PACKAGE_OPTION})
966
967         if(DOXYGEN_FOUND AND DOXYGEN_DOT_FOUND)
968                 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
969
970                 add_custom_target(audaspace_doc ALL ${DOXYGEN_EXECUTABLE} Doxyfile COMMENT "Building C++ HTML documentation with Doxygen.")
971         else()
972                 set(WITH_DOCS FALSE CACHE BOOL "Build C++ HTML Documentation with Doxygen" FORCE)
973                 message(WARNING "Doxygen (and/or dot) not found, documentation will not be built.")
974         endif()
975 endif()
976
977 if(WITH_BINDING_DOCS)
978         find_package(Sphinx ${PACKAGE_OPTION})
979
980         if(SPHINX_FOUND)
981                 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bindings/doc/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/conf.py @ONLY)
982
983                 add_custom_target(bindings_doc ALL COMMAND ${PYTHON_EXECUTABLE} setup.py --build-docs ${SPHINX_EXECUTABLE} -q -b html -c "${CMAKE_CURRENT_BINARY_DIR}" -d "${CMAKE_CURRENT_BINARY_DIR}/_doctrees" "${CMAKE_CURRENT_SOURCE_DIR}/bindings/doc" "${CMAKE_CURRENT_BINARY_DIR}/doc/bindings" DEPENDS pythonmodule COMMENT "Building C/Python HTML documentation with Sphinx.")
984         else()
985                 set(WITH_BINDING_DOCS FALSE CACHE BOOL "Build C/Python HTML Documentation with Sphinx" FORCE)
986                 message(WARNING "Sphinx not found, binding documentation will not be built.")
987         endif()
988 endif()
989
990 if(WITH_DOCS OR WITH_BINDING_DOCS)
991         install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/ DESTINATION ${DOCUMENTATION_INSTALL_PATH})
992 endif()