CMakeLists.txt 20 KB

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