Change PG_03 discussion of rests to use Rest()
[supercollider.git] / lang / CMakeLists.txt
blobd67ea47105083be59c98aa9c5d7402dfcda07c97
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}/external_libraries/boost_lockfree
6                     ${CMAKE_SOURCE_DIR}/external_libraries/boost
7                     ${CMAKE_SOURCE_DIR}/external_libraries/threadpool
8                     ${CMAKE_SOURCE_DIR}/external_libraries/yaml-cpp-0.2.6/include
9                     ${CMAKE_SOURCE_DIR}/external_libraries/TLSF-2.4.6/src
10                     LangSource/Bison)
12 if(APPLE)
13         include_directories("LangPrimSource/${HID_UTIL_DIR}")
14 elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
15         find_package(ALSA)
16 endif()
18 if(APPLE)
19         # apple bundles an old nongpl readline so we say no even though it is usually detectable
20         set(READLINE_FOUND false)
21 elseif(WIN32)
22         set(READLINE_FOUND false)
23 else()
24         find_package(Readline)
25 endif()
26 find_package(Sndfile)
28 set(sclang_sources
29         LangPrimSource/SC_Wii.cpp
30         LangPrimSource/PyrSignalPrim.cpp
31         LangPrimSource/PyrSched.cpp
32         LangPrimSource/PyrPrimitive.cpp
33         LangPrimSource/PyrMathPrim.cpp
34         LangPrimSource/SC_ComPort.cpp
35         LangPrimSource/OSCData.cpp
36         LangPrimSource/PyrArchiver.cpp
37         LangPrimSource/PyrArrayPrimitives.cpp
38         LangPrimSource/PyrBitPrim.cpp
39         LangPrimSource/PyrCharPrim.cpp
40         LangPrimSource/PyrFilePrim.cpp
41         LangPrimSource/PyrListPrim.cpp
42         LangPrimSource/PyrPlatformPrim.cpp
43         LangPrimSource/PyrStringPrim.cpp
44         LangPrimSource/PyrSymbolPrim.cpp
45         LangPrimSource/PyrUnixPrim.cpp
46         LangSource/AdvancingAllocPool.cpp
47         LangSource/ByteCodeArray.cpp
48         LangSource/DumpParseNode.cpp
49         LangSource/GC.cpp
50         LangSource/InitAlloc.cpp
51         LangSource/PyrFileUtils.cpp
52         LangSource/PyrInterpreter3.cpp
53         LangSource/PyrLexer.cpp
54         LangSource/PyrMathOps.cpp
55         LangSource/PyrMathSupport.cpp
56         LangSource/PyrMessage.cpp
57         LangSource/PyrObject.cpp
58         LangSource/PyrParseNode.cpp
59         LangSource/PyrSignal.cpp
60         LangSource/PyrSymbolTable.cpp
61         LangSource/SC_LanguageClient.cpp
62         LangSource/SC_LibraryConfig.cpp
63         LangSource/SC_TerminalClient.cpp
64         LangSource/Samp.cpp
65         LangSource/SimpleStack.cpp
66         LangSource/VMGlobals.cpp
67         LangSource/dumpByteCodes.cpp
69         ${CMAKE_SOURCE_DIR}/common/fftlib.c
70         ${CMAKE_SOURCE_DIR}/common/SC_AllocPool.cpp
71         ${CMAKE_SOURCE_DIR}/common/SC_DirUtils.cpp
72         ${CMAKE_SOURCE_DIR}/common/SC_Sem.cpp
73         ${CMAKE_SOURCE_DIR}/common/SC_StandAloneInfo_Darwin.cpp
74         ${CMAKE_SOURCE_DIR}/common/SC_StringBuffer.cpp
75         ${CMAKE_SOURCE_DIR}/common/SC_StringParser.cpp
76         ${CMAKE_SOURCE_DIR}/common/scsynthsend.cpp
77         ${CMAKE_SOURCE_DIR}/common/sc_popen.cpp
80 file(GLOB boost_system_sources ../external_libraries/boost/libs/system/src/*cpp)
81 file(GLOB boost_fs_sources ../external_libraries/boost/libs/filesystem/v3/src/*cpp)
82 file(GLOB boost_regex_sources ../external_libraries/boost/libs/regex/src/*cpp)
83 list(APPEND sclang_sources ${boost_fs_sources} ${boost_system_sources} ${boost_regex_sources})
85 file(GLOB yaml_sources ../external_libraries/yaml-cpp-0.2.6/src/*cpp)
86 list(APPEND sclang_sources ${yaml_sources})
88 if(NOT WIN32)
89         list(APPEND sclang_sources LangPrimSource/PyrSerialPrim.cpp)
90 endif()
92 if(WIN32)
93         list(APPEND sclang_sources ${CMAKE_SOURCE_DIR}/common/SC_Win32Utils.cpp)
94 endif()
96 if(WIN32)
97         include_directories(../platform/windows/compat_stuff)
98         list(APPEND sclang_sources ../platform/windows/compat_stuff/getopt.c)
99 endif()
101 set(sclang_parser_source LangSource/Bison/lang11d_tab.cpp)
103 add_definitions(-DYYSTACK_USE_ALLOCA)
105 if(UNIX)
106         if(APPLE)
107                 list(APPEND sclang_sources
108                         LangPrimSource/WiiMote_OSX/wiiremote.c
109                         LangPrimSource/SC_HID.cpp
110                         LangPrimSource/${HID_UTIL_DIR}/HID_Utilities.c
111                         LangPrimSource/${HID_UTIL_DIR}/HID_Name_Lookup.c
112                         LangPrimSource/${HID_UTIL_DIR}/HID_Queue_Utilities.c
113                         LangPrimSource/${HID_UTIL_DIR}/HID_Error_Handler.c
114                         LangPrimSource/SC_CoreMIDI.cpp
115                         LangPrimSource/SC_CoreAudioPrim.cpp
116                         LangPrimSource/SC_Speech.M
117                         )
118                 add_definitions(-DHAVE_SPEECH)
119                 if (CMAKE_COMPILER_IS_GNUCXX)
120                         set_source_files_properties(LangPrimSource/SC_Speech.M
121                                                                                 PROPERTIES COMPILE_FLAGS "-x objective-c++ -fobjc-exceptions")
122                 endif()
123                 if(NOT (HID_UTIL_DIR MATCHES "HID_Utilities_10_4"))
124                         list(APPEND sclang_sources
125                                 LangPrimSource/${HID_UTIL_DIR}/IOHIDElement_.c
126                                 LangPrimSource/${HID_UTIL_DIR}/IOHIDDevice_.c
127                         )
128                 endif()
129         else(APPLE)
130                 if(ALSA_FOUND)
131                         list(APPEND sclang_sources LangPrimSource/SC_AlsaMIDI.cpp)
132                 endif()
133                 list(APPEND sclang_sources LangPrimSource/SC_LID.cpp)
134                 add_definitions(-DHAVE_LID)
135         endif(APPLE)
136 else(UNIX)
137 endif(UNIX)
139 if(WIN32)
140         include_directories (../platform/windows/compat_stuff)
141         list(APPEND sclang_sources ../platform/windows/compat_stuff/getopt.c)
142 endif()
144 if (SC_WII OR APPLE)
145         if(CMAKE_SYSTEM_NAME MATCHES "Linux")
146                 find_package(CWiid)
147                 find_package(Bluetooth)
149                 if (BLUETOOTH_FOUND AND CWIID_FOUND)
150                         add_definitions(-DHAVE_WII)
151                         include_directories(${CWIID_INCLUDE_DIRS} ${BLUETOOTH_INCLUDE_DIRS})
152                         message(STATUS "Compiling with WiiMote support")
153                 else()
154                         message(SEND_ERROR "Cannot find libcwiid or libbluetooth")
155                 endif()
156         elseif(APPLE)
157                 add_definitions(-DHAVE_WII)
158                 list(APPEND sclang_sources LangPrimSource/WiiMote_OSX/wiiremote.c)
159                 include_directories(LangPrimSource/WiiMote_OSX)
160         endif()
161 endif()
163 if(SC_QT)
164         set(QT_COLLIDER_LANG_CLIENT ON)
165         include(../QtCollider/CMakeLists.txt)
166         list(APPEND sclang_sources ${QT_COLLIDER_SRCS})
167 endif()
169 if(0 AND FINAL_BUILD) # sclang final-builds are broken
170         CREATE_FINAL_FILE(libsclang_final.cpp ${sclang_sources})
171         add_library(libsclang STATIC libsclang_final.cpp ${sclang_parser_source})
172 else()
173         add_library(libsclang STATIC ${sclang_sources} ${sclang_parser_source})
174 endif()
176 set_property(TARGET libsclang
177         APPEND
178         PROPERTY COMPILE_DEFINITIONS BUILDING_SUPERCOLLIDER)
180 if (SC_WII OR APPLE)
181         if (BLUETOOTH_FOUND AND CWIID_FOUND)
182                 target_link_libraries(libsclang ${BLUETOOTH_LIBRARIES} ${CWIID_LIBRARIES})
183         elseif(APPLE)
184                 target_link_libraries(libsclang "-framework IOBluetooth")
185         endif()
186 endif()
188 if (SCLANG_SERVER)
189         target_link_libraries(libsclang libscsynth)
190 else()
191         set_property(TARGET libsclang
192                 APPEND
193                 PROPERTY COMPILE_DEFINITIONS NO_INTERNAL_SERVER
194                 )
195 endif()
198 set_property(TARGET libsclang
199         PROPERTY OUTPUT_NAME sclang)
202 ## external libraries
203 if(READLINE_FOUND)
204         message(STATUS "Compiling with Readline support")
205         set_property(TARGET libsclang
206                 APPEND
207                 PROPERTY COMPILE_DEFINITIONS HAVE_READLINE)
208         target_link_libraries(libsclang ${READLINE_LIBRARY})
209 endif(READLINE_FOUND)
211 if (APPLE)
212         target_link_libraries(libsclang "-framework Carbon")
213         target_link_libraries(libsclang "-framework CoreAudio")
214         target_link_libraries(libsclang "-framework CoreMIDI")
215         target_link_libraries(libsclang "-framework IOKit")
216         target_link_libraries(libsclang "-framework CoreServices")
217 endif()
219 if(ALSA_FOUND)
220         message(STATUS "Compiling with ALSA midi support")
221         set_property(TARGET libsclang
222                 APPEND
223                 PROPERTY COMPILE_DEFINITIONS HAVE_ALSA=1)
224         target_link_libraries(libsclang ${ALSA_LIBRARY})
225 endif(ALSA_FOUND)
227 if(SNDFILE_FOUND)
228         include_directories(${SNDFILE_INCLUDE_DIR})
229         target_link_libraries(libsclang ${SNDFILE_LIBRARIES})
230 elseif(NOT NO_LIBSNDFILE)
231         message(SEND_ERROR "Cannot find libsndfile")
232 endif(SNDFILE_FOUND)
234 if (FFTW3F_FOUND)
235         include_directories (${FFTW3F_INCLUDE_DIR})
236         target_link_libraries(libsclang ${FFTW3F_LIBRARY})
237 endif()
239 if (WIN32)
240         target_link_libraries(libsclang wsock32 ws2_32)
241 endif()
243 if (GC_SANITYCHECK)
244         add_definitions(-DGC_SANITYCHECK)
245 endif()
247 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
248         target_link_libraries(libsclang rt)
249 endif()
251 target_link_libraries(libsclang ${PTHREADS_LIBRARY} supercollider_boost_thread)
253 if(SC_QT)
254         target_link_libraries(libsclang ${QT_COLLIDER_LIBS})
255 endif()
257 add_executable(sclang LangSource/cmdLineFuncs.cpp)
258 target_link_libraries(sclang libsclang boost_thread)
260 set_property(TARGET sclang
261         APPEND
262         PROPERTY COMPILE_DEFINITIONS USE_SC_TERMINAL_CLIENT)
264 if(LTO)
265     set_property(TARGET sclang libsclang
266                  APPEND PROPERTY COMPILE_FLAGS "-flto -flto-report")
268     set_property(TARGET sclang libsclang
269                  APPEND PROPERTY LINK_FLAGS "-flto -flto-report -fwhole-program")
270 endif()
272 if(APPLE)
273         # determines the app name and app install location (scappbundlename, scappdir):
274         include (${CMAKE_SOURCE_DIR}/cmake_modules/MacAppFolder.cmake)
276         install(TARGETS sclang
277                         DESTINATION "${scappauxresourcesdir}"
278                         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
279 elseif(WIN32)
280         install(TARGETS sclang
281                         DESTINATION "SuperCollider"
282                         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
283 else()
284         install(TARGETS sclang
285                         RUNTIME DESTINATION "bin"
286                         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
287 endif()