CMakeLists.txt 28 KB

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