Audio plugin host https://kx.studio/carla
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.

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