forked from hydrogen-music/hydrogen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
382 lines (332 loc) · 13.3 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
#
# CMAKE SETUP
#
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
# The CMake Policy mechanism is designed to help keep existing projects building as new versions of CMake introduce changes in behavior.
# http://www.cmake.org/cmake/help/cmake2.6docs.html#command:cmake_policy
IF(COMMAND CMAKE_POLICY)
# CMAKE_POLICY(SET CMP0005 NEW)
CMAKE_POLICY(SET CMP0003 NEW) # add_library
CMAKE_POLICY(SET CMP0006 NEW) # bundle destination property
ENDIF()
#
# PROJECT INFO
#
PROJECT(hydrogen)
SET(VERSION_MAJOR "0")
SET(VERSION_MINOR "9")
SET(VERSION_PATCH "6")
#SET(VERSION_SUFFIX "RC2")
SET(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
IF(VERSION_SUFFIX)
SET(DISPLAY_VERSION "${VERSION}-${VERSION_SUFFIX}")
ELSE()
EXECUTE_PROCESS(COMMAND git log --pretty=format:'%h' -n 1 OUTPUT_VARIABLE GIT_REVISION )
SET(DISPLAY_VERSION "${VERSION}-${GIT_REVISION}")
ENDIF(VERSION_SUFFIX)
SET(LIBSNDFILE_VERSION_PREV "1.0.17")
#
# CONFIG OPTIONS
#
SET(WANT_LIBTAR TRUE)
OPTION(WANT_DEBUG "build with debug information" ON)
IF(APPLE)
OPTION(WANT_SHARED "Build the core library shared." OFF)
ELSE()
OPTION(WANT_SHARED "Build the core library shared." ON)
ENDIF()
OPTION(WANT_LIBARCHIVE "Enable use of libarchive instead of libtar" ON)
OPTION(WANT_LADSPA "Enable use of LADSPA plugins" ON)
IF(APPLE)
OPTION(WANT_JACKSESSION "Enable use of Jack-Session-Handler" OFF)
ELSE()
OPTION(WANT_JACKSESSION "Enable use of Jack-Session-Handler" ON)
ENDIF()
IF("${CMAKE_SYSTEM_NAME}" MATCHES "NetBSD")
OPTION(WANT_OSS "Include OSS (Open Sound System) support" ON)
ELSE()
OPTION(WANT_OSS "Include OSS (Open Sound System) support" OFF)
ENDIF()
OPTION(WANT_ALSA "Include ALSA (Advanced Linux Sound Architecture) support" ON)
OPTION(WANT_JACK "Include JACK (Jack Audio Connection Kit) support" ON)
OPTION(WANT_PORTAUDIO "Include PortAudio support" OFF)
OPTION(WANT_PORTMIDI "Include PortMidi support" OFF)
OPTION(WANT_PULSEAUDIO "Include PulseAudio support" ON)
OPTION(WANT_LASH "Include LASH (Linux Audio Session Handler) support" OFF)
OPTION(WANT_LRDF "Include LRDF (Lightweight Resource Description Framework with special support for LADSPA plugins) support" OFF)
OPTION(WANT_RUBBERBAND "Include RUbberBand (Audio Time Stretcher Library) support" OFF)
IF(APPLE)
OPTION(WANT_COREAUDIO "Include CoreAudio support" ON)
OPTION(WANT_COREMIDI "Include CoreMidi support" ON)
OPTION(WANT_BUNDLE "Build a MAC OSX bundle application" ON)
ENDIF()
OPTION(WANT_CPPUNIT "Include CppUnit test suite" ON)
IF(WANT_DEBUG)
SET(CMAKE_BUILD_TYPE Debug)
SET(H2CORE_HAVE_DEBUG TRUE)
ELSE()
SET(CMAKE_BUILD_TYPE Release)
SET(H2CORE_HAVE_DEBUG FALSE)
ENDIF()
IF(WANT_BUNDLE)
SET(H2CORE_HAVE_BUNDLE TRUE)
ELSE()
SET(H2CORE_HAVE_BUNDLE FALSE)
ENDIF()
IF(WANT_SHARED)
SET(H2CORE_LIBRARY_TYPE SHARED)
ELSE()
SET(H2CORE_LIBRARY_TYPE STATIC)
ENDIF()
#SET(CMAKE_CXX_FLAGS "-fno-implement-inlines -finline-small-functions -findirect-inlining -fpartial-inlining")
IF(APPLE)
SET(CMAKE_CXX_FLAGS "-O2")
ELSE()
SET(CMAKE_CXX_FLAGS "-O2 -fno-implement-inlines")
ENDIF()
SET(CMAKE_CXX_FLAGS_RELEASE "")
SET(CMAKE_CXX_FLAGS_DEBUG "-g ")#-Winline")
IF(APPLE)
#Compile for 32bit and 64bit intel macs
SET (CMAKE_OSX_ARCHITECTURES "x86_64;")
ENDIF()
#
# MANDATORY PKGS AND DEFAULT OPTIONS
#
INCLUDE(StatusSupportOptions)
MANDATORY_PKG(QT4)
MANDATORY_PKG(Threads)
MANDATORY_PKG(LIBSNDFILE)
# TODO remove data from path
SET(SYS_DATA_PATH "${CMAKE_INSTALL_PREFIX}/share/hydrogen/data")
# TODO remove data from path, could be .config/hydrogen
SET(USR_DATA_PATH ".hydrogen/data")
IF(WIN32)
SET(WANT_JACK FALSE)
SET(Threads_PATH "C:/Program Files/GnuWin32")
SET(LIBARCHIVE_PATH "C:/Program Files/GnuWin32")
SET(LIBSNDFILE_PATH "C:/Program Files/Mega-Nerd/libsndfile")
ELSE(WIN32)
IF(APPLE)
LINK_DIRECTORIES("/opt/local/lib")
ELSE(APPLE)
SET(OSS_LIB_PATHS "/usr/lib${LIB_SUFFIX}/oss/lib" "/usr/local/lib${LIB_SUFFIX}/oss/lib" )
SET(RUBBERBAND_INCLUDE_PATHS "/usr/include/rubberband" )
ENDIF(APPLE)
ENDIF(WIN32)
#
# HEADER LIBRARY FUNCTIONS
#
INCLUDE(CompileHelper)
INCLUDE(FindHelper)
INCLUDE(FindLadspa)
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckLibraryExists)
INCLUDE(FindZLIB)
INCLUDE(FindThreads)
COMPILE_HELPER(SSCANF ${CMAKE_SOURCE_DIR}/cmake/sscanf sscanf )
COMPILE_HELPER(RTCLOCK ${CMAKE_SOURCE_DIR}/cmake/rtclock rtclock )
CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILES(sys/stat.h HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILES(libtar.h HAVE_LIBTAR_H)
CHECK_LIBRARY_EXISTS(tar tar_open "" HAVE_LIBTAR_OPEN)
CHECK_LIBRARY_EXISTS(tar tar_close "" HAVE_LIBTAR_CLOSE)
CHECK_LIBRARY_EXISTS(tar tar_extract_all "" HAVE_LIBTAR_EXTRACT_ALL)
IF(HAVE_LIBTAR_H AND HAVE_LIBTAR_OPEN AND HAVE_LIBTAR_CLOSE AND HAVE_LIBTAR_EXTRACT_ALL)
SET(LIBTAR_OK TRUE)
ELSE()
SET(LIBTAR_OK FALSE)
ENDIF()
FIND_HELPER(LIBTAR tar tar.h tar)
IF( NOT LIBTAR_FOUND OR NOT LIBTAR_OK OR NOT ZLIB_FOUND )
SET(WANT_LIBTAR FALSE)
MANDATORY_PKG(LIBARCHIVE)
ENDIF()
FIND_HELPER(LIBARCHIVE archive archive.h archive)
IF( WANT_LIBARCHIVE AND LIBARCHIVE_FOUND)
SET(WANT_LIBTAR FALSE)
ENDIF()
FIND_HELPER(LIBSNDFILE sndfile sndfile.h sndfile)
FIND_HELPER(ALSA alsa alsa/asoundlib.h asound )
FIND_LADSPA(LADSPA ladspa.h noise)
IF("${CMAKE_SYSTEM_NAME}" MATCHES "NetBSD")
FIND_HELPER(OSS oss sys/soundcard.h ossaudio )
ELSE()
FIND_HELPER(OSS oss sys/soundcard.h OSSlib )
ENDIF()
FIND_HELPER(JACK jack jack/jack.h jack)
FIND_HELPER(JACKSESSION jack jack/session.h jack)
IF(APPLE)
FIND_LIBRARY(AUDIOUNIT_LIBRARY AudioUnit)
FIND_LIBRARY(CORESERVICES_LIBRARY CoreServices)
FIND_HELPER(COREAUDIO CoreAudio-2.0 coreaudio.h coreaudio)
FIND_HELPER(COREMIDI CoreMidi coremidi.h coremidi)
ENDIF()
FIND_HELPER(PORTAUDIO portaudio-2.0 portaudio.h portaudio)
FIND_HELPER(PORTMIDI portmidi portmidi.h portmidi)
FIND_HELPER(PULSEAUDIO pulseaudio pulse/pulseaudio.h pulse)
FIND_HELPER(LASH lash-1.0 lash/lash.h lash)
FIND_HELPER(LRDF lrdf lrdf.h lrdf)
FIND_HELPER(RUBBERBAND rubberband RubberBandStretcher.h rubberband)
FIND_HELPER(CPPUNIT cppunit cppunit/TestCase.h cppunit)
# CHECK FOR Qt4
SET(QT_USE_QTNETWORK true)
SET(QT_USE_QTXML true)
SET(QT_USE_QTGUI true)
SET(QT_USE_QTXMLPATTERNS true)
FIND_PACKAGE(Qt4 4.3.0 REQUIRED)
find_package(Doxygen)
if(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/docs
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)
#
# COMPUTE H2CORE_HAVE_xxx xxx_STATUS_REPORT
#
SET(STATUS_LIST LIBSNDFILE LIBTAR LIBARCHIVE LADSPA ALSA OSS JACK JACKSESSION COREAUDIO COREMIDI PORTAUDIO PORTMIDI PULSEAUDIO LASH LRDF RUBBERBAND CPPUNIT )
FOREACH( _pkg ${STATUS_LIST})
COMPUTE_PKGS_FLAGS(${_pkg})
ENDFOREACH()
# LIBSNDFILE CHECKS
STRING( COMPARE GREATER "${LIBSNDFILE_VERSION}" "${LIBSNDFILE_VERSION_PREV}" LIBSNDFILE_VERSION_OK)
IF(LIBSNDFILE_VERSION_OK)
SET(LIBSNDFILE_MSG "libsndfile supports FLAC and OGG sound file formats")
ELSE()
SET(LIBSNDFILE_MSG "libsndfile version must be greater than ${LIBSNDFILE_VERSION_PREV} to support LFAC and OGG sound file formats")
ENDIF()
# RUBBERBAND information
SET(LIBRUBBERBAND_MSG "The use of librubberband2 is marked as experimental.
* Because the current implementation produce wrong timing!
* So long this bug isn't solved, please disable this option.
* If rubberband-cli is installed, the hydrogen rubberband-fuction
* will work properly as expected.")
#
# CONFIG PROCESS SUMMARY
#
SET(reset "${_escape}[0m")
SET(red "${_escape}[1;31m")
SET(purple "${_escape}[1;35m")
SET(cyan "${_escape}[1;36m")
COLOR_MESSAGE("${cyan}Installation Summary${reset}
--------------------
* Install Directory : ${CMAKE_INSTALL_PREFIX}
* User data path : ${USR_DATA_PATH}
* System data path : ${SYS_DATA_PATH}
* core library build as : ${H2CORE_LIBRARY_TYPE}
* debug capabilities : ${H2CORE_HAVE_DEBUG}
* macosx bundle : ${H2CORE_HAVE_BUNDLE}\n"
)
COLOR_MESSAGE("${cyan}Main librarires${reset}
* ${purple}libQt${reset} : ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}
* ${purple}libsndfile${reset} : ${LIBSNDFILE_STATUS}
* ${LIBSNDFILE_MSG}
* ${purple}libtar${reset} : ${LIBTAR_STATUS}
* ${purple}libarchive${reset} : ${LIBARCHIVE_STATUS}
* ${purple}ladspa${reset} : ${LADSPA_STATUS}\n"
)
COLOR_MESSAGE("${cyan}Supported audio interfaces${reset}
--------------------------
* ${purple}ALSA${reset} : ${ALSA_STATUS}
* ${purple}OSS${reset} : ${OSS_STATUS}
* ${purple}JACK${reset} : ${JACK_STATUS}
* ${purple}JACKSESSION${reset} : ${JACKSESSION_STATUS}
* ${purple}CoreAudio${reset} : ${COREAUDIO_STATUS}
* ${purple}CoreMidi${reset} : ${COREMIDI_STATUS}
* ${purple}PortAudio${reset} : ${PORTAUDIO_STATUS}
* ${purple}PortMidi${reset} : ${PORTMIDI_STATUS}
* ${purple}PulseAudio${reset} : ${PULSEAUDIO_STATUS}\n"
)
COLOR_MESSAGE("${cyan}Usefull extensions${reset}
-----------------------------------------
* ${purple}LASH${reset} : ${LASH_STATUS}
* ${purple}LRDF${reset} : ${LRDF_STATUS}
* ${purple}RUBBERBAND${reset} : ${RUBBERBAND_STATUS}
* ${LIBRUBBERBAND_MSG}\n"
)
IF(WANT_DEBUG)
COLOR_MESSAGE("${cyan}Miscellaneous capabilities${reset}
-----------------------------------------
* realtime clock : ${HAVE_RTCLOCK}
* working sscanf : ${HAVE_SSCANF}
* unit tests : ${CPPUNIT_STATUS}\n"
)
ENDIF()
COLOR_MESSAGE("-----------------------------------------------------------------
${red}IMPORTANT:${reset}
after installing missing packages, remove ${CMAKE_BINARY_DIR}/CMakeCache.txt before
running cmake again!
-----------------------------------------------------------------\n"
)
find_path( HYDROGEN_INSTALLED NAMES hydrogen/config.h )
IF( HYDROGEN_INSTALLED )
COLOR_MESSAGE("-----------------------------------------------------------------
${red}IMPORTANT${reset}:
previously installed hydrogen headers found in ${HYDROGEN_INSTALLED}
you should uninstall these files before building hydrogen unless you know what you are doing.
-----------------------------------------------------------------\n"
)
ENDIF()
#
# SET BUILD INFORMATION
#
ADD_SUBDIRECTORY(src/core)
IF(H2CORE_HAVE_CPPUNIT)
ADD_SUBDIRECTORY(src/tests)
ENDIF()
ADD_SUBDIRECTORY(src/cli)
ADD_SUBDIRECTORY(src/player)
ADD_SUBDIRECTORY(src/synth)
ADD_SUBDIRECTORY(src/gui)
INSTALL(DIRECTORY data DESTINATION ${SYS_DATA_PATH}/.. PATTERN ".git" EXCLUDE)
IF(NOT WIN32 AND NOT APPLE)
INSTALL(FILES ${CMAKE_SOURCE_DIR}/linux/hydrogen.desktop DESTINATION "${CMAKE_INSTALL_PREFIX}/share/applications")
ENDIF()
#
# CPack
#
INCLUDE(InstallRequiredSystemLibraries)
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Hydrogen : an advanced drum machine for GNU/Linux")
SET(CPACK_PACKAGE_VENDOR "Hydrogen Developers")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.txt")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
SET(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
IF(VERSION_SUFFIX)
SET(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}-${VERSION_SUFFIX}")
ENDIF(VERSION_SUFFIX)
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "Hydrogen ${VERSION}")
IF(WIN32)
# TODO
#SET(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/data\\\\nsis_branding.bmp")
SET(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/data\\\\hydrogen.ico")
SET(CPACK_NSIS_INSTALLED_ICON_NAME "hydrogen.exe")
SET(CPACK_NSIS_DISPLAY_NAME "Hydrogen (Advanced drum machine for GNU/Linux)")
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.hydrogen-music.org/")
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.hydrogen-music.org/")
SET(CPACK_NSIS_CONTACT "[email protected]")
SET(CPACK_PACKAGE_EXECUTABLES "hydrogen-gui.exe;Advanced drum machine for GNU/Linux")
SET(CPACK_NSIS_MENU_LINKS "hydrogen-gui.exe;Advanced drum machine for GNU/Linux")
SET(CPACK_SOURCE_GENERATOR "ZIP")
ELSE(WIN32)
#apple stuff was moved to src/gui/CMakeLists.txt
ENDIF()
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "hydrogen-${VERSION}")
SET(CPACK_SOURCE_IGNORE_FILES ".*~;\\\\.git;\\\\.svn;${CMAKE_BINARY_DIR}")
#!The following 5 lines are copied from cmake's QtTest example
# To Create a package, one can run "cpack -G DragNDrop CPackConfig.cmake" on Mac OS X
# where CPackConfig.cmake is created by including CPack
# And then there's ways to customize this as well
set(CPACK_BINARY_DRAGNDROP ON)
INCLUDE(CPack)
#
# CUSTOM TARGETS
#
ADD_CUSTOM_TARGET(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/cmake/uninstall.cmake.in" "${CMAKE_BINARY_DIR}/uninstall.cmake" IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/uninstall.cmake")