Collection of tools useful for audio production
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

372 lines
11KB

  1. #checking include/library paths
  2. message(STATUS "Checking Include Path" $ENV{CMAKE_INCLUDE_PATH} ${CMAKE_INCLUDE_PATH})
  3. message(STATUS "Checking Library Path" $ENV{CMAKE_LIBRARY_PATH} ${CMAKE_LIBRARY_PATH})
  4. #Dependency check
  5. find_package(PkgConfig REQUIRED)
  6. find_package(zlib REQUIRED)
  7. pkg_check_modules(FFTW REQUIRED fftw3)
  8. pkg_check_modules(MXML REQUIRED mxml)
  9. find_package(Threads REQUIRED)
  10. find_package(OSS)
  11. find_package(Alsa)
  12. pkg_check_modules(JACK jack)
  13. pkg_check_modules(PORTAUDIO portaudio-2.0>=19)
  14. set(FLTK_SKIP_OPENGL true)
  15. find_package(NTK)
  16. find_package(FLTK)
  17. find_package(OpenGL) #for FLTK
  18. find_package(CxxTest)
  19. if(CXXTEST_FOUND)
  20. set(CXXTEST_USE_PYTHON TRUE)
  21. endif()
  22. # lash
  23. pkg_search_module(LASH lash-1.0)
  24. mark_as_advanced(LASH_LIBRARIES)
  25. pkg_search_module(DSSI dssi>=0.9.0)
  26. mark_as_advanced(DSSI_LIBRARIES)
  27. pkg_search_module(LIBLO liblo>=0.26)
  28. mark_as_advanced(LIBLO_LIBRARIES)
  29. ######### Settings ###########
  30. # NOTE: These cache variables should normally not be changed in this
  31. # file, but either in in CMakeCache.txt before compile, or by passing
  32. # parameters directly into cmake using the -D flag.
  33. SET (GuiModule fltk CACHE STRING "GUI module, either fltk, qt or off")
  34. SET (CompileTests ${CXXTEST_FOUND} CACHE BOOL "whether tests should be compiled in or not")
  35. SET (AlsaEnable ${ALSA_FOUND} CACHE BOOL
  36. "Enable support for Advanced Linux Sound Architecture")
  37. SET (JackEnable ${JACK_FOUND} CACHE BOOL
  38. "Enable support for JACK Audio Connection toolKit")
  39. SET (OssEnable ${OSS_FOUND} CACHE BOOL
  40. "Enable support for Open Sound System")
  41. SET (PaEnable ${PORTAUDIO_FOUND} CACHE BOOL
  42. "Enable support for Port Audio System")
  43. SET (LashEnable ${LASH_FOUND} CACHE BOOL
  44. "Enable LASH Audio Session Handler")
  45. SET (DssiEnable ${DSSI_FOUND} CACHE BOOL
  46. "Enable DSSI Plugin compilation")
  47. SET (LibloEnable ${LIBLO_FOUND} CACHE BOOL
  48. "Enable Liblo")
  49. # Now, handle the incoming settings and set define flags/variables based
  50. # on this
  51. # Add version information
  52. add_definitions(-DVERSION="${VERSION}")
  53. # Give a good guess on the best Input/Output default backends
  54. if (JackEnable)
  55. SET (DefaultOutput jack CACHE STRING
  56. "Default Output module: [null, alsa, oss, jack, portaudio]")
  57. # Override with perhaps more helpful midi backends
  58. if (AlsaEnable)
  59. SET (DefaultInput alsa CACHE STRING
  60. "Default Input module: [null, alsa, oss, jack]")
  61. elseif (OssEnable)
  62. SET (DefaultInput oss CACHE STRING
  63. "Default Input module: [null, alsa, oss, jack]")
  64. else ()
  65. SET (DefaultInput jack CACHE STRING
  66. "Default Input module: [null, alsa, oss, jack]")
  67. endif ()
  68. elseif (AlsaEnable)
  69. SET (DefaultOutput alsa CACHE STRING
  70. "Default Output module: [null, alsa, oss, jack, portaudio]")
  71. SET (DefaultInput alsa CACHE STRING
  72. "Default Input module: [null, alsa, oss, jack]")
  73. elseif (OssEnable)
  74. SET (DefaultOutput oss CACHE STRING
  75. "Default Output module: [null, alsa, oss, jack, portaudio]")
  76. SET (DefaultInput oss CACHE STRING
  77. "Default Input module: [null, alsa, oss, jack]")
  78. else()
  79. SET (DefaultOutput null CACHE STRING
  80. "Default Output module: [null, alsa, oss, jack, portaudio]")
  81. SET (DefaultInput null CACHE STRING
  82. "Default Input module: [null, alsa, oss, jack]")
  83. endif()
  84. if (GuiModule STREQUAL qt AND QT_FOUND)
  85. set (QtGui TRUE)
  86. elseif(GuiModule STREQUAL ntk AND NTK_FOUND)
  87. set (NtkGui TRUE)
  88. elseif(GuiModule STREQUAL fltk AND FLTK_FOUND)
  89. set (FltkGui TRUE)
  90. elseif(GuiModule STREQUAL off)
  91. add_definitions(-DDISABLE_GUI)
  92. else ()
  93. set (GuiModule off CACHE STRING "GUI module, either fltk, qt or off")
  94. add_definitions(-DDISABLE_GUI)
  95. message(STATUS "GUI module defaulting to off")
  96. endif()
  97. #Build Flags
  98. option (BuildForAMD_X86_64 "Build for AMD x86_64 system" OFF)
  99. option (BuildForCore2_X86_64 "Build for Intel Core2 x86_64 system" OFF)
  100. option (BuildForDebug "Include gdb debugging support" OFF)
  101. set(CMAKE_BUILD_TYPE "Release")
  102. set (BuildOptions_x86_64AMD
  103. "-O3 -march=athlon64 -m64 -Wall -ffast-math -fno-finite-math-only -fomit-frame-pointer"
  104. CACHE STRING "X86_64 compiler options"
  105. )
  106. set (BuildOptions_X86_64Core2
  107. "-O3 -march=core2 -m64 -Wall -ffast-math -fno-finite-math-only -fomit-frame-pointer"
  108. CACHE STRING "X86_64 compiler options"
  109. )
  110. set (BuildOptionsBasic
  111. "-O3 -msse -msse2 -mfpmath=sse -ffast-math -fomit-frame-pointer"
  112. CACHE STRING "basic X86 complier options"
  113. )
  114. set (BuildOptionsDebug
  115. "-O0 -g3 -ggdb -Wall -Wpointer-arith" CACHE STRING "Debug build flags")
  116. ########### Settings dependant code ###########
  117. # From here on, the setting variables have been prepared so concentrate
  118. # on the actual compiling.
  119. if(AlsaEnable)
  120. list(APPEND AUDIO_LIBRARIES ${ASOUND_LIBRARY})
  121. list(APPEND AUDIO_LIBRARY_DIRS ${ASOUND_LIBRARY_DIRS})
  122. add_definitions(-DALSA=1)
  123. endif(AlsaEnable)
  124. if(JackEnable)
  125. list(APPEND AUDIO_LIBRARIES ${JACK_LIBRARIES})
  126. list(APPEND AUDIO_LIBRARY_DIRS ${JACK_LIBRARY_DIRS})
  127. add_definitions(-DJACK=1)
  128. endif(JackEnable)
  129. if(OssEnable)
  130. add_definitions(-DOSS=1)
  131. endif(OssEnable)
  132. if(PaEnable)
  133. include_directories(${PORTAUDIO_INCLUDE_DIR})
  134. add_definitions(-DPORTAUDIO=1)
  135. list(APPEND AUDIO_LIBRARIES ${PORTAUDIO_LIBRARIES})
  136. list(APPEND AUDIO_LIBRARY_DIRS ${PORTAUDIO_LIBRARY_DIRS})
  137. endif()
  138. if (CompileTests)
  139. ENABLE_TESTING()
  140. endif()
  141. if(LashEnable)
  142. include_directories(${LASH_INCLUDE_DIRS})
  143. add_definitions(-DLASH=1)
  144. list(APPEND AUDIO_LIBRARIES ${LASH_LIBRARIES})
  145. list(APPEND AUDIO_LIBRARY_DIRS ${LASH_LIBRARY_DIRS})
  146. message(STATUS "Compiling with lash")
  147. endif()
  148. if(LibloEnable)
  149. include_directories(${LIBLO_INCLUDE_DIRS})
  150. add_definitions(-DUSE_NSM=1)
  151. list(APPEND AUDIO_LIBRARIES ${LIBLO_LIBRARIES})
  152. list(APPEND AUDIO_LIBRARY_DIRS ${LIBLO_LIBRARY_DIRS})
  153. message(STATUS "Compiling with liblo")
  154. endif()
  155. # other include directories
  156. include_directories(${ZLIB_INCLUDE_DIRS} ${MXML_INCLUDE_DIRS})
  157. add_definitions(
  158. -DASM_F2I_YES
  159. -g #TODO #todo put in a better location
  160. -Wall
  161. -Wextra
  162. )
  163. if (BuildForDebug)
  164. set (CMAKE_BUILD_TYPE "Debug")
  165. set (CMAKE_CXX_FLAGS_DEBUG ${BuildOptionsDebug})
  166. message (STATUS "Building for ${CMAKE_BUILD_TYPE}, flags: ${CMAKE_CXX_FLAGS_DEBUG}")
  167. else (BuildForDebug)
  168. set (CMAKE_BUILD_TYPE "Release")
  169. if (BuildForAMD_X86_64)
  170. set (CMAKE_CXX_FLAGS_RELEASE ${BuildOptions_x86_64AMD})
  171. else (BuildForAMD_X86_64)
  172. if (BuildForCore2_X86_64)
  173. set (CMAKE_CXX_FLAGS_RELEASE ${BuildOptions_X86_64Core2})
  174. else (BuildForCore2_X86_64)
  175. set (CMAKE_CXX_FLAGS_RELEASE ${BuildOptionsBasic})
  176. endif (BuildForCore2_X86_64)
  177. endif (BuildForAMD_X86_64)
  178. message (STATUS "Building for ${CMAKE_BUILD_TYPE}, flags: ${CMAKE_CXX_FLAGS_RELEASE}")
  179. endif (BuildForDebug)
  180. add_definitions(-fPIC)
  181. if(FLTK_FOUND)
  182. mark_as_advanced(FORCE FLTK_BASE_LIBRARY)
  183. mark_as_advanced(FORCE FLTK_CONFIG_SCRIPT)
  184. mark_as_advanced(FORCE FLTK_DIR)
  185. mark_as_advanced(FORCE FLTK_FLUID_EXECUTABLE)
  186. mark_as_advanced(FORCE FLTK_FORMS_LIBRARY)
  187. mark_as_advanced(FORCE FLTK_GL_LIBRARY)
  188. mark_as_advanced(FORCE FLTK_IMAGES_LIBRARY)
  189. mark_as_advanced(FORCE FLTK_INCLUDE_DIR)
  190. mark_as_advanced(FORCE FLTK_MATH_LIBRARY)
  191. endif(FLTK_FOUND)
  192. if(NTK_FOUND)
  193. mark_as_advanced(FORCE NTK_BASE_LIBRARY)
  194. mark_as_advanced(FORCE NTK_CONFIG_SCRIPT)
  195. mark_as_advanced(FORCE NTK_DIR)
  196. mark_as_advanced(FORCE NTK_FLUID_EXECUTABLE)
  197. mark_as_advanced(FORCE NTK_FORMS_LIBRARY)
  198. mark_as_advanced(FORCE NTK_GL_LIBRARY)
  199. mark_as_advanced(FORCE NTK_IMAGES_LIBRARY)
  200. mark_as_advanced(FORCE NTK_INCLUDE_DIR)
  201. mark_as_advanced(FORCE NTK_MATH_LIBRARY)
  202. endif(NTK_FOUND)
  203. if(FltkGui)
  204. #UGLY WORKAROUND
  205. find_program (FLTK_CONFIG fltk-config)
  206. if (FLTK_CONFIG)
  207. execute_process (COMMAND ${FLTK_CONFIG} --use-images --ldflags OUTPUT_VARIABLE FLTK_LDFLAGS)
  208. string(STRIP ${FLTK_LDFLAGS} FLTK_LIBRARIES)
  209. endif()
  210. message(STATUS ${FLTK_LDFLAGS})
  211. set(GUI_LIBRARIES ${FLTK_LIBRARIES} ${FLTK_LIBRARIES} ${OPENGL_LIBRARIES} zynaddsubfx_gui)
  212. add_definitions(-DFLTK_GUI)
  213. message(STATUS "Will build FLTK gui")
  214. include_directories(
  215. ${FLTK_INCLUDE_DIR}
  216. "${CMAKE_CURRENT_SOURCE_DIR}/UI"
  217. "${CMAKE_CURRENT_BINARY_DIR}/UI"
  218. )
  219. add_subdirectory(UI)
  220. endif()
  221. if(NtkGui)
  222. #UGLY WORKAROUND
  223. find_program (NTK_CONFIG ntk-config)
  224. if (NTK_CONFIG)
  225. execute_process (COMMAND ${NTK_CONFIG} --use-images --ldflags OUTPUT_VARIABLE NTK_LDFLAGS)
  226. string(STRIP ${NTK_LDFLAGS} NTK_LIBRARIES)
  227. endif()
  228. message(STATUS ${NTK_LDFLAGS})
  229. set(GUI_LIBRARIES ${NTK_LIBRARIES} ${NTK_LIBRARIES} ${OPENGL_LIBRARIES} zynaddsubfx_gui)
  230. add_definitions(-DNTK_GUI)
  231. message(STATUS "Will build NTK gui")
  232. include_directories(
  233. ${NTK_INCLUDE_DIR}
  234. "${CMAKE_CURRENT_SOURCE_DIR}/UI"
  235. "${CMAKE_CURRENT_BINARY_DIR}/UI"
  236. )
  237. add_subdirectory(UI)
  238. endif()
  239. ########### General section ##############
  240. # Following this should be only general compilation code, and no mention
  241. # of module-specific variables
  242. link_directories(${AUDIO_LIBRARY_DIRS} ${ZLIB_LIBRARY_DIRS} ${FFTW_LIBRARY_DIRS} ${MXML_LIBRARY_DIRS} ${FLTK_LIBRARY_DIRS} ${NTK_LIBRARY_DIRS})
  243. include_directories(
  244. ${CMAKE_CURRENT_SOURCE_DIR}
  245. ${CMAKE_CURRENT_BINARY_DIR}
  246. )
  247. set(NONGUI_LIBRARIES
  248. zynaddsubfx_misc
  249. zynaddsubfx_synth
  250. zynaddsubfx_effect
  251. zynaddsubfx_params
  252. zynaddsubfx_dsp
  253. zynaddsubfx_nio
  254. )
  255. add_subdirectory(Misc)
  256. add_subdirectory(Synth)
  257. add_subdirectory(Effects)
  258. add_subdirectory(Params)
  259. add_subdirectory(DSP)
  260. if(CompileTests)
  261. add_subdirectory(Tests)
  262. endif(CompileTests)
  263. add_subdirectory(Nio)
  264. add_library(zynaddsubfx_core STATIC
  265. ${zynaddsubfx_dsp_SRCS}
  266. ${zynaddsubfx_effect_SRCS}
  267. ${zynaddsubfx_misc_SRCS}
  268. ${zynaddsubfx_params_SRCS}
  269. ${zynaddsubfx_synth_SRCS}
  270. )
  271. target_link_libraries(zynaddsubfx_core
  272. ${ZLIB_LIBRARIES}
  273. ${FFTW_LIBRARIES}
  274. ${MXML_LIBRARIES}
  275. ${OS_LIBRARIES}
  276. pthread)
  277. message(STATUS "using link directories: ${AUDIO_LIBRARY_DIRS} ${ZLIB_LIBRARY_DIRS} ${FFTW_LIBRARY_DIRS} ${MXML_LIBRARY_DIRS} ${FLTK_LIBRARY_DIRS}")
  278. add_executable(zynaddsubfx main.cpp)
  279. target_link_libraries(zynaddsubfx
  280. zynaddsubfx_nio
  281. zynaddsubfx_core
  282. ${GUI_LIBRARIES}
  283. ${NIO_LIBRARIES}
  284. ${AUDIO_LIBRARIES}
  285. )
  286. if (DssiEnable)
  287. add_library(zynaddsubfx_dssi SHARED
  288. Output/DSSIaudiooutput.cpp
  289. )
  290. target_link_libraries(zynaddsubfx_dssi
  291. zynaddsubfx_core
  292. ${NIO_LIBRARIES}
  293. ${AUDIO_LIBRARIES}
  294. ${OS_LIBRARIES}
  295. )
  296. if (${CMAKE_SIZEOF_VOID_P} EQUAL "8")
  297. install(TARGETS zynaddsubfx_dssi LIBRARY DESTINATION lib64/dssi/)
  298. else ()
  299. install(TARGETS zynaddsubfx_dssi LIBRARY DESTINATION lib/dssi/)
  300. endif ()
  301. endif()
  302. message(STATUS "Link libraries: ${ZLIB_LIBRARY} ${FFTW_LIBRARY} ${MXML_LIBRARIES} ${AUDIO_LIBRARIES} ${OS_LIBRARIES}")
  303. install(TARGETS zynaddsubfx
  304. RUNTIME DESTINATION bin
  305. )
  306. if(NtkGui)
  307. install(DIRECTORY ../pixmaps DESTINATION share/zynaddsubfx)
  308. add_definitions(-DPIXMAP_PATH="${CMAKE_INSTALL_PREFIX}/share/zynaddsubfx/pixmaps/")
  309. endif(NtkGui)
  310. include(CTest)