sclang: array primitives - respect mutability when changing object.
[supercollider.git] / lang / CMakeLists.txt
blobb9ec12e599dd8688a44f4728a4f79fa2df752eb6
1 include_directories(${CMAKE_SOURCE_DIR}/include/common
2                     ${CMAKE_SOURCE_DIR}/include/lang
3                     ${CMAKE_SOURCE_DIR}/include/plugin_interface
4                     ${CMAKE_SOURCE_DIR}/include/server
5                     ${CMAKE_SOURCE_DIR}/common
7                     ${CMAKE_SOURCE_DIR}/external_libraries/boost-lockfree
8                     ${CMAKE_SOURCE_DIR}/external_libraries/threadpool
9                     ${CMAKE_SOURCE_DIR}/external_libraries/yaml-cpp-0.3.0/include
10                     ${CMAKE_SOURCE_DIR}/external_libraries/TLSF-2.4.6/src
11                     LangSource/Bison)
13 if (Boost_FOUND)
14     include_directories(${Boost_INCLUDE_DIRS})
15 else()
16     include_directories(${CMAKE_SOURCE_DIR}/external_libraries/boost)
17 endif()
19 if(APPLE)
20         include_directories("LangPrimSource/${HID_UTIL_DIR}")
21 elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
22         find_package(ALSA)
23 elseif(WIN32)
24         find_package(Portmidi)
25 endif()
27 find_package(Readline 5.0)
29 find_package(Sndfile)
31 set(sclang_sources
32         LangPrimSource/SC_Wii.cpp
33         LangPrimSource/PyrSignalPrim.cpp
34         LangPrimSource/PyrSched.cpp
35         LangPrimSource/PyrPrimitive.cpp
36         LangPrimSource/PyrMathPrim.cpp
37         LangPrimSource/SC_ComPort.cpp
38         LangPrimSource/OSCData.cpp
39         LangPrimSource/PyrArchiver.cpp
40         LangPrimSource/PyrArrayPrimitives.cpp
41         LangPrimSource/PyrBitPrim.cpp
42         LangPrimSource/PyrCharPrim.cpp
43         LangPrimSource/PyrFilePrim.cpp
44         LangPrimSource/PyrListPrim.cpp
45         LangPrimSource/PyrPlatformPrim.cpp
46         LangPrimSource/PyrStringPrim.cpp
47         LangPrimSource/PyrSymbolPrim.cpp
48         LangPrimSource/PyrUnixPrim.cpp
49         LangSource/AdvancingAllocPool.cpp
50         LangSource/ByteCodeArray.cpp
51         LangSource/DumpParseNode.cpp
52         LangSource/GC.cpp
53         LangSource/InitAlloc.cpp
54         LangSource/PyrInterpreter3.cpp
55         LangSource/PyrLexer.cpp
56         LangSource/PyrMathOps.cpp
57         LangSource/PyrMathSupport.cpp
58         LangSource/PyrMessage.cpp
59         LangSource/PyrObject.cpp
60         LangSource/PyrParseNode.cpp
61         LangSource/PyrSignal.cpp
62         LangSource/PyrSymbolTable.cpp
63         LangSource/SC_LanguageClient.cpp
64         LangSource/SC_LibraryConfig.cpp
65         LangSource/SC_TerminalClient.cpp
66         LangSource/Samp.cpp
67         LangSource/SimpleStack.cpp
68         LangSource/VMGlobals.cpp
69         LangSource/dumpByteCodes.cpp
71         ${CMAKE_SOURCE_DIR}/common/fftlib.c
72         ${CMAKE_SOURCE_DIR}/common/SC_AllocPool.cpp
73         ${CMAKE_SOURCE_DIR}/common/SC_DirUtils.cpp
74         ${CMAKE_SOURCE_DIR}/common/SC_Reply.cpp
75         ${CMAKE_SOURCE_DIR}/common/SC_Sem.cpp
76         ${CMAKE_SOURCE_DIR}/common/SC_StandAloneInfo_Darwin.cpp
77         ${CMAKE_SOURCE_DIR}/common/SC_StringBuffer.cpp
78         ${CMAKE_SOURCE_DIR}/common/SC_StringParser.cpp
79         ${CMAKE_SOURCE_DIR}/common/SC_TextUtils.cpp
81         ${CMAKE_SOURCE_DIR}/common/scsynthsend.cpp
82         ${CMAKE_SOURCE_DIR}/common/sc_popen.cpp
85 if (NOT Boost_FOUND)
86         file(GLOB boost_system_sources ../external_libraries/boost/libs/system/src/*cpp)
87         file(GLOB boost_fs_sources ../external_libraries/boost/libs/filesystem/src/*cpp)
88         file(GLOB boost_regex_sources ../external_libraries/boost/libs/regex/src/*cpp)
89         list(APPEND sclang_sources ${boost_fs_sources} ${boost_system_sources} ${boost_regex_sources})
90 endif()
92 file(GLOB_RECURSE headers ../include/*.h* )
93 file(GLOB_RECURSE external_headers ../external_libraries/*.h* )
94 list(APPEND sclang_sources ${headers} ${external_headers}) # make qt creator happy
96 if(NOT WIN32)
97         list(APPEND sclang_sources LangPrimSource/PyrSerialPrim.cpp)
98 endif()
100 if(WIN32)
101         list(APPEND sclang_sources ${CMAKE_SOURCE_DIR}/common/SC_Win32Utils.cpp)
102 endif()
104 if(WIN32)
105         include_directories(../platform/windows/compat_stuff)
106         list(APPEND sclang_sources ../platform/windows/compat_stuff/getopt.c)
107 endif()
109 set(sclang_parser_source LangSource/Bison/lang11d_tab.cpp)
111 add_definitions(-DYYSTACK_USE_ALLOCA)
113 if(UNIX)
114         if(APPLE)
115                 list(APPEND sclang_sources
116                         LangPrimSource/WiiMote_OSX/wiiremote.c
117                         LangPrimSource/SC_HID.cpp
118                         LangPrimSource/${HID_UTIL_DIR}/HID_Utilities.c
119                         LangPrimSource/${HID_UTIL_DIR}/HID_Name_Lookup.c
120                         LangPrimSource/${HID_UTIL_DIR}/HID_Queue_Utilities.c
121                         LangPrimSource/${HID_UTIL_DIR}/HID_Error_Handler.c
122                         LangPrimSource/SC_CoreMIDI.cpp
123                         LangPrimSource/SC_CoreAudioPrim.cpp
124                         LangPrimSource/SC_Speech.M
125                         )
126                 add_definitions(-DHAVE_SPEECH)
127                 if (CMAKE_COMPILER_IS_GNUCXX)
128                         set_source_files_properties(LangPrimSource/SC_Speech.M
129                                                                                 PROPERTIES COMPILE_FLAGS "-x objective-c++ -fobjc-exceptions")
130                 endif()
131                 if(NOT (HID_UTIL_DIR MATCHES "HID_Utilities_10_4"))
132                         list(APPEND sclang_sources
133                                 LangPrimSource/${HID_UTIL_DIR}/IOHIDElement_.c
134                                 LangPrimSource/${HID_UTIL_DIR}/IOHIDDevice_.c
135                         )
136                 endif()
137         else(APPLE)
138                 if(ALSA_FOUND)
139                         list(APPEND sclang_sources LangPrimSource/SC_AlsaMIDI.cpp)
140                 endif()
141                 list(APPEND sclang_sources LangPrimSource/SC_LID.cpp)
142                 add_definitions(-DHAVE_LID)
143         endif(APPLE)
144 else(UNIX)
145 endif(UNIX)
147 if(WIN32)
148         include_directories (../platform/windows/compat_stuff)
149         list(APPEND sclang_sources ../platform/windows/compat_stuff/getopt.c)
150         if(PORTMIDI_FOUND)
151                 include_directories (${PORTMIDI_INCLUDE_DIRS})
152                 add_definitions(-DHAVE_PORTMIDI)
153                 list(APPEND sclang_sources LangPrimSource/SC_PortMidi.cpp)
154         endif()
155 endif()
157 if (SC_WII OR APPLE)
158         if(CMAKE_SYSTEM_NAME MATCHES "Linux")
159                 find_package(CWiid)
160                 find_package(Bluetooth)
162                 if (BLUETOOTH_FOUND AND CWIID_FOUND)
163                         add_definitions(-DHAVE_WII)
164                         include_directories(${CWIID_INCLUDE_DIRS} ${BLUETOOTH_INCLUDE_DIRS})
165                         message(STATUS "Compiling with WiiMote support")
166                 else()
167                         message(SEND_ERROR "Cannot find libcwiid or libbluetooth.\n (If Wii support is not required, then set SC_WII=no)")
168                 endif()
169         elseif(APPLE)
170                 add_definitions(-DHAVE_WII)
171                 list(APPEND sclang_sources LangPrimSource/WiiMote_OSX/wiiremote.c)
172                 include_directories(LangPrimSource/WiiMote_OSX)
173         endif()
174 endif()
176 include(../SCDoc/CMakeLists.txt)
177 list(APPEND sclang_sources ${SCDOC_SRCS})
179 if(SC_IDE)
180         add_definitions(-DSC_IDE)
181         list(APPEND sclang_sources ../editors/sc-ide/primitives/sc_ipc_client.cpp)
182 endif()
184 if(SC_QT)
185         set(QT_COLLIDER_LANG_CLIENT ON)
186         include(../QtCollider/CMakeLists.txt)
187         list(APPEND sclang_sources ${QT_COLLIDER_SRCS})
188 endif()
190 if(0 AND FINAL_BUILD) # sclang final-builds are broken
191         CREATE_FINAL_FILE(libsclang_final.cpp ${sclang_sources})
192         add_library(libsclang STATIC libsclang_final.cpp ${sclang_parser_source})
193 else()
194         add_library(libsclang STATIC ${sclang_sources} ${sclang_parser_source})
195 endif()
197 set_property(TARGET libsclang
198         APPEND
199         PROPERTY COMPILE_DEFINITIONS BUILDING_SUPERCOLLIDER)
201 if (SC_WII OR APPLE)
202         if (BLUETOOTH_FOUND AND CWIID_FOUND)
203                 target_link_libraries(libsclang ${BLUETOOTH_LIBRARIES} ${CWIID_LIBRARIES})
204         elseif(APPLE)
205                 target_link_libraries(libsclang "-framework IOBluetooth")
206         endif()
207 endif()
209 if (Boost_FOUND)
210         target_link_libraries(libsclang ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
211 endif()
213 if (SCLANG_SERVER)
214         target_link_libraries(libsclang libscsynth)
215 else()
216         set_property(TARGET libsclang
217                 APPEND
218                 PROPERTY COMPILE_DEFINITIONS NO_INTERNAL_SERVER
219                 )
220 endif()
223 set_property(TARGET libsclang
224         PROPERTY OUTPUT_NAME sclang)
227 ## external libraries
228 if(READLINE_FOUND)
229         message(STATUS "Compiling with Readline support")
230         set_property(TARGET libsclang
231                 APPEND
232                 PROPERTY COMPILE_DEFINITIONS HAVE_READLINE)
233         include_directories(${READLINE_INCLUDE_DIR})
234         target_link_libraries(libsclang ${READLINE_LIBRARY})
235 endif(READLINE_FOUND)
237 if (APPLE)
238         target_link_libraries(libsclang "-framework Carbon")
239         target_link_libraries(libsclang "-framework CoreAudio")
240         target_link_libraries(libsclang "-framework CoreMIDI")
241         target_link_libraries(libsclang "-framework IOKit")
242         target_link_libraries(libsclang "-framework CoreServices")
243 endif()
245 if(ALSA_FOUND)
246         message(STATUS "Compiling with ALSA midi support")
247         set_property(TARGET libsclang
248                 APPEND
249                 PROPERTY COMPILE_DEFINITIONS HAVE_ALSA=1)
250         target_link_libraries(libsclang ${ALSA_LIBRARY})
251 endif(ALSA_FOUND)
253 if(SNDFILE_FOUND)
254         include_directories(${SNDFILE_INCLUDE_DIR})
255         target_link_libraries(libsclang ${SNDFILE_LIBRARIES})
256 elseif(NOT NO_LIBSNDFILE)
257         message(SEND_ERROR "Cannot find libsndfile")
258 endif(SNDFILE_FOUND)
260 if (FFTW3F_FOUND)
261         include_directories (${FFTW3F_INCLUDE_DIR})
262         target_link_libraries(libsclang ${FFTW3F_LIBRARY})
263 endif()
265 if (WIN32)
266         target_link_libraries(libsclang wsock32 ws2_32)
267         if(PORTMIDI_FOUND)
268                 target_link_libraries(libsclang ${PORTMIDI_LIBRARIES})
269         endif()
270 endif()
272 if (GC_SANITYCHECK)
273         add_definitions(-DGC_SANITYCHECK)
274 endif()
276 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
277         target_link_libraries(libsclang rt)
278 endif()
280 target_link_libraries(libsclang ${PTHREADS_LIBRARY} yaml)
282 if(SC_QT)
283         target_link_libraries(libsclang ${QT_COLLIDER_LIBS})
284 endif()
286 add_executable(sclang LangSource/cmdLineFuncs.cpp)
288 if (Boost_FOUND)
289         target_link_libraries(sclang libsclang ${Boost_THREAD_LIBRARY})
290 else()
291         target_link_libraries(sclang libsclang boost_thread)
292 endif()
294 set_property(TARGET sclang
295         APPEND
296         PROPERTY COMPILE_DEFINITIONS USE_SC_TERMINAL_CLIENT)
298 if(LTO)
299         set_property(TARGET sclang libsclang
300                                         APPEND PROPERTY COMPILE_FLAGS "-flto -flto-report")
302         set_property(TARGET sclang libsclang
303                                         APPEND PROPERTY LINK_FLAGS "-flto -flto-report -fwhole-program")
304 endif()
306 if(APPLE)
307         # determines the app name and app install location (scappbundlename, scappdir):
308         include (${CMAKE_SOURCE_DIR}/cmake_modules/MacAppFolder.cmake)
310         install(TARGETS sclang
311                         DESTINATION "${scappauxresourcesdir}"
312                         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
313 elseif(WIN32)
314         install(TARGETS sclang
315                         DESTINATION "SuperCollider"
316                         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
317 else()
318         install(TARGETS sclang
319                         RUNTIME DESTINATION "bin"
320                         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
321 endif()