-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
261 lines (224 loc) · 10.1 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
cmake_minimum_required(VERSION 2.8.11) # needed for CFBundle building
project(SuperColliderAU)
if(NOT APPLE)
message(SEND_ERROR "ERROR: only APPLE platform is supported")
endif()
#if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
# set(CMAKE_COMPILER_IS_CLANG 1)
#else()
# message(SEND_ERROR "Only CLANG compiler supported")
#endif()
message("Building SuperColliderAU")
option(SSE "Compile with support for SSE instructions." ON)
option(SSE2 "Compile with support for SSE2 instructions." ON)
set(SC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/supercollider)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
set(PLUGINS_DIR ${SC_DIR}/build/server/plugins/${CMAKE_BUILD_TYPE}/)
if (NOT EXISTS ${PLUGINS_DIR})
message(SEND_ERROR "Pluigns directory not found: ${PLUGINS_DIR}")
endif()
file(GLOB PLUGINS ${SC_DIR}/build/server/plugins/${CMAKE_BUILD_TYPE}/*.scx)
set(CMAKE_MODULE_PATH ${SC_DIR}/cmake_modules)
include (${SC_DIR}/cmake_modules/FinalFile.cmake)
include (${SC_DIR}/cmake_modules/FindPthreads.cmake)
include (${SC_DIR}/cmake_modules/FindSndfile.cmake)
find_package(Pthreads)
find_package(Sndfile)
if (NOT PTHREADS_FOUND)
message(SEND_ERROR "cannot find libpthreads")
endif()
if (NOT SNDFILE_FOUND)
message(SEND_ERROR "cannot find libsndfile")
endif()
add_subdirectory(${SC_DIR}/external_libraries ${CMAKE_BINARY_DIR}/external_libraries)
if (SSE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -mfpmath=sse")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -mfpmath=sse")
endif()
if (SSE41)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
endif()
if (SSE42)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
endif()
if (NATIVE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -stdlib=libc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
set(scau_bundle "SuperColliderAU")
set(SNDFILE_INCLUDE_DIR ${SC_DIR}/external_libraries/libsndfile)
set(BOOST_INCLUDE_DIR ${SC_DIR}/external_libraries/boost)
set(TLSF_INCLUDE_DIR ${SC_DIR}/external_libraries/TLSF-2.4.6/src)
include_directories(${SC_DIR}/external_libraries
${BOOST_INCLUDE_DIR}
${SNDFILE_INCLUDE_DIR}
${PTHREADS_INCLUDE_DIR}
${TLSF_INCLUDE_DIR}
${SC_DIR}/external_libraries/boost_sync/include
${SC_DIR}/external_libraries/boost_lockfree
${SC_DIR}/external_libraries/nova-simd
${SC_DIR}/external_libraries/nova-tt
)
set_property(DIRECTORY
APPEND
PROPERTY COMPILE_DEFINITIONS SC_MEMORY_ALIGNMENT=32)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/Source
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/OtherBases
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/Utility
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/PublicUtility
${SC_DIR}/include/common
${SC_DIR}/common
${SC_DIR}/build/common
${SC_DIR}/include/server/
${SC_DIR}/include/plugin_interface
${SC_DIR}/server/scsynth/
)
add_definitions("-DSC_AUDIO_API=SC_AUDIO_API_AUDIOUNITS" ${AUDIOUNITS_DEFINITIONS})
add_definitions("-DSC_DARWIN")
add_definitions("-D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0")
add_definitions(-w)# TODO: fix deprecation warnings
if (NOT Boost_FOUND)
file(GLOB boost_system_sources ${SC_DIR}/external_libraries/boost/libs/system/src/*cpp)
file(GLOB boost_filesystem_sources ${SC_DIR}/external_libraries/boost/libs/filesystem/src/*cpp)
endif()
set(scau_sources
${SC_DIR}/common/fftlib.c
${SC_DIR}/common/SC_fftlib.cpp
${SC_DIR}/common/SC_AllocPool.cpp
${SC_DIR}/common/SC_Errors.cpp
${SC_DIR}/common/Samp.cpp
${SC_DIR}/common/SC_StringBuffer.cpp
${SC_DIR}/common/SC_StringParser.cpp
${SC_DIR}/common/sc_popen.cpp
${SC_DIR}/common/strtod.c
${SC_DIR}/common/SC_Reply.cpp
${SC_DIR}/common/SC_Filesystem_macos.cpp
${SC_DIR}/common/SC_Filesystem_iphone.cpp
${SC_DIR}/external_libraries/TLSF-2.4.6/src/tlsf.c
${SC_DIR}/server/scsynth/SC_AU.cpp
${SC_DIR}/server/scsynth/SC_BufGen.cpp
${SC_DIR}/server/scsynth/SC_ComPort.cpp
${SC_DIR}/server/scsynth/SC_CoreAudio.cpp
${SC_DIR}/server/scsynth/SC_Graph.cpp
${SC_DIR}/server/scsynth/SC_GraphDef.cpp
${SC_DIR}/server/scsynth/SC_Group.cpp
${SC_DIR}/server/scsynth/SC_Lib_Cintf.cpp
${SC_DIR}/server/scsynth/SC_Lib.cpp
${SC_DIR}/server/scsynth/SC_MiscCmds.cpp
${SC_DIR}/server/scsynth/SC_Node.cpp
${SC_DIR}/server/scsynth/SC_Rate.cpp
${SC_DIR}/server/scsynth/SC_SequencedCommand.cpp
${SC_DIR}/server/scsynth/SC_Str4.cpp
${SC_DIR}/server/scsynth/SC_Unit.cpp
${SC_DIR}/server/scsynth/SC_UnitDef.cpp
${SC_DIR}/server/scsynth/Rendezvous.cpp
${SC_DIR}/server/scsynth/SC_World.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Source/SuperColliderAU.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/OtherBases/AUMIDIBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/OtherBases/AUMIDIEffectBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/Utility/AUBuffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUDispatch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/OtherBases/AUEffectBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUInputElement.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUPlugInDispatch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUOutputElement.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUScopeElement.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAAudioChannelLayout.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAStreamBasicDescription.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAVectorUnit.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/ComponentBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUPlugInDispatch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Source/UDPPort.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Source/ControlSpecs.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Source/OSCMessages.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Source/Resources.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Source/SCProcess.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Source/SuperColliderAU.r
${CMAKE_CURRENT_SOURCE_DIR}/Resources/Info.plist
${CMAKE_CURRENT_SOURCE_DIR}/Resources/English.lproj/InfoPlist.strings
${CMAKE_CURRENT_SOURCE_DIR}/Resources/serverConfig.plist
${CMAKE_CURRENT_SOURCE_DIR}/Resources/SuperColliderAU.rsrc
${boost_system_sources}
${boost_filesystem_sources}
${PLUGINS}
)
if(APPLE)
set_property(SOURCE ${SC_DIR}/common/SC_Filesystem_macos.cpp PROPERTY COMPILE_FLAGS -xobjective-c++)
list(APPEND scau_sources
${SC_DIR}/common/SC_Apple.mm
)
set_source_files_properties( ${SC_DIR}/common/SC_Apple.mm
PROPERTIES COMPILE_FLAGS "-x objective-c++ -fobjc-exceptions"
)
endif()
add_library(${scau_bundle} MODULE ${scau_sources})
find_program(REZ Rez NO_DEFAULT_PATHS)
execute_process (
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND xcrun --sdk macosx --show-sdk-path
OUTPUT_VARIABLE SDKROOT
)
execute_process(COMMAND
${REZ}
-isysroot ${SDKROOT}
${CMAKE_CURRENT_SOURCE_DIR}/Source/SuperColliderAU.r
-d SystemSevenOrLater=1 -useDF -script Roman -arch x86_64
-o ${CMAKE_CURRENT_SOURCE_DIR}/Resources/SuperColliderAU.rsrc
-I /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Versions/A/Headers
-I ${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/OtherBases/
-I ${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/
-I ${CMAKE_CURRENT_SOURCE_DIR}/CoreAudioUtilityClasses
)
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/Resources/SuperColliderAU.rsrc
PROPERTIES GENERATED 1
)
set_target_properties(${scau_bundle} PROPERTIES
BUNDLE 1
BUNDLE_EXTENSION component
XCODE_ATTRIBUTE_WRAPPER_EXTENSION component
XCODE_ATTRIBUTE_MACH_O_TYPE mh_bundle
XCODE_ATTRIBUTE_INFOPLIST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Info.plist
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Info.plist
LINK_FLAGS "-Wl")
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/Resources/English.lproj/InfoPlist.strings
PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/English.lproj")
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/Resources/serverConfig.plist
${CMAKE_CURRENT_SOURCE_DIR}/Resources/SuperColliderAU.rsrc
PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set_source_files_properties(
${PLUGINS}
PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/plugins")
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/Resources/synthdefs/.
PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/synthdefs")
target_link_libraries(${scau_bundle} "-framework AudioUnit")
target_link_libraries(${scau_bundle} "-framework CoreAudio")
target_link_libraries(${scau_bundle} "-framework CoreMIDI")
target_link_libraries(${scau_bundle} "-framework CoreServices")
#target_link_libraries(${scau_bundle} "-framework vecLib")
target_link_libraries(${scau_bundle} "-framework Accelerate")
target_link_libraries(${scau_bundle} "-framework Foundation")
target_link_libraries(${scau_bundle} ${SNDFILE_LIBRARIES})
add_definitions("-DLIBSNDFILE_1018")
if (Boost_FOUND)
target_link_libraries(${scau_bundle} ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} )
else()
target_link_libraries(${scau_bundle} boost_system_lib boost_filesystem_lib)
endif()
target_link_libraries(${scau_bundle} ${PTHREADS_LIBRARY})