CMakeLists.txt 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  1. CMAKE_MINIMUM_REQUIRED(VERSION 3.3)
  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(/usr/local/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(-D'QT_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 SF_SET_COMPRESSION_LEVEL
  170. IF(NOT SNDFILE_VERSION VERSION_LESS 1.0.26)
  171. SET(LMMS_HAVE_SF_COMPLEVEL TRUE)
  172. ENDIF()
  173. IF(WANT_LV2)
  174. IF(PKG_CONFIG_FOUND)
  175. PKG_CHECK_MODULES(LV2 lv2)
  176. PKG_CHECK_MODULES(LILV lilv-0)
  177. ENDIF()
  178. IF(NOT LV2_FOUND AND NOT LILV_FOUND)
  179. FIND_PACKAGE(LV2 CONFIG)
  180. FIND_PACKAGE(LILV CONFIG)
  181. IF(LILV_FOUND)
  182. SET(LILV_LIBRARIES "lilv::lilv")
  183. ENDIF()
  184. ENDIF()
  185. IF(LV2_FOUND AND LILV_FOUND)
  186. SET(LMMS_HAVE_LV2 TRUE)
  187. SET(STATUS_LV2 "OK")
  188. ELSE()
  189. SET(STATUS_LV2 "not found, install it or set PKG_CONFIG_PATH appropriately")
  190. ENDIF()
  191. ELSE(WANT_LV2)
  192. SET(STATUS_LV2 "not built as requested")
  193. ENDIF(WANT_LV2)
  194. IF(WANT_SUIL)
  195. IF(PKG_CONFIG_FOUND)
  196. PKG_CHECK_MODULES(SUIL suil-0)
  197. IF(SUIL_FOUND)
  198. SET(LMMS_HAVE_SUIL TRUE)
  199. SET(STATUS_SUIL "OK")
  200. ELSE()
  201. SET(STATUS_SUIL "not found, install it or set PKG_CONFIG_PATH appropriately")
  202. ENDIF()
  203. ELSE()
  204. SET(STATUS_SUIL "not found, requires pkg-config")
  205. ENDIF()
  206. ELSE(WANT_SUIL)
  207. SET(STATUS_SUIL "not built as requested")
  208. ENDIF(WANT_SUIL)
  209. IF(WANT_CALF)
  210. SET(LMMS_HAVE_CALF TRUE)
  211. SET(STATUS_CALF "OK")
  212. ELSE(WANT_CALF)
  213. SET(STATUS_CALF "not built as requested")
  214. ENDIF(WANT_CALF)
  215. IF(WANT_CAPS)
  216. SET(LMMS_HAVE_CAPS TRUE)
  217. SET(STATUS_CAPS "OK")
  218. ELSE(WANT_CAPS)
  219. SET(STATUS_CAPS "not built as requested")
  220. ENDIF(WANT_CAPS)
  221. IF(WANT_CMT)
  222. SET(LMMS_HAVE_CMT TRUE)
  223. SET(STATUS_CMT "OK")
  224. ELSE(WANT_CMT)
  225. SET(STATUS_CMT "not built as requested")
  226. ENDIF(WANT_CMT)
  227. IF(WANT_SWH)
  228. SET(LMMS_HAVE_SWH TRUE)
  229. SET(STATUS_SWH "OK")
  230. ELSE(WANT_SWH)
  231. SET(STATUS_SWH "not built as requested")
  232. ENDIF(WANT_SWH)
  233. IF(WANT_TAP)
  234. SET(LMMS_HAVE_TAP TRUE)
  235. SET(STATUS_TAP "OK")
  236. ELSE(WANT_TAP)
  237. SET(STATUS_TAP "not built as requested")
  238. ENDIF(WANT_TAP)
  239. # check for CARLA
  240. IF(WANT_CARLA)
  241. PKG_CHECK_MODULES(CARLA carla-native-plugin)
  242. # look for carla under old name
  243. IF(NOT CARLA_FOUND)
  244. PKG_CHECK_MODULES(CARLA carla-standalone>=1.9.5)
  245. ENDIF()
  246. IF(CARLA_FOUND)
  247. SET(LMMS_HAVE_CARLA TRUE)
  248. SET(STATUS_CARLA "OK")
  249. ELSE(CARLA_FOUND)
  250. SET(LMMS_HAVE_WEAKCARLA TRUE)
  251. SET(STATUS_CARLA "OK (weak linking enabled)")
  252. ENDIF(CARLA_FOUND)
  253. ENDIF(WANT_CARLA)
  254. # check for SDL2
  255. IF(WANT_SDL)
  256. SET(SDL2_BUILDING_LIBRARY TRUE)
  257. FIND_PACKAGE(SDL2)
  258. IF(SDL2_FOUND)
  259. SET(LMMS_HAVE_SDL TRUE)
  260. SET(LMMS_HAVE_SDL2 TRUE)
  261. SET(STATUS_SDL "OK, using SDL2")
  262. SET(SDL_INCLUDE_DIR "")
  263. SET(SDL_LIBRARY "")
  264. ELSE()
  265. SET(SDL2_INCLUDE_DIR "")
  266. SET(SDL2_LIBRARY "")
  267. ENDIF()
  268. ENDIF()
  269. # fallback to SDL1
  270. IF(WANT_SDL AND NOT LMMS_HAVE_SDL2)
  271. # Fallback to SDL1.2
  272. SET(SDL_BUILDING_LIBRARY TRUE)
  273. FIND_PACKAGE(SDL)
  274. IF(SDL_FOUND)
  275. SET(LMMS_HAVE_SDL TRUE)
  276. SET(STATUS_SDL "OK, using SDL1.2")
  277. # fix mingw since 53abd65
  278. IF(NOT SDL_INCLUDE_DIR)
  279. SET(SDL_INCLUDE_DIR "${CMAKE_FIND_ROOT_PATH}/include")
  280. ENDIF()
  281. ELSE()
  282. SET(STATUS_SDL "not found, please install libsdl2-dev (or similar) "
  283. "if you require SDL support")
  284. SET(SDL_INCLUDE_DIR "")
  285. SET(SDL_LIBRARY "")
  286. ENDIF()
  287. ENDIF()
  288. # check for Stk
  289. IF(WANT_STK)
  290. FIND_PACKAGE(STK)
  291. IF(STK_FOUND)
  292. SET(LMMS_HAVE_STK TRUE)
  293. SET(STATUS_STK "OK")
  294. ELSE(STK_FOUND)
  295. SET(STK_INCLUDE_DIR "")
  296. SET(STATUS_STK "not found, please install libstk0-dev (or similar) "
  297. "if you require the Mallets instrument")
  298. ENDIF(STK_FOUND)
  299. ENDIF(WANT_STK)
  300. # check for PortAudio
  301. IF(WANT_PORTAUDIO)
  302. FIND_PACKAGE(Portaudio)
  303. IF(PORTAUDIO_FOUND)
  304. SET(LMMS_HAVE_PORTAUDIO TRUE)
  305. SET(STATUS_PORTAUDIO "OK")
  306. ELSE(PORTAUDIO_FOUND)
  307. SET(STATUS_PORTAUDIO "not found, please install portaudio19-dev (or similar, version >= 1.9) "
  308. "if you require PortAudio support")
  309. ENDIF(PORTAUDIO_FOUND)
  310. ENDIF(WANT_PORTAUDIO)
  311. # check for libsoundio
  312. IF(WANT_SOUNDIO)
  313. FIND_PACKAGE(SoundIo)
  314. IF(SOUNDIO_FOUND)
  315. SET(LMMS_HAVE_SOUNDIO TRUE)
  316. SET(STATUS_SOUNDIO "OK")
  317. INCLUDE_DIRECTORIES("${SOUNDIO_INCLUDE_DIR}")
  318. ELSE(SOUNDIO_FOUND)
  319. SET(SOUNDIO_INCLUDE_DIR "")
  320. SET(STATUS_SOUNDIO "not found, please install libsoundio if you require libsoundio support")
  321. SET(SOUNDIO_LIBRARY "")
  322. ENDIF(SOUNDIO_FOUND)
  323. ENDIF(WANT_SOUNDIO)
  324. # check for PulseAudio
  325. IF(WANT_PULSEAUDIO)
  326. FIND_PACKAGE(PulseAudio)
  327. IF(PULSEAUDIO_FOUND)
  328. SET(LMMS_HAVE_PULSEAUDIO TRUE)
  329. SET(STATUS_PULSEAUDIO "OK")
  330. ELSE(PULSEAUDIO_FOUND)
  331. SET(STATUS_PULSEAUDIO "not found, please install libpulse-dev (or similar) "
  332. "if you require PulseAudio support")
  333. ENDIF(PULSEAUDIO_FOUND)
  334. ENDIF(WANT_PULSEAUDIO)
  335. IF(NOT LMMS_HAVE_PULSEAUDIO)
  336. SET(PULSEAUDIO_INCLUDE_DIR "")
  337. SET(PULSEAUDIO_LIBRARIES "")
  338. ENDIF(NOT LMMS_HAVE_PULSEAUDIO)
  339. # check for MP3/Lame-libraries
  340. IF(WANT_MP3LAME)
  341. FIND_PACKAGE(Lame)
  342. IF(LAME_FOUND)
  343. SET(LMMS_HAVE_MP3LAME TRUE)
  344. SET(STATUS_MP3LAME "OK")
  345. ELSE(LAME_FOUND)
  346. SET(STATUS_MP3LAME "not found, please install libmp3lame-dev (or similar)")
  347. SET(LAME_LIBRARIES "")
  348. SET(LAME_INCLUDE_DIRS "")
  349. ENDIF(LAME_FOUND)
  350. ELSE(WANT_MP3LAME)
  351. SET(STATUS_MP3LAME "Disabled for build")
  352. ENDIF(WANT_MP3LAME)
  353. # check for OGG/Vorbis-libraries
  354. IF(WANT_OGGVORBIS)
  355. FIND_PACKAGE(OggVorbis)
  356. IF(OGGVORBIS_FOUND)
  357. SET(LMMS_HAVE_OGGVORBIS TRUE)
  358. SET(STATUS_OGGVORBIS "OK")
  359. ELSE(OGGVORBIS_FOUND)
  360. SET(STATUS_OGGVORBIS "not found, libogg-dev and libvorbis-dev (or similar) "
  361. "is highly recommended")
  362. ENDIF(OGGVORBIS_FOUND)
  363. ENDIF(WANT_OGGVORBIS)
  364. # check whether to enable OSS-support
  365. IF(LMMS_HAVE_SOUNDCARD_H OR LMMS_HAVE_SYS_SOUNDCARD_H)
  366. SET(LMMS_HAVE_OSS TRUE)
  367. SET(STATUS_OSS "OK")
  368. ELSE(LMMS_HAVE_SOUNDCARD_H OR LMMS_HAVE_SYS_SOUNDCARD_H)
  369. SET(STATUS_OSS "<not found or not supported on this platform>")
  370. ENDIF(LMMS_HAVE_SOUNDCARD_H OR LMMS_HAVE_SYS_SOUNDCARD_H)
  371. # check for ALSA
  372. IF(WANT_ALSA)
  373. FIND_PACKAGE(Alsa)
  374. IF(ALSA_FOUND)
  375. SET(LMMS_HAVE_ALSA TRUE)
  376. SET(STATUS_ALSA "OK")
  377. ELSE(ALSA_FOUND)
  378. SET(STATUS_ALSA "not found, please install libasound2-dev (or similar) "
  379. "if you require ALSA support")
  380. ENDIF(ALSA_FOUND)
  381. ENDIF(WANT_ALSA)
  382. IF(NOT LMMS_HAVE_ALSA)
  383. SET(ASOUND_LIBRARY "")
  384. ENDIF(NOT LMMS_HAVE_ALSA)
  385. # check for JACK
  386. IF(WANT_JACK)
  387. IF(WANT_WEAKJACK)
  388. SET(LMMS_HAVE_WEAKJACK TRUE)
  389. SET(WEAKJACK_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/3rdparty/weakjack/weakjack)
  390. SET(JACK_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/3rdparty/jack2/common)
  391. SET(STATUS_JACK "OK (weak linking enabled)")
  392. # use dlsym instead
  393. SET(JACK_LIBRARIES ${CMAKE_DL_LIBS})
  394. SET(LMMS_HAVE_JACK TRUE)
  395. SET(LMMS_HAVE_JACK_PRENAME TRUE)
  396. SET(JACK_FOUND TRUE)
  397. ELSE()
  398. PKG_CHECK_MODULES(JACK jack>=0.77)
  399. IF(JACK_FOUND)
  400. SET(LMMS_HAVE_JACK TRUE)
  401. SET(STATUS_JACK "OK")
  402. SET(CMAKE_REQUIRED_LIBRARIES_BACKUP "${CMAKE_REQUIRED_LIBRARIES}")
  403. SET(CMAKE_REQUIRED_LIBRARIES "${JACK_LIBRARIES}")
  404. CHECK_LIBRARY_EXISTS(jack jack_port_rename "" LMMS_HAVE_JACK_PRENAME)
  405. SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_BACKUP}")
  406. UNSET(CMAKE_REQUIRED_LIBRARIES_BACKUP)
  407. ENDIF()
  408. ENDIF()
  409. IF(NOT JACK_FOUND)
  410. SET(JACK_INCLUDE_DIRS "")
  411. SET(STATUS_JACK "not found")
  412. ENDIF()
  413. ENDIF(WANT_JACK)
  414. # check for FFTW3F-library
  415. FIND_PACKAGE(FFTW COMPONENTS fftw3f REQUIRED)
  416. # check for FLTK
  417. FIND_PACKAGE(FLTK)
  418. IF(FLTK_FOUND)
  419. SET(STATUS_ZYN "OK")
  420. ELSE()
  421. SET(STATUS_ZYN "not found, please install fltk")
  422. ENDIF()
  423. # check for Fluidsynth
  424. IF(WANT_SF2)
  425. PKG_CHECK_MODULES(FLUIDSYNTH fluidsynth>=1.0.7)
  426. IF(FLUIDSYNTH_FOUND)
  427. SET(LMMS_HAVE_FLUIDSYNTH TRUE)
  428. SET(STATUS_FLUIDSYNTH "OK")
  429. ELSE(FLUIDSYNTH_FOUND)
  430. SET(STATUS_FLUIDSYNTH "not found, libfluidsynth-dev (or similar)"
  431. "is highly recommended")
  432. ENDIF(FLUIDSYNTH_FOUND)
  433. ENDIF(WANT_SF2)
  434. # check for libgig
  435. If(WANT_GIG)
  436. PKG_CHECK_MODULES(GIG gig)
  437. IF(GIG_FOUND)
  438. SET(LMMS_HAVE_GIG TRUE)
  439. SET(STATUS_GIG "OK")
  440. ELSE(GIG_FOUND)
  441. SET(STATUS_GIG "not found, libgig needed for decoding .gig files")
  442. ENDIF(GIG_FOUND)
  443. ENDIF(WANT_GIG)
  444. # check for pthreads
  445. IF(LMMS_BUILD_LINUX OR LMMS_BUILD_APPLE OR LMMS_BUILD_OPENBSD OR LMMS_BUILD_FREEBSD OR LMMS_BUILD_HAIKU)
  446. FIND_PACKAGE(Threads)
  447. ENDIF(LMMS_BUILD_LINUX OR LMMS_BUILD_APPLE OR LMMS_BUILD_OPENBSD OR LMMS_BUILD_FREEBSD OR LMMS_BUILD_HAIKU)
  448. # check for sndio (roaraudio won't work yet)
  449. IF(WANT_SNDIO)
  450. FIND_PACKAGE(Sndio)
  451. IF(SNDIO_FOUND)
  452. SET(LMMS_HAVE_SNDIO TRUE)
  453. SET(STATUS_SNDIO "OK")
  454. ELSE()
  455. SET(STATUS_SNDIO "<not found or not supported on this platform>")
  456. ENDIF(SNDIO_FOUND)
  457. ENDIF(WANT_SNDIO)
  458. # check for WINE
  459. IF(WANT_VST)
  460. FIND_PACKAGE(Wine)
  461. IF(WINE_FOUND)
  462. SET(LMMS_SUPPORT_VST TRUE)
  463. IF(WINE_LIBRARY_FIX)
  464. SET(STATUS_VST "OK, with workaround linking ${WINE_LIBRARY_FIX}")
  465. ELSE()
  466. SET(STATUS_VST "OK")
  467. ENDIF()
  468. ELSEIF(WANT_VST_NOWINE)
  469. SET(LMMS_SUPPORT_VST TRUE)
  470. SET(STATUS_VST "OK")
  471. ELSE(WINE_FOUND)
  472. SET(STATUS_VST "not found, please install (lib)wine-dev (or similar) - 64 bit systems additionally need gcc-multilib and g++-multilib")
  473. ENDIF(WINE_FOUND)
  474. ENDIF(WANT_VST)
  475. IF(LMMS_BUILD_WIN32)
  476. SET(LMMS_SUPPORT_VST TRUE)
  477. SET(STATUS_VST "OK")
  478. ENDIF(LMMS_BUILD_WIN32)
  479. IF(WANT_DEBUG_FPE)
  480. IF(LMMS_BUILD_LINUX OR LMMS_BUILD_APPLE)
  481. SET(LMMS_DEBUG_FPE TRUE)
  482. SET (STATUS_DEBUG_FPE "Enabled")
  483. ELSE()
  484. SET (STATUS_DEBUG_FPE "Wanted but disabled due to unsupported platform")
  485. ENDIF()
  486. ELSE()
  487. SET (STATUS_DEBUG_FPE "Disabled")
  488. ENDIF(WANT_DEBUG_FPE)
  489. # check for libsamplerate
  490. FIND_PACKAGE(Samplerate 0.1.8 MODULE REQUIRED)
  491. # set compiler flags
  492. IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
  493. SET(WERROR_FLAGS "-Wall -Werror=unused-function -Wno-sign-compare -Wno-strict-overflow")
  494. OPTION(USE_WERROR "Add -werror to the build flags. Stops the build on warnings" OFF)
  495. IF(${USE_WERROR})
  496. SET(WERROR_FLAGS "${WERROR_FLAGS} -Werror")
  497. ENDIF()
  498. # Due to a regression in gcc-4.8.X, we need to disable array-bounds check
  499. 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))
  500. SET(WERROR_FLAGS "${WERROR_FLAGS} -Wno-array-bounds -Wno-attributes")
  501. ENDIF()
  502. ELSEIF(MSVC)
  503. # Remove any existing /W flags
  504. STRING(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
  505. SET(WERROR_FLAGS "/W2")
  506. IF(${USE_WERROR})
  507. SET(WERROR_FLAGS "${WERROR_FLAGS} /WX")
  508. ENDIF()
  509. ENDIF()
  510. IF(NOT CMAKE_BUILD_TYPE)
  511. message(STATUS "Setting build type to 'Release' as none was specified.")
  512. set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
  513. # Set the possible values of build type for cmake-gui
  514. SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
  515. "MinSizeRel" "RelWithDebInfo")
  516. ENDIF()
  517. SET(CMAKE_C_FLAGS "${WERROR_FLAGS} ${CMAKE_C_FLAGS}")
  518. SET(CMAKE_CXX_FLAGS "${WERROR_FLAGS} ${CMAKE_CXX_FLAGS}")
  519. SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DLMMS_DEBUG")
  520. SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DLMMS_DEBUG")
  521. # people simply updating git will still have this and mess up build with it
  522. FILE(REMOVE include/lmmsconfig.h)
  523. FILE(GLOB LMMS_INCLUDES "${CMAKE_SOURCE_DIR}/include/*.h")
  524. LIST(SORT LMMS_INCLUDES)
  525. # Get list of all committers from git history, ordered by number of commits.
  526. # The CONTRIBUTORS file is used by AboutDialog. This information can be provided
  527. # with -DCONTRIBUTORS=/path/to/CONTRIBUTORS instead. For instance, to generate
  528. # this file for version 1.1.3, the command is:
  529. # git shortlog -sne v1.1.3 | cut -c8-
  530. FIND_PACKAGE(Git)
  531. IF(GIT_FOUND AND NOT CONTRIBUTORS)
  532. SET(CONTRIBUTORS "${CMAKE_BINARY_DIR}/CONTRIBUTORS")
  533. EXECUTE_PROCESS(
  534. COMMAND "${GIT_EXECUTABLE}" shortlog -sne
  535. COMMAND cut -c8-
  536. OUTPUT_FILE "${CONTRIBUTORS}"
  537. WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
  538. TIMEOUT 1)
  539. ENDIF()
  540. # we somehow have to make LMMS-binary depend on MOC-files
  541. ADD_FILE_DEPENDENCIES("${CMAKE_BINARY_DIR}/lmmsconfig.h")
  542. IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
  543. IF(WIN32)
  544. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes")
  545. ELSE(WIN32)
  546. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -DPIC")
  547. ENDIF(WIN32)
  548. ENDIF()
  549. # use ccache
  550. include(CompileCache)
  551. # make sub-directories
  552. ADD_SUBDIRECTORY(cmake)
  553. ADD_SUBDIRECTORY(src)
  554. ADD_SUBDIRECTORY(plugins)
  555. ADD_SUBDIRECTORY(tests)
  556. ADD_SUBDIRECTORY(data)
  557. ADD_SUBDIRECTORY(doc)
  558. # install tasks
  559. ADD_SUBDIRECTORY(cmake/install)
  560. FIND_PACKAGE(UnixCommands)
  561. IF(GZIP)
  562. ADD_CUSTOM_COMMAND(OUTPUT "${CMAKE_BINARY_DIR}/lmms.1.gz"
  563. COMMAND ${GZIP} -c ${CMAKE_SOURCE_DIR}/doc/lmms.1 > ${CMAKE_BINARY_DIR}/lmms.1.gz
  564. DEPENDS "${CMAKE_SOURCE_DIR}/doc/lmms.1"
  565. COMMENT "Generating lmms.1.gz"
  566. VERBATIM)
  567. ADD_CUSTOM_TARGET(manpage ALL
  568. DEPENDS "${CMAKE_BINARY_DIR}/lmms.1.gz")
  569. ELSEIF(UNIX)
  570. MESSAGE(FATAL_ERROR "Can't find gzip required for generating lmms.1.gz")
  571. ENDIF()
  572. # install headers
  573. IF(LMMS_BUILD_LINUX)
  574. INSTALL(FILES ${LMMS_INCLUDES}
  575. "${CMAKE_BINARY_DIR}/lmmsconfig.h"
  576. "${CMAKE_BINARY_DIR}/lmmsversion.h"
  577. "${CMAKE_SOURCE_DIR}/src/gui/embed.cpp"
  578. DESTINATION "${CMAKE_INSTALL_PREFIX}/include/lmms/")
  579. ENDIF(LMMS_BUILD_LINUX)
  580. # package ZynAddSubFX into win32 build
  581. IF(LMMS_BUILD_WIN32)
  582. IF(EXISTS "${CMAKE_SOURCE_DIR}/extras")
  583. ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/extras/data/presets")
  584. FILE(GLOB ZASF_BINARIES
  585. "${CMAKE_SOURCE_DIR}/extras/plugins/zynaddsubfx/zynaddsubfx.dll"
  586. "${CMAKE_SOURCE_DIR}/extras/plugins/zynaddsubfx/remote_zynaddsubfx.exe")
  587. LIST(SORT ZASF_BINARIES)
  588. INSTALL(FILES "${ZASF_BINARIES}" DESTINATION "${PLUGIN_DIR}")
  589. ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/extras")
  590. ENDIF(LMMS_BUILD_WIN32)
  591. #
  592. # add distclean-target
  593. #
  594. ADD_CUSTOM_TARGET(distclean
  595. COMMAND make clean
  596. COMMAND rm -rf `find -name cmake_install.cmake` `find -name Makefile` `find -type d -name CMakeFiles` CMakeCache.txt lmmsconfig.h lmms.1.gz)
  597. #
  598. # add tarball-target
  599. #
  600. SET(TMP "lmms-${VERSION}")
  601. ADD_CUSTOM_TARGET(dist
  602. COMMAND make clean
  603. COMMAND rm -rf "${TMP}"
  604. COMMAND mkdir -p "${TMP}"
  605. COMMAND cp CMakeLists.txt LICENSE.txt INSTALL.txt README.md "${TMP}"
  606. COMMAND cp -r buildtools cmake data doc include plugins src "${TMP}"
  607. COMMAND rm -rf `find "${TMP}" -name cmake_install.cmake` `find "${TMP}" -name Makefile` `find "${TMP}" -type d -name CMakeFiles` "${TMP}/CMakeCache.txt"
  608. COMMAND tar cjf lmms-${VERSION}-src.tar.bz2 "${TMP}"
  609. COMMAND rm -rf "${TMP}")
  610. #
  611. # add uninstall-target
  612. #
  613. ADD_CUSTOM_TARGET(uninstall
  614. COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}" -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/uninstall.cmake"
  615. )
  616. #
  617. # display configuration information
  618. #
  619. MESSAGE("\n"
  620. "Installation Summary\n"
  621. "--------------------\n"
  622. "* Install Directory : ${CMAKE_INSTALL_PREFIX}\n"
  623. )
  624. MESSAGE(
  625. "Supported audio interfaces\n"
  626. "--------------------------\n"
  627. "* ALSA : ${STATUS_ALSA}\n"
  628. "* JACK : ${STATUS_JACK}\n"
  629. "* OSS : ${STATUS_OSS}\n"
  630. "* Sndio : ${STATUS_SNDIO}\n"
  631. "* PortAudio : ${STATUS_PORTAUDIO}\n"
  632. "* libsoundio : ${STATUS_SOUNDIO}\n"
  633. "* PulseAudio : ${STATUS_PULSEAUDIO}\n"
  634. "* SDL : ${STATUS_SDL}\n"
  635. )
  636. MESSAGE(
  637. "Supported MIDI interfaces\n"
  638. "-------------------------\n"
  639. "* ALSA : ${STATUS_ALSA}\n"
  640. "* OSS : ${STATUS_OSS}\n"
  641. "* Sndio : ${STATUS_SNDIO}\n"
  642. "* JACK : ${STATUS_JACK}\n"
  643. "* WinMM : ${STATUS_WINMM}\n"
  644. "* AppleMidi : ${STATUS_APPLEMIDI}\n"
  645. )
  646. MESSAGE(
  647. "Supported file formats for project export\n"
  648. "-----------------------------------------\n"
  649. "* WAVE : OK\n"
  650. "* FLAC : OK\n"
  651. "* OGG/VORBIS : ${STATUS_OGGVORBIS}\n"
  652. "* MP3/Lame : ${STATUS_MP3LAME}\n"
  653. )
  654. MESSAGE(
  655. "Optional plugins\n"
  656. "----------------\n"
  657. "* Lv2 plugins : ${STATUS_LV2}\n"
  658. "* SUIL for plugin UIs : ${STATUS_SUIL}\n"
  659. "* ZynAddSubFX instrument : ${STATUS_ZYN}\n"
  660. "* Carla Patchbay & Rack : ${STATUS_CARLA}\n"
  661. "* SoundFont2 player : ${STATUS_FLUIDSYNTH}\n"
  662. "* Stk Mallets : ${STATUS_STK}\n"
  663. "* VST-instrument hoster : ${STATUS_VST}\n"
  664. "* VST-effect hoster : ${STATUS_VST}\n"
  665. "* CALF LADSPA plugins : ${STATUS_CALF}\n"
  666. "* CAPS LADSPA plugins : ${STATUS_CAPS}\n"
  667. "* CMT LADSPA plugins : ${STATUS_CMT}\n"
  668. "* TAP LADSPA plugins : ${STATUS_TAP}\n"
  669. "* SWH LADSPA plugins : ${STATUS_SWH}\n"
  670. "* GIG player : ${STATUS_GIG}\n"
  671. )
  672. MESSAGE(
  673. "Developer options\n"
  674. "-----------------------------------------\n"
  675. "* Debug FP exceptions : ${STATUS_DEBUG_FPE}\n"
  676. )
  677. MESSAGE(
  678. "\n"
  679. "-----------------------------------------------------------------\n"
  680. "IMPORTANT:\n"
  681. "after installing missing packages, remove CMakeCache.txt before\n"
  682. "running cmake again!\n"
  683. "-----------------------------------------------------------------\n"
  684. "\n\n")
  685. SET(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION "${BIN_DIR}")
  686. if(MSVC)
  687. # We can't set this on the install time according to the configuration
  688. SET(CMAKE_INSTALL_DEBUG_LIBRARIES TRUE)
  689. SET(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
  690. endif()
  691. INCLUDE(InstallRequiredSystemLibraries)