CMakeLists.txt 21 KB

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