CMakeLists.txt 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. INCLUDE(BuildPlugin)
  2. set(CMAKE_POSITION_INDEPENDENT_CODE ON)
  3. # definitions for ZynAddSubFX
  4. IF(LMMS_BUILD_LINUX OR LMMS_BUILD_APPLE OR LMMS_BUILD_OPENBSD OR LMMS_BUILD_FREEBSD)
  5. FIND_PACKAGE(X11)
  6. INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR})
  7. ADD_DEFINITIONS(-DOS_LINUX)
  8. ELSE()
  9. ADD_DEFINITIONS(-DOS_WINDOWS)
  10. ENDIF()
  11. # do not conflict with LMMS' Controller class
  12. ADD_DEFINITIONS(-DController=ZynController)
  13. # use asm optimizations when on x86 or x86_64
  14. IF(LMMS_HOST_X86 OR LMMS_HOST_X86_64)
  15. ADD_DEFINITIONS(-DASM_F2I_YES)
  16. ENDIF(LMMS_HOST_X86 OR LMMS_HOST_X86_64)
  17. # build ZynAddSubFX with full optimizations
  18. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wno-write-strings -Wno-deprecated-declarations -fpermissive")
  19. IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "6.0.0")
  20. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-misleading-indentation")
  21. ENDIF()
  22. IF(LMMS_BUILD_WIN32)
  23. # link system-libraries
  24. ADD_DEFINITIONS(-DPTW32_STATIC_LIB)
  25. # fix X11 headers errors caused by bug with mingw + c++11 (enable -std=gnu++0x)
  26. SET(CMAKE_CXX_EXTENSIONS ON)
  27. ENDIF(LMMS_BUILD_WIN32)
  28. SET(FLTK_SKIP_OPENGL TRUE)
  29. SET(FLTK_SKIP_FORMS TRUE)
  30. SET(FLTK_SKIP_IMAGES TRUE)
  31. SET(FLTK_SKIP_MATH TRUE)
  32. IF(MINGW_PREFIX)
  33. SET(FLTK_SKIP_FLUID TRUE)
  34. ENDIF()
  35. IF(NOT FLTK_FOUND)
  36. RETURN()
  37. ENDIF()
  38. IF(MINGW_PREFIX)
  39. SET(FLTK_FLUID_EXECUTABLE "${MINGW_PREFIX}/bin/fluid")
  40. ENDIF()
  41. IF(NOT EXISTS ${FLTK_FLUID_EXECUTABLE})
  42. # Try to detect full path anyway
  43. EXECUTE_PROCESS(COMMAND which fluid OUTPUT_VARIABLE FLTK_FLUID_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE)
  44. IF(NOT EXISTS ${FLTK_FLUID_EXECUTABLE})
  45. MESSAGE(FATAL_ERROR "Please install the fluid binary which is part of FLTK.")
  46. ENDIF()
  47. ENDIF()
  48. INCLUDE_DIRECTORIES("${FLTK_INCLUDE_DIR}"
  49. "${CMAKE_CURRENT_SOURCE_DIR}"
  50. ${FFTW3F_INCLUDE_DIRS}
  51. "${CMAKE_CURRENT_BINARY_DIR}"
  52. "${CMAKE_BINARY_DIR}")
  53. include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/zynaddsubfx/src/UI)
  54. ADD_DEFINITIONS(-DPLUGINVERSION) # removes exit confirmation dialogs etc. in MasterUI.fl
  55. add_subdirectory(zynaddsubfx/src/Nio)
  56. add_subdirectory(zynaddsubfx/src/UI)
  57. SET(zynaddsubfx_core_SRCS
  58. zynaddsubfx/src/DSP/AnalogFilter.cpp
  59. zynaddsubfx/src/DSP/FFTwrapper.cpp
  60. zynaddsubfx/src/DSP/Filter.cpp
  61. zynaddsubfx/src/DSP/FormantFilter.cpp
  62. zynaddsubfx/src/DSP/SVFilter.cpp
  63. zynaddsubfx/src/DSP/Unison.cpp
  64. zynaddsubfx/src/Effects/Alienwah.cpp
  65. zynaddsubfx/src/Effects/Chorus.cpp
  66. zynaddsubfx/src/Effects/Distorsion.cpp
  67. zynaddsubfx/src/Effects/DynamicFilter.cpp
  68. zynaddsubfx/src/Effects/Echo.cpp
  69. zynaddsubfx/src/Effects/Effect.cpp
  70. zynaddsubfx/src/Effects/EffectLFO.cpp
  71. zynaddsubfx/src/Effects/EffectMgr.cpp
  72. zynaddsubfx/src/Effects/EQ.cpp
  73. zynaddsubfx/src/Effects/Phaser.cpp
  74. zynaddsubfx/src/Effects/Reverb.cpp
  75. zynaddsubfx/src/Misc/Bank.cpp
  76. zynaddsubfx/src/Misc/Config.cpp
  77. zynaddsubfx/src/Misc/Dump.cpp
  78. zynaddsubfx/src/Misc/Master.cpp
  79. zynaddsubfx/src/Misc/Microtonal.cpp
  80. zynaddsubfx/src/Misc/Part.cpp
  81. zynaddsubfx/src/Misc/Util.cpp
  82. zynaddsubfx/src/Misc/QtXmlWrapper.cpp
  83. zynaddsubfx/src/Misc/Recorder.cpp
  84. zynaddsubfx/src/Misc/WavFile.cpp
  85. zynaddsubfx/src/Misc/WaveShapeSmps.cpp
  86. zynaddsubfx/src/Params/ADnoteParameters.cpp
  87. zynaddsubfx/src/Params/Controller.cpp
  88. zynaddsubfx/src/Params/EnvelopeParams.cpp
  89. zynaddsubfx/src/Params/FilterParams.cpp
  90. zynaddsubfx/src/Params/LFOParams.cpp
  91. zynaddsubfx/src/Params/PADnoteParameters.cpp
  92. zynaddsubfx/src/Params/Presets.cpp
  93. zynaddsubfx/src/Params/PresetsArray.cpp
  94. zynaddsubfx/src/Params/PresetsStore.cpp
  95. zynaddsubfx/src/Params/SUBnoteParameters.cpp
  96. zynaddsubfx/src/Synth/SynthNote.cpp
  97. zynaddsubfx/src/Synth/ADnote.cpp
  98. zynaddsubfx/src/Synth/Envelope.cpp
  99. zynaddsubfx/src/Synth/LFO.cpp
  100. zynaddsubfx/src/Synth/OscilGen.cpp
  101. zynaddsubfx/src/Synth/PADnote.cpp
  102. zynaddsubfx/src/Synth/Resonance.cpp
  103. zynaddsubfx/src/Synth/SUBnote.cpp
  104. )
  105. IF(LMMS_BUILD_LINUX)
  106. ADD_LIBRARY(ZynAddSubFxCore MODULE LocalZynAddSubFx.cpp ${zynaddsubfx_core_SRCS})
  107. ELSE()
  108. ADD_LIBRARY(ZynAddSubFxCore SHARED LocalZynAddSubFx.cpp ${zynaddsubfx_core_SRCS})
  109. ENDIF()
  110. TARGET_LINK_LIBRARIES(ZynAddSubFxCore zynaddsubfx_nio ${FFTW3F_LIBRARIES} ${QT_LIBRARIES} -lz -lpthread)
  111. TARGET_LINK_LIBRARIES(ZynAddSubFxCore Qt5::Widgets Qt5::Xml)
  112. IF(LMMS_BUILD_WIN32)
  113. TARGET_LINK_LIBRARIES(ZynAddSubFxCore -lws2_32)
  114. INSTALL(TARGETS ZynAddSubFxCore RUNTIME DESTINATION "${PLUGIN_DIR}")
  115. ELSE(LMMS_BUILD_WIN32)
  116. INSTALL(TARGETS ZynAddSubFxCore LIBRARY DESTINATION "${PLUGIN_DIR}")
  117. ENDIF(LMMS_BUILD_WIN32)
  118. LINK_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/..")
  119. IF(LMMS_BUILD_LINUX)
  120. LINK_LIBRARIES(-Wl,--enable-new-dtags)
  121. SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
  122. SET(CMAKE_INSTALL_RPATH "$ORIGIN")
  123. ELSE()
  124. SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${PLUGIN_DIR}")
  125. ENDIF()
  126. BUILD_PLUGIN(zynaddsubfx ZynAddSubFx.cpp ZynAddSubFx.h MOCFILES ZynAddSubFx.h EMBEDDED_RESOURCES artwork.png logo.png)
  127. TARGET_LINK_LIBRARIES(zynaddsubfx -lZynAddSubFxCore)
  128. ADD_DEPENDENCIES(zynaddsubfx ZynAddSubFxCore)
  129. IF(WIN32)
  130. SET(WINRC "${CMAKE_CURRENT_BINARY_DIR}/zynaddsubfxrc.obj")
  131. ADD_CUSTOM_COMMAND(OUTPUT "${WINRC}"
  132. COMMAND "${CMAKE_RC_COMPILER}"
  133. "-I\"${CMAKE_CURRENT_SOURCE_DIR}\""
  134. "-o\"${CMAKE_CURRENT_BINARY_DIR}/zynaddsubfxrc.obj\""
  135. "-i\"${CMAKE_CURRENT_BINARY_DIR}/zynaddsubfx.rc\""
  136. DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/zynaddsubfx.rc")
  137. ENDIF(WIN32)
  138. # Use libraries in non-standard directories (e.g., another version of Qt)
  139. SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  140. ADD_EXECUTABLE(RemoteZynAddSubFx RemoteZynAddSubFx.cpp "${WINRC}")
  141. INSTALL(TARGETS RemoteZynAddSubFx RUNTIME DESTINATION "${PLUGIN_DIR}")
  142. # Needed to deploy dependencies of RemoteZynAddSubFx
  143. SET_PROPERTY(GLOBAL APPEND PROPERTY PLUGINS_BUILT "RemoteZynAddSubFx")
  144. IF(LMMS_BUILD_WIN32)
  145. SET_TARGET_PROPERTIES(RemoteZynAddSubFx PROPERTIES LINK_FLAGS "${LINK_FLAGS} -mwindows")
  146. ENDIF(LMMS_BUILD_WIN32)
  147. # Remove useless dependencies from FLTK. Use fltk-config to avoid static library
  148. # in older environments
  149. SET(FLTK_FILTERED_LDFLAGS ${FLTK_LIBRARIES})
  150. FIND_PROGRAM(FLTK_CONFIG fltk-config)
  151. IF(FLTK_CONFIG AND NOT (LMMS_BUILD_APPLE OR LMMS_BUILD_WIN32))
  152. EXECUTE_PROCESS(COMMAND ${FLTK_CONFIG} --ldflags OUTPUT_VARIABLE FLTK_FILTERED_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
  153. STRING(REPLACE " " ";" FLTK_FILTERED_LDFLAGS ${FLTK_FILTERED_LDFLAGS})
  154. LIST(REMOVE_ITEM FLTK_FILTERED_LDFLAGS -lX11)
  155. ENDIF()
  156. TARGET_LINK_LIBRARIES(RemoteZynAddSubFx zynaddsubfx_gui -lZynAddSubFxCore ${FLTK_FILTERED_LDFLAGS} -lpthread )
  157. ADD_DEPENDENCIES(RemoteZynAddSubFx ZynAddSubFxCore)
  158. # Support qt_version_tag in Qt 5.6
  159. TARGET_LINK_LIBRARIES(RemoteZynAddSubFx Qt5::Core)
  160. # link Qt libraries when on win32
  161. IF(LMMS_BUILD_WIN32)
  162. TARGET_LINK_LIBRARIES(RemoteZynAddSubFx ${QT_LIBRARIES})
  163. ENDIF(LMMS_BUILD_WIN32)
  164. IF(LMMS_BUILD_WIN32)
  165. ADD_CUSTOM_COMMAND(TARGET ZynAddSubFxCore POST_BUILD COMMAND "${STRIP}" \"$<TARGET_FILE:ZynAddSubFxCore>\")
  166. ADD_CUSTOM_COMMAND(TARGET RemoteZynAddSubFx POST_BUILD COMMAND "${STRIP}" \"$<TARGET_FILE:RemoteZynAddSubFx>\")
  167. ENDIF(LMMS_BUILD_WIN32)