-
Notifications
You must be signed in to change notification settings - Fork 25
/
CMakeLists.txt
428 lines (390 loc) · 9.61 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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
cmake_minimum_required (VERSION 3.0)
project (cyclone C)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(BUILD_SINGLE_LIBRARY "Compile everything into one single library." OFF)
set(PD_INCLUDE_DIR "" CACHE PATH "Path to pure-data sources (this can be the pure-data/src folder in the sources of libpd)")
if (NOT PD_INCLUDE_DIR)
message(FATAL_ERROR "Please provide a path to the pure-data source files.")
endif()
set(PD_LIBRARY "" CACHE PATH "Path to pure-data / libpd library (pd.lib or libpd.lib)")
if (NOT PD_LIBRARY)
message(FATAL_ERROR "Please provide a path to the pure-data / libpd library.")
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/libs" CACHE PATH "Installation path" FORCE)
endif()
if (WIN32)
set(CMAKE_THREAD_LIBS_INIT CACHE PATH "Path to pthreads library")
set(PTHREADS_INCLUDE_DIR CACHE PATH "Path to the pthreads library header files")
# We need pthreads.
# Please provide the path to the pthreads library include path and
# the path to the pthread library by specifying the following arguments
# on the CMake command-line:
# -DCMAKE_THREAD_LIBS_INIT:PATH=<path to library, either MSVC (for example pthreadVC2.lib) or GNUC version>
# -DPTHREADS_INCLUDE_DIR:PATH=<path to the pthread header files>
if (NOT CMAKE_THREAD_LIBS_INIT OR NOT PTHREADS_INCLUDE_DIR)
message(FATAL_ERROR "Please provide a path to the pthreads library and its headers.")
endif()
set(CMAKE_THREAD_PREFER_PTHREAD ON)
endif()
if(WIN32)
# Use Windows APIs compatible with most versions
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINVER=0x502 -DWIN32 -D_WIN32")
endif()
if (MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_STRUCT_TIMESPEC")
add_definitions("/D_CRT_SECURE_NO_WARNINGS /wd4091 /wd4996")
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
# Select appropriate long int type on 64-bit Windows
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPD_LONGINTTYPE=\"long long\"")
endif()
else()
add_definitions(-DHAVE_UNISTD_H=1)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -ffast-math -funroll-loops -fomit-frame-pointer -O3")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -O0")
if(NOT APPLE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic")
endif()
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_MACOSX_RPATH ON)
foreach (_BUILD_TYPE RELEASE DEBUG)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${_BUILD_TYPE} ${CMAKE_INSTALL_PREFIX})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${_BUILD_TYPE} ${CMAKE_INSTALL_PREFIX})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${_BUILD_TYPE} ${CMAKE_INSTALL_PREFIX})
endforeach()
include_directories(${PD_INCLUDE_DIR})
include_directories(${PTHREADS_INCLUDE_DIR})
include_directories(shared)
find_package(Threads REQUIRED)
set(CONTROL_CLASSES
accum
acos
anal
asin
bangbang
borax
bucket
cartopol
counter
cosh
cycle
decide
decode
flush
forward
fromsymbol
funnel
gate
histo
listfunnel
linedrive
maximum
mean
midiflush
midiformat
midiparse
minimum
next
onebang
past
peak
poltocar
sinh
spell
split
spray
sprintf
sustain
switch
tanh
togedge
trough
universal
unjoin
uzi
xbendin
xbendin2
xbendout
xbendout2
xnotein
xnoteout
zl
# new ones in cyclone 0.3
acosh
asinh
atanh
atodb
dbtoa
join
# FIXME loadmess needs sys_noloadbang
pong
pak
rdiv
rminus
round
scale
#GUI
comment
# classes with dependencies
capture
mtr
coll
tosymbol
append
clip
prepend
thresh
substitute
speedlim
match
iter
buddy
bondo
pv
prob
active
mousefilter
mousestate
offer
funbuff
drunk
urn
table
seq
grab
)
if (MSVC)
# Remove controls that are not compatible with MSVC
list(REMOVE_ITEM CONTROL_CLASSES
funbuff # needs POSIX libgen.h
round # needs alloca
pong # needs alloca
)
endif(MSVC)
set(SIGNAL_CLASSES
acos
acosh
allpass
asin
asinh
atan
atan2
atanh
average
avg
change
click
clip
cosh
cosx
count
comb
curve
cycle
delta
deltaclip
edge
line
lores
maximum
minimum
mstosamps
onepole
overdrive
peakamp
phasewrap
pink
pong
pow
rampsmooth
rand
reson
sampstoms
sinh
sinx
slide
snapshot
spike
svf
tanh
tanx
teeth
train
trapezoid
triangle
zerox
# new in cyclone 0.3
atodb
cross
dbtoa
degrade
downsamp
equals
greaterthan
greaterthaneq
lessthan
lessthaneq
modulo
notequals
phaseshift
rdiv
rminus
round
scale
thresh
trunc
# classes with dependencies
frameaccum
framedelta
capture
cartopol
delay
plusequals
minmax
poltocar
matrix
sah
gate
selector
kink
vectral
bitand
bitnot
bitor
bitsafe
bitshift
bitxor
# GUI
scope
buffir
lookup
index
peek
poke
record
wave
play
)
add_library(cyclone_shared STATIC
shared/common/file.h
shared/common/file.c
shared/common/grow.h
shared/common/grow.c
shared/common/magicbit.h
shared/common/magicbit.c
shared/control/gui.h
shared/control/gui.c
shared/control/mifi.h
shared/control/mifi.c
shared/control/rand.h
shared/control/rand.c
shared/control/tree.h
shared/control/tree.c
shared/signal/cybuf.h
shared/signal/cybuf.c
)
link_libraries(${PD_LIBRARY})
link_libraries(${CMAKE_THREAD_LIBS_INIT})
link_libraries(cyclone_shared)
# Add main cyclone library
set(SETUP_DECLS "")
set(SETUP_CALLS "")
if(BUILD_SINGLE_LIBRARY)
string(APPEND SETUP_DECLS "// control classes\n\n")
string(APPEND SETUP_CALLS " // control classes\n\n")
foreach(NAME ${CONTROL_CLASSES})
string(APPEND SETUP_DECLS "void ${NAME}_setup();\n")
string(APPEND SETUP_CALLS " ${NAME}_setup();\n")
endforeach(NAME)
string(APPEND SETUP_DECLS "\n// signal classes\n\n")
string(APPEND SETUP_CALLS "\n // signal classes\n\n")
foreach(NAME ${SIGNAL_CLASSES})
string(APPEND SETUP_DECLS "void ${NAME}_tilde_setup();\n")
string(APPEND SETUP_CALLS " ${NAME}_tilde_setup();\n")
endforeach(NAME)
endif(BUILD_SINGLE_LIBRARY)
configure_file(cyclone_objects/binaries/single_lib.c.in
${CMAKE_CURRENT_BINARY_DIR}/cyclone_objects/binaries/single_lib.c)
add_library(cyclone cyclone_objects/binaries/cyclone_lib.c
${CMAKE_CURRENT_BINARY_DIR}/cyclone_objects/binaries/single_lib.c
)
# Add libraries for objects
if(BUILD_SHARED_LIBS AND NOT BUILD_SINGLE_LIBRARY)
set(LIB_BUILD_MODE SHARED)
else()
set(LIB_BUILD_MODE STATIC)
endif()
if(BUILD_SINGLE_LIBRARY)
add_definitions(-DCYCLONE_SINGLE_LIBRARY=1)
endif()
foreach(NAME ${CONTROL_CLASSES})
add_library(${NAME} ${LIB_BUILD_MODE} cyclone_objects/binaries/control/${NAME}.c)
endforeach(NAME)
foreach(NAME ${SIGNAL_CLASSES})
add_library(signal_${NAME} ${LIB_BUILD_MODE} cyclone_objects/binaries/audio/${NAME}.c)
set_target_properties(signal_${NAME} PROPERTIES OUTPUT_NAME ${NAME}~)
endforeach(NAME)
# Link objects to main library if building a single library
if(BUILD_SINGLE_LIBRARY)
foreach(NAME ${CONTROL_CLASSES})
target_link_libraries(cyclone ${NAME})
endforeach(NAME)
foreach(NAME ${SIGNAL_CLASSES})
target_link_libraries(cyclone signal_${NAME})
endforeach(NAME)
endif(BUILD_SINGLE_LIBRARY)
# Install
install(DIRECTORY
cyclone_objects/abstractions/
documentation/help_files/
documentation/extra_files/
DESTINATION .
FILES_MATCHING PATTERN "*.pd"
)
install(FILES
LICENSE.txt
README.pdf
DESTINATION .
)
if (MINGW)
# pthreadGC-3.dll is required for Windows installation. It can be found in
# the MinGW directory (usually C:\MinGW\bin) directory and should be
# copied to the current directory before installation or packaging.
install(FILES
maintenance/windows_dll/pthreadGC-3.dll
maintenance/windows_dll/libgcc_s_dw2-1.dll
DESTINATION .
)
endif(MINGW)
# Install upper case aliases on Linux
if(UNIX AND NOT APPLE)
if(NOT IS_ABSOLUTE ${CMAKE_INSTALL_PREFIX})
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_PREFIX}")
endif()
macro(create_symlinks old new)
if (NOT BUILD_SINGLE_LIBRARY)
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \
${CMAKE_INSTALL_PREFIX}/lib${old}${CMAKE_DEBUG_POSTFIX}.so \
${CMAKE_INSTALL_PREFIX}/lib${new}${CMAKE_DEBUG_POSTFIX}.so)")
endif()
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \
${CMAKE_INSTALL_PREFIX}/${old}-help.pd ${CMAKE_INSTALL_PREFIX}/${new}-help.pd)")
endmacro()
create_symlinks(append Append)
create_symlinks(bucket Bucket)
create_symlinks(clip Clip)
create_symlinks(decode Decode)
create_symlinks(histo Histo)
create_symlinks(mousestate MouseState)
create_symlinks(peak Peak)
create_symlinks(table Table)
create_symlinks(togedge TogEdge)
create_symlinks(trough Trough)
create_symlinks(uzi Uzi)
create_symlinks(clip~ Clip~)
create_symlinks(line~ Line~)
create_symlinks(scope~ Scope~)
create_symlinks(snapshot~ Snapshot~)
endif(UNIX AND NOT APPLE)