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

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