forked from faudio/faudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
332 lines (273 loc) · 10.4 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
##
## CMake build for FA
##
## This script is slighly unusual, in that it requires components_resolve to be called once before
## building anything. Follow the instructions in README and all we be well.
##
cmake_minimum_required(VERSION 2.8.8)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
## ----------------------------------------------------------------------
## Basic definitions
project(FA C CXX)
set(VERSION_PRE "")
set(VERSION_X 2)
set(VERSION_Y 3)
set(VERSION_Z 0)
set(VERSION_SUFF "")
set(VERSION "${VERSION_PRE}${VERSION_X}.${VERSION_Y}.${VERSION_Z}${VERSION_SUFF}")
if(APPLE)
set(NOT_APPLE False)
else()
set(NOT_APPLE True)
endif()
if(WIN32) # TODO better check
set(MSYS True)
set(NOT_MSYS False)
else()
set(MSYS False)
set(NOT_MSYS True)
endif()
## ----------------------------------------------------------------------
## Build options
#
# This should hold
# CMAKE_OSX_DEPLOYMENT_TARGET
# <= CMAKE_OSX_SYSROOT
# <= (build machine OS X version)
#
# CMAKE_OSX_DEPLOYMENT_TARGET is minimum supported version (i.e. 10.5)
# CMAKE_OSX_SYSROOT is path to SDK of maximum supported version
#
option(ENABLE_REALTIME_AUDIO "Enable real-time audio" True)
option(ENABLE_REALTIME_MIDI "Enable real-time midi" True)
option(ENABLE_NONREALTIME_AUDIO "Enable non-real-time audio" True)
option(ENABLE_FLUIDSYNTH "Enable the Fluidsynth processor" ${NOT_APPLE})
option(ENABLE_AUDIO_UNIT "Enable AudioUnit processors" ${APPLE})
option(ENABLE_VST "Enable VST processors" True)
option(BUILD_FRAMEWORK "Build an OS X framework" ${APPLE})
option(BUILD_SHARED "Build a shared library" ${NOT_APPLE})
option(BUILD_TESTS "Build unit tests" True)
option(PROFILING "Compile with profiler flags -pg set" False)
option(BUILD_COMPONENTS "Build dependent components locally" True)
option(SHOW_COMPONENT_OUTPUT "Show output while building components" True)
## ----------------------------------------------------------------------
## Misc setup
include(Profiling)
include(FixOSXLionPaths)
#find_package(Dist)
## ----------------------------------------------------------------------
## Sanity checks
if(APPLE)
# string(COMPARE NOTEQUAL "${CMAKE_OSX_ARCHITECTURES}" "i386" ARCH_NOT_32_BIT)
# if(ARCH_NOT_32_BIT)
# message(FATAL_ERROR
# "\nThe Audio Engine does not support 64-bit mode yet."
# "\nTry -DCMAKE_OSX_ARCHITECTURES=i386.")
# endif()
string(COMPARE EQUAL "${CMAKE_OSX_DEPLOYMENT_TARGET}" "" NO_DEP_TARGET)
if(NO_DEP_TARGET)
message(FATAL_ERROR
"\nNo OS X deployment target set."
"\nTry -DCMAKE_OSX_DEPLOYMENT_TARGET=10.5.")
endif()
endif()
if(MSYS)
string(COMPARE NOTEQUAL "${CMAKE_GENERATOR}" "MSYS Makefiles" GENERATOR_NOT_MSYS)
if(GENERATOR_NOT_MSYS)
message(FATAL_ERROR
"\nMust use MSYS Makefiles generator."
"\nTry -G 'MSYS Makefiles'.")
endif()
endif()
## ----------------------------------------------------------------------
## Component manager
#
# These steps sets up the component manager and adds the components_resolve target
#
# Usually there is no need to use this explicitly, as the boot script calls
# "make components_resolve" and it only needs to be called once. Note that components_resolve
# calls cmake again to proceed below the guard below.
#
if(BUILD_COMPONENTS)
list(APPEND COMPONENT_DEFINES
"-DAUDIO_ENGINE_BUILD_COMPONENTS=True")
endif()
if(SHOW_COMPONENT_OUTPUT)
list(APPEND COMPONENT_DEFINES
"-DAUDIO_ENGINE_SHOW_COMPONENT_OUTPUT=True")
endif()
if(DIST_EXECUTABLE)
list(APPEND COMPONENT_DEFINES
"-DDIST_EXECUTABLE=${DIST_EXECUTABLE}")
endif()
list(APPEND COMPONENT_DEFINES
"-DAUDIO_ENGINE_WORKING_DIR=${CMAKE_SOURCE_DIR}")
include(AudioEngine)
add_custom_target(components_print
COMMAND cmake
${COMPONENT_DEFINES}
-P "${CMAKE_SOURCE_DIR}/cmake/scripts/components_print.cmake")
add_custom_target(components_resolve
COMMAND cmake
${COMPONENT_DEFINES}
-P "${CMAKE_SOURCE_DIR}/cmake/scripts/components_resolve.cmake")
add_custom_target(components_clean
COMMAND cmake
${COMPONENT_DEFINES}
-P "${CMAKE_SOURCE_DIR}/cmake/scripts/components_clean.cmake")
add_custom_target(format
COMMAND sh "${CMAKE_SOURCE_DIR}/cmake/scripts/astyle.sh" scl
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
add_custom_target(run_scorecleaner
COMMAND sh "${CMAKE_SOURCE_DIR}/cmake/scripts/run_scorecleaner.sh"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
## ----------------------------------------------------------------------
## Add main targets
# We only proceed here if the component mangager has been run, as per above.
if (COMPONENTS_RESOLVED)
## ----------------------------------------------------------------------
# Find packages
find_package(Pthreads)
find_package(Iconv)
find_package(Portaudio)
find_package(Portmidi)
find_package(Sndfile)
if(ENABLE_FLUIDSYNTH)
find_package(Fluidsynth)
find_package(Glib)
endif()
## ----------------------------------------------------------------------
## Add compiler defs
add_definitions(${PTHREAD_DEFINITIONS})
add_definitions(${ICONV_DEFINITIONS})
if (APPLE)
# message("Sysroot is " ${CMAKE_OSX_SYSROOT})
# message("Target is "${CMAKE_OSX_DEPLOYMENT_TARGET})
set(CMAKE_C_COMPILER "/usr/bin/clang")
add_definitions(-std=c99)
add_definitions(-fcolor-diagnostics)
if(${CMAKE_BUILD_TYPE} STREQUAL Debug)
add_definitions(-Werror)
endif()
add_definitions(-Wno-error=logical-op-parentheses)
add_definitions(
-Wall
)
# -Wmissing-noreturn
# -Wswitch-default
# -Wswitch-enum
# -Wreturn-type
# -Wdeprecated
# -Wswitch
add_definitions("-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
add_definitions("-isysroot ${CMAKE_OSX_SYSROOT}")
add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=1)
# add_definitions("-v")
set(STD_LINK_FLAGS "${STD_LINK_FLAGS} -mmin-macosx-version=${CMAKE_OSX_DEPLOYMENT_TARGET}")
set(STD_LINK_FLAGS "${STD_LINK_FLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
set(STD_LINK_FLAGS "${STD_LINK_FLAGS} -isysroot ${CMAKE_OSX_SYSROOT}")
# set(STD_LINK_FLAGS "${STD_LINK_FLAGS} -v")
set(STD_LINK_FLAGS "${STD_LINK_FLAGS} -ObjC -all_load")
endif()
if (MSYS)
add_definitions(-std=c99)
add_definitions(-DFLUIDSYNTH_NOT_A_DLL=1)
endif()
## ----------------------------------------------------------------------
## Add include directories
include_directories("include")
include_directories("${CMAKE_BINARY_DIR}/include") # for the conf file
# include_directories(${CMAKE_SOURCE_DIR}) # for scl and scl-c
include_directories(${PTHREADS_INCLUDE_DIRS})
include_directories(${ICONV_INCLUDE_DIRS})
include_directories(${PORTAUDIO_INCLUDE_DIRS})
include_directories(${PORTMIDI_INCLUDE_DIRS})
include_directories(${SNDFILE_INCLUDE_DIRS})
include_directories(${GTEST_INCLUDE_DIRS})
include_directories(${ICU_INCLUDE_DIRS})
include_directories(${FLUIDSYNTH_INCLUDE_DIRS}) # May be empty
include_directories(${GLIB_INCLUDE_DIRS}) # May be empty
include_directories("external/vst")
## ----------------------------------------------------------------------
## Add libraries
set(CMAKE_LIBRARY_PATH
${PTHREADS_LIBRARIES}
${ICONV_LIBRARIES}
${PORTAUDIO_LIBRARIES}
${PORTMIDI_LIBRARIES}
${SNDFILE_LIBRARIES}
${GTEST_LIBRARIES}
${ICU_LIBRARIES}
${FLUIDSYNTH_LIBRARIES} # May be empty
${GLIB_LIBRARIES} # May be empty
"/c/mingw/lib"
"/c/mingw"
)
list(APPEND EXTS ${PTHREADS_LIBRARIES})
list(APPEND EXTS ${ICONV_LIBRARIES})
list(APPEND EXTS ${PORTAUDIO_LIBRARIES})
list(APPEND EXTS ${PORTMIDI_LIBRARIES})
list(APPEND EXTS ${SNDFILE_LIBRARIES})
list(APPEND EXTS ${GTEST_LIBRARIES})
list(APPEND EXTS ${FLUIDSYNTH_LIBRARIES}) # May be empty
list(APPEND EXTS ${GLIB_LIBRARIES}) # May be empty
if (MSYS)
find_library (MINGW32 NAMES mingw32 PATH_SUFFIXES lib PATHS "C:/MinGW")
find_library (OLE32 NAMES ole32 PATH_SUFFIXES lib PATHS "C:/MinGW")
#find_library (WINMM NAMES winmm PATH_SUFFIXES lib PATHS "C:/MinGW")
find_library (WINSOCK NAMES ws2_32 PATH_SUFFIXES lib PATHS "C:/MinGW")
find_library(LSTDCXX NAMES libstdc++-6 PATH_SUFFIXES lib PATHS "C:/MinGW")
find_library(LIBGCC NAMES libgcc_s_dw2-1 PATH_SUFFIXES lib PATHS "C:/MinGW")
find_library(WINMM winmm)
set(WINMM winmm.lib)
set(CMAKE_C_STANDARD_LIBRARIES "-lws2_32 ${CMAKE_C_STANDARD_LIBRARIES}")
list(APPEND EXTS ${WINSOCK})
list(APPEND EXTS ${WINMM})
list(APPEND EXTS ${OLE32})
list(APPEND EXTS ${MINGW32})
list(APPEND EXTS ${LSTDCXX})
list(APPEND EXTS ${LIBGCC})
endif()
if(APPLE)
find_library(COCOA Cocoa)
find_library(COREAUDIO CoreAudio)
find_library(COREMIDI CoreMidi)
find_library(AUDIOUNIT AudioUnit)
find_library(AUDIOTOOLBOX AudioToolbox)
find_library(QUARTZCORE QuartzCore)
list(APPEND EXTS ${COCOA})
list(APPEND EXTS ${COREAUDIO})
list(APPEND EXTS ${COREMIDI})
list(APPEND EXTS ${AUDIOUNIT})
list(APPEND EXTS ${AUDIOTOOLBOX})
list(APPEND EXTS ${QUARTZCORE})
endif ()
#if(MSYS)
#find_library(WINMM winmm)
#set(WINMM winmm.lib)
#list(APPEND EXTS ${WINMM})
#endif()
## ----------------------------------------------------------------------
## Add targets for source-only libraries
add_subdirectory(external)
## ----------------------------------------------------------------------
## Config file
set(FA_VERSION "{ \"${VERSION_PRE}\", ${VERSION_X}, ${VERSION_Y}, ${VERSION_Z}, \"${VERSION_SUFF}\" }")
set(FA_REALTIME_MIDI ENABLE_REALTIME_MIDI)
set(FA_REALTIME_AUDIO ENABLE_REALTIME_AUDIO)
set(FA_NONREALTIME_AUDIO ENABLE_NONREALTIME_AUDIO)
set(FA_HAS_FLUIDSYNTH ENABLE_FLUIDSYNTH)
set(FA_HAS_AUDIO_UNIT ENABLE_AUDIO_UNIT)
set(FA_HAS_VST ENABLE_VST)
configure_file(
${CMAKE_SOURCE_DIR}/include/config.h.in
${CMAKE_BINARY_DIR}/include/config.h
)
## ----------------------------------------------------------------------
## Add main targets
add_subdirectory(shared)
add_subdirectory(test)
add_subdirectory(tools)
endif(COMPONENTS_RESOLVED)