CMakeLists.txt 21 KB

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