CMakeLists.txt 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. CMAKE_MINIMUM_REQUIRED(VERSION 3.8)
  2. PROJECT(lmms)
  3. SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH})
  4. SET(LMMS_BINARY_DIR ${CMAKE_BINARY_DIR})
  5. SET(LMMS_SOURCE_DIR ${CMAKE_SOURCE_DIR})
  6. IF(COMMAND CMAKE_POLICY)
  7. CMAKE_POLICY(SET CMP0005 NEW)
  8. CMAKE_POLICY(SET CMP0003 NEW)
  9. IF (CMAKE_MAJOR_VERSION GREATER 2)
  10. CMAKE_POLICY(SET CMP0026 NEW)
  11. CMAKE_POLICY(SET CMP0045 NEW)
  12. CMAKE_POLICY(SET CMP0050 OLD)
  13. ENDIF()
  14. CMAKE_POLICY(SET CMP0020 NEW)
  15. CMAKE_POLICY(SET CMP0057 NEW)
  16. ENDIF(COMMAND CMAKE_POLICY)
  17. # Import of windows.h breaks min()/max()
  18. ADD_DEFINITIONS(-DNOMINMAX)
  19. INCLUDE(PluginList)
  20. INCLUDE(CheckSubmodules)
  21. INCLUDE(AddFileDependencies)
  22. INCLUDE(CheckIncludeFiles)
  23. INCLUDE(FindPkgConfig)
  24. INCLUDE(GenerateExportHeader)
  25. STRING(TOUPPER "${CMAKE_PROJECT_NAME}" PROJECT_NAME_UCASE)
  26. SET(PROJECT_YEAR 2020)
  27. SET(PROJECT_AUTHOR "LMMS Developers")
  28. SET(PROJECT_URL "https://lmms.io")
  29. SET(PROJECT_EMAIL "lmms-devel@lists.sourceforge.net")
  30. SET(PROJECT_DESCRIPTION "${PROJECT_NAME_UCASE} - Free music production software")
  31. SET(PROJECT_COPYRIGHT "2008-${PROJECT_YEAR} ${PROJECT_AUTHOR}")
  32. SET(VERSION_MAJOR "1")
  33. SET(VERSION_MINOR "3")
  34. SET(VERSION_RELEASE "0")
  35. SET(VERSION_STAGE "alpha")
  36. SET(VERSION_BUILD "")
  37. SET(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_RELEASE}")
  38. IF(VERSION_STAGE)
  39. SET(VERSION "${VERSION}-${VERSION_STAGE}")
  40. ENDIF()
  41. IF(VERSION_BUILD)
  42. SET(VERSION "${VERSION}-${VERSION_BUILD}")
  43. ENDIF()
  44. # Override version information for non-base builds
  45. INCLUDE(VersionInfo)
  46. INCLUDE(DetectMachine)
  47. OPTION(WANT_ALSA "Include ALSA (Advanced Linux Sound Architecture) support" ON)
  48. OPTION(WANT_CALF "Include CALF LADSPA plugins" ON)
  49. OPTION(WANT_CAPS "Include C* Audio Plugin Suite (LADSPA plugins)" ON)
  50. OPTION(WANT_CARLA "Include Carla plugin" ON)
  51. OPTION(WANT_CMT "Include Computer Music Toolkit LADSPA plugins" ON)
  52. OPTION(WANT_JACK "Include JACK (Jack Audio Connection Kit) support" ON)
  53. OPTION(WANT_WEAKJACK "Loosely link JACK libraries" ON)
  54. OPTION(WANT_LV2 "Include Lv2 plugins" ON)
  55. OPTION(WANT_SUIL "Include SUIL for LV2 plugin UIs" ON)
  56. OPTION(WANT_MP3LAME "Include MP3/Lame support" ON)
  57. OPTION(WANT_OGGVORBIS "Include OGG/Vorbis support" ON)
  58. OPTION(WANT_PULSEAUDIO "Include PulseAudio support" ON)
  59. OPTION(WANT_PORTAUDIO "Include PortAudio support" ON)
  60. OPTION(WANT_SNDIO "Include sndio support" ON)
  61. OPTION(WANT_SOUNDIO "Include libsoundio support" ON)
  62. OPTION(WANT_SDL "Include SDL (Simple DirectMedia Layer) support" ON)
  63. OPTION(WANT_SF2 "Include SoundFont2 player plugin" ON)
  64. OPTION(WANT_GIG "Include GIG player plugin" ON)
  65. OPTION(WANT_STK "Include Stk (Synthesis Toolkit) support" ON)
  66. OPTION(WANT_SWH "Include Steve Harris's LADSPA plugins" ON)
  67. OPTION(WANT_TAP "Include Tom's Audio Processing LADSPA plugins" ON)
  68. OPTION(WANT_VST "Include VST support" ON)
  69. OPTION(WANT_VST_32 "Include 32-bit VST support" ON)
  70. OPTION(WANT_VST_64 "Include 64-bit VST support" ON)
  71. OPTION(WANT_WINMM "Include WinMM MIDI support" OFF)
  72. OPTION(WANT_DEBUG_FPE "Debug floating point exceptions" OFF)
  73. OPTION(BUNDLE_QT_TRANSLATIONS "Install Qt translation files for LMMS" OFF)
  74. IF(LMMS_BUILD_APPLE)
  75. # Fix linking on 10.14+. See issue #4762 on github
  76. LINK_DIRECTORIES("${APPLE_PREFIX}/lib")
  77. SET(WANT_SOUNDIO OFF)
  78. SET(WANT_ALSA OFF)
  79. SET(WANT_PULSEAUDIO OFF)
  80. SET(WANT_VST OFF)
  81. SET(STATUS_ALSA "<not supported on this platform>")
  82. SET(STATUS_PULSEAUDIO "<not supported on this platform>")
  83. SET(STATUS_APPLEMIDI "OK")
  84. ELSE(LMMS_BUILD_APPLE)
  85. SET(STATUS_APPLEMIDI "<not supported on this platform>")
  86. ENDIF(LMMS_BUILD_APPLE)
  87. IF(LMMS_BUILD_WIN32)
  88. SET(WANT_ALSA OFF)
  89. SET(WANT_PULSEAUDIO OFF)
  90. SET(WANT_SNDIO OFF)
  91. SET(WANT_SOUNDIO OFF)
  92. SET(WANT_WINMM ON)
  93. SET(BUNDLE_QT_TRANSLATIONS ON)
  94. SET(LMMS_HAVE_WINMM TRUE)
  95. SET(STATUS_ALSA "<not supported on this platform>")
  96. SET(STATUS_PULSEAUDIO "<not supported on this platform>")
  97. SET(STATUS_SOUNDIO "<disabled in this release>")
  98. SET(STATUS_WINMM "OK")
  99. SET(STATUS_APPLEMIDI "<not supported on this platform>")
  100. ELSE(LMMS_BUILD_WIN32)
  101. SET(STATUS_WINMM "<not supported on this platform>")
  102. ENDIF(LMMS_BUILD_WIN32)
  103. # TODO: Fix linking issues with msys debug builds
  104. IF(LMMS_BUILD_MSYS AND CMAKE_BUILD_TYPE STREQUAL "Debug")
  105. SET(WANT_GIG OFF)
  106. SET(WANT_STK OFF)
  107. SET(WANT_SWH OFF)
  108. SET(STATUS_GIG "not built as requested")
  109. SET(STATUS_STK "not built as requested")
  110. ENDIF()
  111. SET(CMAKE_CXX_STANDARD_REQUIRED ON)
  112. CHECK_INCLUDE_FILES(stdint.h LMMS_HAVE_STDINT_H)
  113. CHECK_INCLUDE_FILES(stdlib.h LMMS_HAVE_STDLIB_H)
  114. CHECK_INCLUDE_FILES(pthread.h LMMS_HAVE_PTHREAD_H)
  115. CHECK_INCLUDE_FILES(semaphore.h LMMS_HAVE_SEMAPHORE_H)
  116. CHECK_INCLUDE_FILES(unistd.h LMMS_HAVE_UNISTD_H)
  117. CHECK_INCLUDE_FILES(sys/types.h LMMS_HAVE_SYS_TYPES_H)
  118. CHECK_INCLUDE_FILES(sys/ipc.h LMMS_HAVE_SYS_IPC_H)
  119. CHECK_INCLUDE_FILES(sys/shm.h LMMS_HAVE_SYS_SHM_H)
  120. CHECK_INCLUDE_FILES(sys/time.h LMMS_HAVE_SYS_TIME_H)
  121. CHECK_INCLUDE_FILES(sys/times.h LMMS_HAVE_SYS_TIMES_H)
  122. CHECK_INCLUDE_FILES(sched.h LMMS_HAVE_SCHED_H)
  123. CHECK_INCLUDE_FILES(sys/soundcard.h LMMS_HAVE_SYS_SOUNDCARD_H)
  124. CHECK_INCLUDE_FILES(soundcard.h LMMS_HAVE_SOUNDCARD_H)
  125. CHECK_INCLUDE_FILES(fcntl.h LMMS_HAVE_FCNTL_H)
  126. CHECK_INCLUDE_FILES(sys/ioctl.h LMMS_HAVE_SYS_IOCTL_H)
  127. CHECK_INCLUDE_FILES(ctype.h LMMS_HAVE_CTYPE_H)
  128. CHECK_INCLUDE_FILES(string.h LMMS_HAVE_STRING_H)
  129. CHECK_INCLUDE_FILES(process.h LMMS_HAVE_PROCESS_H)
  130. CHECK_INCLUDE_FILES(locale.h LMMS_HAVE_LOCALE_H)
  131. LIST(APPEND CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}")
  132. FIND_PACKAGE(Qt5 5.6.0 COMPONENTS Core Gui Widgets Xml REQUIRED)
  133. FIND_PACKAGE(Qt5 COMPONENTS LinguistTools QUIET)
  134. INCLUDE_DIRECTORIES(
  135. ${Qt5Core_INCLUDE_DIRS}
  136. ${Qt5Gui_INCLUDE_DIRS}
  137. ${Qt5Widgets_INCLUDE_DIRS}
  138. ${Qt5Xml_INCLUDE_DIRS}
  139. )
  140. SET(QT_LIBRARIES
  141. Qt5::Core
  142. Qt5::Gui
  143. Qt5::Widgets
  144. Qt5::Xml
  145. )
  146. IF(LMMS_BUILD_LINUX AND WANT_VST)
  147. FIND_PACKAGE(Qt5 COMPONENTS X11Extras REQUIRED)
  148. LIST(APPEND QT_LIBRARIES Qt5::X11Extras)
  149. ENDIF()
  150. # Resolve Qt5::qmake to full path for use in packaging scripts
  151. GET_TARGET_PROPERTY(QT_QMAKE_EXECUTABLE "${Qt5Core_QMAKE_EXECUTABLE}" IMPORTED_LOCATION)
  152. # Find the location of Qt translation files
  153. execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_TRANSLATIONS
  154. OUTPUT_VARIABLE QT_TRANSLATIONS_DIR
  155. OUTPUT_STRIP_TRAILING_WHITESPACE
  156. ERROR_QUIET
  157. )
  158. IF(EXISTS "${QT_TRANSLATIONS_DIR}")
  159. MESSAGE("-- Found Qt translations in ${QT_TRANSLATIONS_DIR}")
  160. ADD_DEFINITIONS("-DQT_TRANSLATIONS_DIR=\"${QT_TRANSLATIONS_DIR}\"")
  161. ENDIF()
  162. FIND_PACKAGE(Qt5Test)
  163. SET(QT_QTTEST_LIBRARY Qt5::Test)
  164. # check for libsndfile
  165. FIND_PACKAGE(SndFile REQUIRED)
  166. IF(NOT SNDFILE_FOUND)
  167. MESSAGE(FATAL_ERROR "LMMS requires libsndfile1 and libsndfile1-dev >= 1.0.18 - please install, remove CMakeCache.txt and try again!")
  168. ENDIF()
  169. # check if we can use SFC_SET_COMPRESSION_LEVEL
  170. INCLUDE(CheckCXXSourceCompiles)
  171. CHECK_CXX_SOURCE_COMPILES(
  172. "#include <sndfile.h>
  173. int main() {SFC_SET_COMPRESSION_LEVEL;}"
  174. LMMS_HAVE_SF_COMPLEVEL
  175. )
  176. IF(WANT_LV2)
  177. IF(PKG_CONFIG_FOUND)
  178. PKG_CHECK_MODULES(LV2 lv2)
  179. PKG_CHECK_MODULES(LILV lilv-0)
  180. ENDIF()
  181. IF(NOT LV2_FOUND AND NOT LILV_FOUND)
  182. FIND_PACKAGE(LV2 CONFIG)
  183. FIND_PACKAGE(LILV CONFIG)
  184. IF(LILV_FOUND)
  185. SET(LILV_LIBRARIES "lilv::lilv")
  186. ENDIF()
  187. ENDIF()
  188. IF(LV2_FOUND AND LILV_FOUND)
  189. SET(LMMS_HAVE_LV2 TRUE)
  190. SET(STATUS_LV2 "OK")
  191. ELSE()
  192. SET(STATUS_LV2 "not found, install it or set PKG_CONFIG_PATH appropriately")
  193. ENDIF()
  194. ELSE(WANT_LV2)
  195. SET(STATUS_LV2 "not built as requested")
  196. ENDIF(WANT_LV2)
  197. IF(WANT_SUIL)
  198. IF(PKG_CONFIG_FOUND)
  199. PKG_CHECK_MODULES(SUIL suil-0)
  200. IF(SUIL_FOUND)
  201. SET(LMMS_HAVE_SUIL TRUE)
  202. SET(STATUS_SUIL "OK")
  203. ELSE()
  204. SET(STATUS_SUIL "not found, install it or set PKG_CONFIG_PATH appropriately")
  205. ENDIF()
  206. ELSE()
  207. SET(STATUS_SUIL "not found, requires pkg-config")
  208. ENDIF()
  209. ELSE(WANT_SUIL)
  210. SET(STATUS_SUIL "not built as requested")
  211. ENDIF(WANT_SUIL)
  212. IF(WANT_CALF)
  213. SET(LMMS_HAVE_CALF TRUE)
  214. SET(STATUS_CALF "OK")
  215. ELSE(WANT_CALF)
  216. SET(STATUS_CALF "not built as requested")
  217. ENDIF(WANT_CALF)
  218. IF(WANT_CAPS)
  219. SET(LMMS_HAVE_CAPS TRUE)
  220. SET(STATUS_CAPS "OK")
  221. ELSE(WANT_CAPS)
  222. SET(STATUS_CAPS "not built as requested")
  223. ENDIF(WANT_CAPS)
  224. IF(WANT_CMT)
  225. SET(LMMS_HAVE_CMT TRUE)
  226. SET(STATUS_CMT "OK")
  227. ELSE(WANT_CMT)
  228. SET(STATUS_CMT "not built as requested")
  229. ENDIF(WANT_CMT)
  230. IF(WANT_SWH)
  231. SET(LMMS_HAVE_SWH TRUE)
  232. SET(STATUS_SWH "OK")
  233. ELSE(WANT_SWH)
  234. SET(STATUS_SWH "not built as requested")
  235. ENDIF(WANT_SWH)
  236. IF(WANT_TAP)
  237. SET(LMMS_HAVE_TAP TRUE)
  238. SET(STATUS_TAP "OK")
  239. ELSE(WANT_TAP)
  240. SET(STATUS_TAP "not built as requested")
  241. ENDIF(WANT_TAP)
  242. # check for CARLA
  243. IF(WANT_CARLA)
  244. PKG_CHECK_MODULES(CARLA carla-native-plugin)
  245. # look for carla under old name
  246. IF(NOT CARLA_FOUND)
  247. PKG_CHECK_MODULES(CARLA carla-standalone>=1.9.5)
  248. ENDIF()
  249. IF(CARLA_FOUND)
  250. SET(LMMS_HAVE_CARLA TRUE)
  251. SET(STATUS_CARLA "OK")
  252. ELSE(CARLA_FOUND)
  253. SET(LMMS_HAVE_WEAKCARLA TRUE)
  254. SET(STATUS_CARLA "OK (weak linking enabled)")
  255. ENDIF(CARLA_FOUND)
  256. ENDIF(WANT_CARLA)
  257. # check for SDL2
  258. IF(WANT_SDL)
  259. # Don't look for SDL2main
  260. SET(SDL2_BUILDING_LIBRARY TRUE)
  261. # Search for SDL2 using config mode first, then fall back to module mode.
  262. # This allows us to use SDL2's own CMake configuration files if available.
  263. FIND_PACKAGE(SDL2 CONFIG QUIET)
  264. IF(NOT TARGET SDL2::SDL2)
  265. UNSET(SDL2_FOUND)
  266. FIND_PACKAGE(SDL2 MODULE)
  267. ENDIF()
  268. IF(SDL2_FOUND)
  269. SET(LMMS_HAVE_SDL TRUE)
  270. SET(LMMS_HAVE_SDL2 TRUE)
  271. SET(STATUS_SDL "OK, using SDL2")
  272. SET(SDL2_LIBRARY "SDL2::SDL2")
  273. SET(SDL_INCLUDE_DIR "")
  274. SET(SDL_LIBRARY "")
  275. ELSE()
  276. SET(SDL2_LIBRARY "")
  277. ENDIF()
  278. ENDIF()
  279. # fallback to SDL1
  280. IF(WANT_SDL AND NOT LMMS_HAVE_SDL2)
  281. # Fallback to SDL1.2
  282. SET(SDL_BUILDING_LIBRARY TRUE)
  283. FIND_PACKAGE(SDL)
  284. IF(SDL_FOUND)
  285. SET(LMMS_HAVE_SDL TRUE)
  286. SET(STATUS_SDL "OK, using SDL1.2")
  287. # fix mingw since 53abd65
  288. IF(NOT SDL_INCLUDE_DIR)
  289. SET(SDL_INCLUDE_DIR "${CMAKE_FIND_ROOT_PATH}/include")
  290. ENDIF()
  291. ELSE()
  292. SET(STATUS_SDL "not found, please install libsdl2-dev (or similar) "
  293. "if you require SDL support")
  294. SET(SDL_INCLUDE_DIR "")
  295. SET(SDL_LIBRARY "")
  296. ENDIF()
  297. ENDIF()
  298. # check for Stk
  299. IF(WANT_STK)
  300. FIND_PACKAGE(STK)
  301. IF(STK_FOUND)
  302. SET(LMMS_HAVE_STK TRUE)
  303. SET(STATUS_STK "OK")
  304. ELSE(STK_FOUND)
  305. SET(STK_INCLUDE_DIR "")
  306. SET(STATUS_STK "not found, please install libstk0-dev (or similar) "
  307. "if you require the Mallets instrument")
  308. ENDIF(STK_FOUND)
  309. ENDIF(WANT_STK)
  310. # check for PortAudio
  311. IF(WANT_PORTAUDIO)
  312. FIND_PACKAGE(Portaudio)
  313. IF(PORTAUDIO_FOUND)
  314. SET(LMMS_HAVE_PORTAUDIO TRUE)
  315. SET(STATUS_PORTAUDIO "OK")
  316. ELSE(PORTAUDIO_FOUND)
  317. SET(STATUS_PORTAUDIO "not found, please install portaudio19-dev (or similar, version >= 1.9) "
  318. "if you require PortAudio support")
  319. ENDIF(PORTAUDIO_FOUND)
  320. ENDIF(WANT_PORTAUDIO)
  321. # check for libsoundio
  322. IF(WANT_SOUNDIO)
  323. FIND_PACKAGE(SoundIo)
  324. IF(SOUNDIO_FOUND)
  325. SET(LMMS_HAVE_SOUNDIO TRUE)
  326. SET(STATUS_SOUNDIO "OK")
  327. INCLUDE_DIRECTORIES("${SOUNDIO_INCLUDE_DIR}")
  328. ELSE(SOUNDIO_FOUND)
  329. SET(SOUNDIO_INCLUDE_DIR "")
  330. SET(STATUS_SOUNDIO "not found, please install libsoundio if you require libsoundio support")
  331. SET(SOUNDIO_LIBRARY "")
  332. ENDIF(SOUNDIO_FOUND)
  333. ENDIF(WANT_SOUNDIO)
  334. # check for PulseAudio
  335. IF(WANT_PULSEAUDIO)
  336. FIND_PACKAGE(PulseAudio)
  337. IF(PULSEAUDIO_FOUND)
  338. SET(LMMS_HAVE_PULSEAUDIO TRUE)
  339. SET(STATUS_PULSEAUDIO "OK")
  340. ELSE(PULSEAUDIO_FOUND)
  341. SET(STATUS_PULSEAUDIO "not found, please install libpulse-dev (or similar) "
  342. "if you require PulseAudio support")
  343. ENDIF(PULSEAUDIO_FOUND)
  344. ENDIF(WANT_PULSEAUDIO)
  345. IF(NOT LMMS_HAVE_PULSEAUDIO)
  346. SET(PULSEAUDIO_INCLUDE_DIR "")
  347. SET(PULSEAUDIO_LIBRARIES "")
  348. ENDIF(NOT LMMS_HAVE_PULSEAUDIO)
  349. # check for MP3/Lame-libraries
  350. IF(WANT_MP3LAME)
  351. FIND_PACKAGE(Lame)
  352. IF(LAME_FOUND)
  353. SET(LMMS_HAVE_MP3LAME TRUE)
  354. SET(STATUS_MP3LAME "OK")
  355. ELSE(LAME_FOUND)
  356. SET(STATUS_MP3LAME "not found, please install libmp3lame-dev (or similar)")
  357. SET(LAME_LIBRARIES "")
  358. SET(LAME_INCLUDE_DIRS "")
  359. ENDIF(LAME_FOUND)
  360. ELSE(WANT_MP3LAME)
  361. SET(STATUS_MP3LAME "Disabled for build")
  362. ENDIF(WANT_MP3LAME)
  363. # check for OGG/Vorbis-libraries
  364. IF(WANT_OGGVORBIS)
  365. FIND_PACKAGE(OggVorbis)
  366. IF(OGGVORBIS_FOUND)
  367. SET(LMMS_HAVE_OGGVORBIS TRUE)
  368. SET(STATUS_OGGVORBIS "OK")
  369. ELSE(OGGVORBIS_FOUND)
  370. SET(STATUS_OGGVORBIS "not found, libogg-dev and libvorbis-dev (or similar) "
  371. "is highly recommended")
  372. ENDIF(OGGVORBIS_FOUND)
  373. ENDIF(WANT_OGGVORBIS)
  374. # check whether to enable OSS-support
  375. IF(LMMS_HAVE_SOUNDCARD_H OR LMMS_HAVE_SYS_SOUNDCARD_H)
  376. SET(LMMS_HAVE_OSS TRUE)
  377. SET(STATUS_OSS "OK")
  378. ELSE(LMMS_HAVE_SOUNDCARD_H OR LMMS_HAVE_SYS_SOUNDCARD_H)
  379. SET(STATUS_OSS "<not found or not supported on this platform>")
  380. ENDIF(LMMS_HAVE_SOUNDCARD_H OR LMMS_HAVE_SYS_SOUNDCARD_H)
  381. # check for ALSA
  382. IF(WANT_ALSA)
  383. FIND_PACKAGE(Alsa)
  384. IF(ALSA_FOUND)
  385. SET(LMMS_HAVE_ALSA TRUE)
  386. SET(STATUS_ALSA "OK")
  387. ELSE(ALSA_FOUND)
  388. SET(STATUS_ALSA "not found, please install libasound2-dev (or similar) "
  389. "if you require ALSA support")
  390. ENDIF(ALSA_FOUND)
  391. ENDIF(WANT_ALSA)
  392. IF(NOT LMMS_HAVE_ALSA)
  393. SET(ASOUND_LIBRARY "")
  394. ENDIF(NOT LMMS_HAVE_ALSA)
  395. # check for JACK
  396. IF(WANT_JACK)
  397. IF(WANT_WEAKJACK)
  398. SET(LMMS_HAVE_WEAKJACK TRUE)
  399. SET(WEAKJACK_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/3rdparty/weakjack/weakjack)
  400. SET(JACK_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/3rdparty/jack2/common)
  401. SET(STATUS_JACK "OK (weak linking enabled)")
  402. # use dlsym instead
  403. SET(JACK_LIBRARIES ${CMAKE_DL_LIBS})
  404. SET(LMMS_HAVE_JACK TRUE)
  405. SET(LMMS_HAVE_JACK_PRENAME TRUE)
  406. SET(JACK_FOUND TRUE)
  407. ELSE()
  408. PKG_CHECK_MODULES(JACK jack>=0.77)
  409. IF(JACK_FOUND)
  410. SET(LMMS_HAVE_JACK TRUE)
  411. SET(STATUS_JACK "OK")
  412. SET(CMAKE_REQUIRED_LIBRARIES_BACKUP "${CMAKE_REQUIRED_LIBRARIES}")
  413. SET(CMAKE_REQUIRED_LIBRARIES "${JACK_LIBRARIES}")
  414. CHECK_LIBRARY_EXISTS(jack jack_port_rename "" LMMS_HAVE_JACK_PRENAME)
  415. SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_BACKUP}")
  416. UNSET(CMAKE_REQUIRED_LIBRARIES_BACKUP)
  417. ENDIF()
  418. ENDIF()
  419. IF(NOT JACK_FOUND)
  420. SET(JACK_INCLUDE_DIRS "")
  421. SET(STATUS_JACK "not found")
  422. ENDIF()
  423. ENDIF(WANT_JACK)
  424. # check for FFTW3F-library
  425. FIND_PACKAGE(FFTW COMPONENTS fftw3f REQUIRED)
  426. # check for FLTK
  427. FIND_PACKAGE(FLTK)
  428. IF(FLTK_FOUND)
  429. SET(STATUS_ZYN "OK")
  430. ELSE()
  431. SET(STATUS_ZYN "not found, please install fltk")
  432. ENDIF()
  433. # check for Fluidsynth
  434. IF(WANT_SF2)
  435. PKG_CHECK_MODULES(FLUIDSYNTH fluidsynth>=1.0.7)
  436. IF(FLUIDSYNTH_FOUND)
  437. SET(LMMS_HAVE_FLUIDSYNTH TRUE)
  438. SET(STATUS_FLUIDSYNTH "OK")
  439. ELSE(FLUIDSYNTH_FOUND)
  440. SET(STATUS_FLUIDSYNTH "not found, libfluidsynth-dev (or similar)"
  441. "is highly recommended")
  442. ENDIF(FLUIDSYNTH_FOUND)
  443. ENDIF(WANT_SF2)
  444. # check for libgig
  445. If(WANT_GIG)
  446. PKG_CHECK_MODULES(GIG gig)
  447. IF(GIG_FOUND)
  448. SET(LMMS_HAVE_GIG TRUE)
  449. SET(STATUS_GIG "OK")
  450. ELSE(GIG_FOUND)
  451. SET(STATUS_GIG "not found, libgig needed for decoding .gig files")
  452. ENDIF(GIG_FOUND)
  453. ENDIF(WANT_GIG)
  454. # check for pthreads
  455. IF(LMMS_BUILD_LINUX OR LMMS_BUILD_APPLE OR LMMS_BUILD_OPENBSD OR LMMS_BUILD_FREEBSD OR LMMS_BUILD_HAIKU)
  456. FIND_PACKAGE(Threads)
  457. ENDIF(LMMS_BUILD_LINUX OR LMMS_BUILD_APPLE OR LMMS_BUILD_OPENBSD OR LMMS_BUILD_FREEBSD OR LMMS_BUILD_HAIKU)
  458. # check for sndio (roaraudio won't work yet)
  459. IF(WANT_SNDIO)
  460. FIND_PACKAGE(Sndio)
  461. IF(SNDIO_FOUND)
  462. SET(LMMS_HAVE_SNDIO TRUE)
  463. SET(STATUS_SNDIO "OK")
  464. ELSE()
  465. SET(STATUS_SNDIO "<not found or not supported on this platform>")
  466. ENDIF(SNDIO_FOUND)
  467. ENDIF(WANT_SNDIO)
  468. # check for WINE
  469. IF(WANT_VST)
  470. FIND_PACKAGE(Wine)
  471. IF(WINE_FOUND)
  472. SET(LMMS_SUPPORT_VST TRUE)
  473. IF(WINE_LIBRARY_FIX)
  474. SET(STATUS_VST "OK, with workaround linking ${WINE_LIBRARY_FIX}")
  475. ELSE()
  476. SET(STATUS_VST "OK")
  477. ENDIF()
  478. ELSEIF(WANT_VST_NOWINE)
  479. SET(LMMS_SUPPORT_VST TRUE)
  480. SET(STATUS_VST "OK")
  481. ELSE(WINE_FOUND)
  482. SET(STATUS_VST "not found, please install (lib)wine-dev (or similar) - 64 bit systems additionally need gcc-multilib and g++-multilib")
  483. ENDIF(WINE_FOUND)
  484. ENDIF(WANT_VST)
  485. IF(LMMS_BUILD_WIN32)
  486. SET(LMMS_SUPPORT_VST TRUE)
  487. SET(STATUS_VST "OK")
  488. ENDIF(LMMS_BUILD_WIN32)
  489. IF(WANT_DEBUG_FPE)
  490. IF(LMMS_BUILD_LINUX OR LMMS_BUILD_APPLE)
  491. SET(LMMS_DEBUG_FPE TRUE)
  492. SET (STATUS_DEBUG_FPE "Enabled")
  493. ELSE()
  494. SET (STATUS_DEBUG_FPE "Wanted but disabled due to unsupported platform")
  495. ENDIF()
  496. ELSE()
  497. SET (STATUS_DEBUG_FPE "Disabled")
  498. ENDIF(WANT_DEBUG_FPE)
  499. # check for libsamplerate
  500. FIND_PACKAGE(Samplerate 0.1.8 MODULE REQUIRED)
  501. # set compiler flags
  502. IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
  503. SET(WERROR_FLAGS "-Wall -Werror=unused-function -Wno-sign-compare -Wno-strict-overflow")
  504. OPTION(USE_WERROR "Add -werror to the build flags. Stops the build on warnings" OFF)
  505. IF(${USE_WERROR})
  506. SET(WERROR_FLAGS "${WERROR_FLAGS} -Werror")
  507. ENDIF()
  508. # Due to a regression in gcc-4.8.X, we need to disable array-bounds check
  509. IF (CMAKE_COMPILER_IS_GNUCXX AND ((CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "4.8.0") OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.8.0") OR LMMS_BUILD_WIN32))
  510. SET(WERROR_FLAGS "${WERROR_FLAGS} -Wno-array-bounds -Wno-attributes")
  511. ENDIF()
  512. ELSEIF(MSVC)
  513. # Remove any existing /W flags
  514. STRING(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
  515. SET(WERROR_FLAGS "/W2")
  516. IF(${USE_WERROR})
  517. SET(WERROR_FLAGS "${WERROR_FLAGS} /WX")
  518. ENDIF()
  519. ENDIF()
  520. IF(NOT CMAKE_BUILD_TYPE)
  521. message(STATUS "Setting build type to 'Release' as none was specified.")
  522. set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
  523. # Set the possible values of build type for cmake-gui
  524. SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
  525. "MinSizeRel" "RelWithDebInfo")
  526. ENDIF()
  527. SET(CMAKE_C_FLAGS "${WERROR_FLAGS} ${CMAKE_C_FLAGS}")
  528. SET(CMAKE_CXX_FLAGS "${WERROR_FLAGS} ${CMAKE_CXX_FLAGS}")
  529. SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DLMMS_DEBUG")
  530. SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DLMMS_DEBUG")
  531. # people simply updating git will still have this and mess up build with it
  532. FILE(REMOVE include/lmmsconfig.h)
  533. FILE(GLOB LMMS_INCLUDES "${CMAKE_SOURCE_DIR}/include/*.h")
  534. LIST(SORT LMMS_INCLUDES)
  535. # Get list of all committers from git history, ordered by number of commits.
  536. # The CONTRIBUTORS file is used by AboutDialog. This information can be provided
  537. # with -DCONTRIBUTORS=/path/to/CONTRIBUTORS instead. For instance, to generate
  538. # this file for version 1.1.3, the command is:
  539. # git shortlog -sne v1.1.3 | cut -c8-
  540. FIND_PACKAGE(Git)
  541. IF(GIT_FOUND AND NOT CONTRIBUTORS)
  542. SET(CONTRIBUTORS "${CMAKE_BINARY_DIR}/CONTRIBUTORS")
  543. EXECUTE_PROCESS(
  544. COMMAND "${GIT_EXECUTABLE}" shortlog -sne
  545. COMMAND cut -c8-
  546. OUTPUT_FILE "${CONTRIBUTORS}"
  547. WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
  548. TIMEOUT 1)
  549. ENDIF()
  550. # we somehow have to make LMMS-binary depend on MOC-files
  551. ADD_FILE_DEPENDENCIES("${CMAKE_BINARY_DIR}/lmmsconfig.h")
  552. IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
  553. IF(WIN32)
  554. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes")
  555. ELSE(WIN32)
  556. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -DPIC")
  557. ENDIF(WIN32)
  558. ENDIF()
  559. # use ccache
  560. include(CompileCache)
  561. # make sub-directories
  562. ADD_SUBDIRECTORY(cmake)
  563. ADD_SUBDIRECTORY(src)
  564. ADD_SUBDIRECTORY(plugins)
  565. ADD_SUBDIRECTORY(tests)
  566. ADD_SUBDIRECTORY(data)
  567. ADD_SUBDIRECTORY(doc)
  568. # install tasks
  569. ADD_SUBDIRECTORY(cmake/install)
  570. FIND_PACKAGE(UnixCommands)
  571. IF(GZIP)
  572. ADD_CUSTOM_COMMAND(OUTPUT "${CMAKE_BINARY_DIR}/lmms.1.gz"
  573. COMMAND ${GZIP} -c ${CMAKE_SOURCE_DIR}/doc/lmms.1 > ${CMAKE_BINARY_DIR}/lmms.1.gz
  574. DEPENDS "${CMAKE_SOURCE_DIR}/doc/lmms.1"
  575. COMMENT "Generating lmms.1.gz"
  576. VERBATIM)
  577. ADD_CUSTOM_TARGET(manpage ALL
  578. DEPENDS "${CMAKE_BINARY_DIR}/lmms.1.gz")
  579. ELSEIF(UNIX)
  580. MESSAGE(FATAL_ERROR "Can't find gzip required for generating lmms.1.gz")
  581. ENDIF()
  582. # install headers
  583. IF(LMMS_BUILD_LINUX)
  584. INSTALL(FILES ${LMMS_INCLUDES}
  585. "${CMAKE_BINARY_DIR}/lmmsconfig.h"
  586. "${CMAKE_BINARY_DIR}/lmmsversion.h"
  587. "${CMAKE_SOURCE_DIR}/src/gui/embed.cpp"
  588. DESTINATION "${CMAKE_INSTALL_PREFIX}/include/lmms/")
  589. ENDIF(LMMS_BUILD_LINUX)
  590. # package ZynAddSubFX into win32 build
  591. IF(LMMS_BUILD_WIN32)
  592. IF(EXISTS "${CMAKE_SOURCE_DIR}/extras")
  593. ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/extras/data/presets")
  594. FILE(GLOB ZASF_BINARIES
  595. "${CMAKE_SOURCE_DIR}/extras/plugins/zynaddsubfx/zynaddsubfx.dll"
  596. "${CMAKE_SOURCE_DIR}/extras/plugins/zynaddsubfx/remote_zynaddsubfx.exe")
  597. LIST(SORT ZASF_BINARIES)
  598. INSTALL(FILES "${ZASF_BINARIES}" DESTINATION "${PLUGIN_DIR}")
  599. ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/extras")
  600. ENDIF(LMMS_BUILD_WIN32)
  601. #
  602. # add distclean-target
  603. #
  604. ADD_CUSTOM_TARGET(distclean
  605. COMMAND make clean
  606. COMMAND rm -rf `find -name cmake_install.cmake` `find -name Makefile` `find -type d -name CMakeFiles` CMakeCache.txt lmmsconfig.h lmms.1.gz)
  607. #
  608. # add tarball-target
  609. #
  610. SET(TMP "lmms-${VERSION}")
  611. ADD_CUSTOM_TARGET(dist
  612. COMMAND make clean
  613. COMMAND rm -rf "${TMP}"
  614. COMMAND mkdir -p "${TMP}"
  615. COMMAND cp CMakeLists.txt LICENSE.txt INSTALL.txt README.md "${TMP}"
  616. COMMAND cp -r buildtools cmake data doc include plugins src "${TMP}"
  617. COMMAND rm -rf `find "${TMP}" -name cmake_install.cmake` `find "${TMP}" -name Makefile` `find "${TMP}" -type d -name CMakeFiles` "${TMP}/CMakeCache.txt"
  618. COMMAND tar cjf lmms-${VERSION}-src.tar.bz2 "${TMP}"
  619. COMMAND rm -rf "${TMP}")
  620. #
  621. # add uninstall-target
  622. #
  623. ADD_CUSTOM_TARGET(uninstall
  624. COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}" -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/uninstall.cmake"
  625. )
  626. #
  627. # display configuration information
  628. #
  629. MESSAGE("\n"
  630. "Installation Summary\n"
  631. "--------------------\n"
  632. "* Install Directory : ${CMAKE_INSTALL_PREFIX}\n"
  633. )
  634. MESSAGE(
  635. "Supported audio interfaces\n"
  636. "--------------------------\n"
  637. "* ALSA : ${STATUS_ALSA}\n"
  638. "* JACK : ${STATUS_JACK}\n"
  639. "* OSS : ${STATUS_OSS}\n"
  640. "* Sndio : ${STATUS_SNDIO}\n"
  641. "* PortAudio : ${STATUS_PORTAUDIO}\n"
  642. "* libsoundio : ${STATUS_SOUNDIO}\n"
  643. "* PulseAudio : ${STATUS_PULSEAUDIO}\n"
  644. "* SDL : ${STATUS_SDL}\n"
  645. )
  646. MESSAGE(
  647. "Supported MIDI interfaces\n"
  648. "-------------------------\n"
  649. "* ALSA : ${STATUS_ALSA}\n"
  650. "* OSS : ${STATUS_OSS}\n"
  651. "* Sndio : ${STATUS_SNDIO}\n"
  652. "* JACK : ${STATUS_JACK}\n"
  653. "* WinMM : ${STATUS_WINMM}\n"
  654. "* AppleMidi : ${STATUS_APPLEMIDI}\n"
  655. )
  656. MESSAGE(
  657. "Supported file formats for project export\n"
  658. "-----------------------------------------\n"
  659. "* WAVE : OK\n"
  660. "* FLAC : OK\n"
  661. "* OGG/VORBIS : ${STATUS_OGGVORBIS}\n"
  662. "* MP3/Lame : ${STATUS_MP3LAME}\n"
  663. )
  664. MESSAGE(
  665. "Optional plugins\n"
  666. "----------------\n"
  667. "* Lv2 plugins : ${STATUS_LV2}\n"
  668. "* SUIL for plugin UIs : ${STATUS_SUIL}\n"
  669. "* ZynAddSubFX instrument : ${STATUS_ZYN}\n"
  670. "* Carla Patchbay & Rack : ${STATUS_CARLA}\n"
  671. "* SoundFont2 player : ${STATUS_FLUIDSYNTH}\n"
  672. "* Stk Mallets : ${STATUS_STK}\n"
  673. "* VST-instrument hoster : ${STATUS_VST}\n"
  674. "* VST-effect hoster : ${STATUS_VST}\n"
  675. "* CALF LADSPA plugins : ${STATUS_CALF}\n"
  676. "* CAPS LADSPA plugins : ${STATUS_CAPS}\n"
  677. "* CMT LADSPA plugins : ${STATUS_CMT}\n"
  678. "* TAP LADSPA plugins : ${STATUS_TAP}\n"
  679. "* SWH LADSPA plugins : ${STATUS_SWH}\n"
  680. "* GIG player : ${STATUS_GIG}\n"
  681. )
  682. MESSAGE(
  683. "Developer options\n"
  684. "-----------------------------------------\n"
  685. "* Debug FP exceptions : ${STATUS_DEBUG_FPE}\n"
  686. )
  687. MESSAGE(
  688. "\n"
  689. "-----------------------------------------------------------------\n"
  690. "IMPORTANT:\n"
  691. "after installing missing packages, remove CMakeCache.txt before\n"
  692. "running cmake again!\n"
  693. "-----------------------------------------------------------------\n"
  694. "\n\n")
  695. SET(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION "${BIN_DIR}")
  696. if(MSVC)
  697. # We can't set this on the install time according to the configuration
  698. SET(CMAKE_INSTALL_DEBUG_LIBRARIES TRUE)
  699. SET(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
  700. endif()
  701. INCLUDE(InstallRequiredSystemLibraries)