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.

CMakeLists.txt 11KB

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