bumping version to 3.5-rc1
[supercollider.git] / lang / CMakeLists.txt
blob0819ad1921b559d2af25b284e51765e0cebd254a
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 find_package(Readline 5.0)
20 find_package(Sndfile)
22 set(sclang_sources
23         LangPrimSource/SC_Wii.cpp
24         LangPrimSource/PyrSignalPrim.cpp
25         LangPrimSource/PyrSched.cpp
26         LangPrimSource/PyrPrimitive.cpp
27         LangPrimSource/PyrMathPrim.cpp
28         LangPrimSource/SC_ComPort.cpp
29         LangPrimSource/OSCData.cpp
30         LangPrimSource/PyrArchiver.cpp
31         LangPrimSource/PyrArrayPrimitives.cpp
32         LangPrimSource/PyrBitPrim.cpp
33         LangPrimSource/PyrCharPrim.cpp
34         LangPrimSource/PyrFilePrim.cpp
35         LangPrimSource/PyrListPrim.cpp
36         LangPrimSource/PyrPlatformPrim.cpp
37         LangPrimSource/PyrStringPrim.cpp
38         LangPrimSource/PyrSymbolPrim.cpp
39         LangPrimSource/PyrUnixPrim.cpp
40         LangSource/AdvancingAllocPool.cpp
41         LangSource/ByteCodeArray.cpp
42         LangSource/DumpParseNode.cpp
43         LangSource/GC.cpp
44         LangSource/InitAlloc.cpp
45         LangSource/PyrFileUtils.cpp
46         LangSource/PyrInterpreter3.cpp
47         LangSource/PyrLexer.cpp
48         LangSource/PyrMathOps.cpp
49         LangSource/PyrMathSupport.cpp
50         LangSource/PyrMessage.cpp
51         LangSource/PyrObject.cpp
52         LangSource/PyrParseNode.cpp
53         LangSource/PyrSignal.cpp
54         LangSource/PyrSymbolTable.cpp
55         LangSource/SC_LanguageClient.cpp
56         LangSource/SC_LibraryConfig.cpp
57         LangSource/SC_TerminalClient.cpp
58         LangSource/Samp.cpp
59         LangSource/SimpleStack.cpp
60         LangSource/VMGlobals.cpp
61         LangSource/dumpByteCodes.cpp
63         ${CMAKE_SOURCE_DIR}/common/fftlib.c
64         ${CMAKE_SOURCE_DIR}/common/SC_AllocPool.cpp
65         ${CMAKE_SOURCE_DIR}/common/SC_DirUtils.cpp
66         ${CMAKE_SOURCE_DIR}/common/SC_Sem.cpp
67         ${CMAKE_SOURCE_DIR}/common/SC_StandAloneInfo_Darwin.cpp
68         ${CMAKE_SOURCE_DIR}/common/SC_StringBuffer.cpp
69         ${CMAKE_SOURCE_DIR}/common/SC_StringParser.cpp
70         ${CMAKE_SOURCE_DIR}/common/scsynthsend.cpp
71         ${CMAKE_SOURCE_DIR}/common/sc_popen.cpp
74 file(GLOB boost_system_sources ../external_libraries/boost/libs/system/src/*cpp)
75 file(GLOB boost_fs_sources ../external_libraries/boost/libs/filesystem/v3/src/*cpp)
76 file(GLOB boost_regex_sources ../external_libraries/boost/libs/regex/src/*cpp)
77 list(APPEND sclang_sources ${boost_fs_sources} ${boost_system_sources} ${boost_regex_sources})
79 file(GLOB yaml_sources ../external_libraries/yaml-cpp-0.2.6/src/*cpp)
80 list(APPEND sclang_sources ${yaml_sources})
82 if(NOT WIN32)
83         list(APPEND sclang_sources LangPrimSource/PyrSerialPrim.cpp)
84 endif()
86 if(WIN32)
87         list(APPEND sclang_sources ${CMAKE_SOURCE_DIR}/common/SC_Win32Utils.cpp)
88 endif()
90 if(WIN32)
91         include_directories(../platform/windows/compat_stuff)
92         list(APPEND sclang_sources ../platform/windows/compat_stuff/getopt.c)
93 endif()
95 set(sclang_parser_source LangSource/Bison/lang11d_tab.cpp)
97 add_definitions(-DYYSTACK_USE_ALLOCA)
99 if(UNIX)
100         if(APPLE)
101                 list(APPEND sclang_sources
102                         LangPrimSource/WiiMote_OSX/wiiremote.c
103                         LangPrimSource/SC_HID.cpp
104                         LangPrimSource/${HID_UTIL_DIR}/HID_Utilities.c
105                         LangPrimSource/${HID_UTIL_DIR}/HID_Name_Lookup.c
106                         LangPrimSource/${HID_UTIL_DIR}/HID_Queue_Utilities.c
107                         LangPrimSource/${HID_UTIL_DIR}/HID_Error_Handler.c
108                         LangPrimSource/SC_CoreMIDI.cpp
109                         LangPrimSource/SC_CoreAudioPrim.cpp
110                         LangPrimSource/SC_Speech.M
111                         )
112                 add_definitions(-DHAVE_SPEECH)
113                 if (CMAKE_COMPILER_IS_GNUCXX)
114                         set_source_files_properties(LangPrimSource/SC_Speech.M
115                                                                                 PROPERTIES COMPILE_FLAGS "-x objective-c++ -fobjc-exceptions")
116                 endif()
117                 if(NOT (HID_UTIL_DIR MATCHES "HID_Utilities_10_4"))
118                         list(APPEND sclang_sources
119                                 LangPrimSource/${HID_UTIL_DIR}/IOHIDElement_.c
120                                 LangPrimSource/${HID_UTIL_DIR}/IOHIDDevice_.c
121                         )
122                 endif()
123         else(APPLE)
124                 if(ALSA_FOUND)
125                         list(APPEND sclang_sources LangPrimSource/SC_AlsaMIDI.cpp)
126                 endif()
127                 list(APPEND sclang_sources LangPrimSource/SC_LID.cpp)
128                 add_definitions(-DHAVE_LID)
129         endif(APPLE)
130 else(UNIX)
131 endif(UNIX)
133 if(WIN32)
134         include_directories (../platform/windows/compat_stuff)
135         list(APPEND sclang_sources ../platform/windows/compat_stuff/getopt.c)
136 endif()
138 if (SC_WII OR APPLE)
139         if(CMAKE_SYSTEM_NAME MATCHES "Linux")
140                 find_package(CWiid)
141                 find_package(Bluetooth)
143                 if (BLUETOOTH_FOUND AND CWIID_FOUND)
144                         add_definitions(-DHAVE_WII)
145                         include_directories(${CWIID_INCLUDE_DIRS} ${BLUETOOTH_INCLUDE_DIRS})
146                         message(STATUS "Compiling with WiiMote support")
147                 else()
148                         message(SEND_ERROR "Cannot find libcwiid or libbluetooth")
149                 endif()
150         elseif(APPLE)
151                 add_definitions(-DHAVE_WII)
152                 list(APPEND sclang_sources LangPrimSource/WiiMote_OSX/wiiremote.c)
153                 include_directories(LangPrimSource/WiiMote_OSX)
154         endif()
155 endif()
157 if(SC_QT)
158         set(QT_COLLIDER_LANG_CLIENT ON)
159         include(../QtCollider/CMakeLists.txt)
160         list(APPEND sclang_sources ${QT_COLLIDER_SRCS})
161 endif()
163 if(0 AND FINAL_BUILD) # sclang final-builds are broken
164         CREATE_FINAL_FILE(libsclang_final.cpp ${sclang_sources})
165         add_library(libsclang SHARED libsclang_final.cpp ${sclang_parser_source})
166 else()
167         add_library(libsclang STATIC ${sclang_sources} ${sclang_parser_source})
168 endif()
170 set_property(TARGET libsclang
171         APPEND
172         PROPERTY COMPILE_DEFINITIONS BUILDING_SUPERCOLLIDER)
174 if (SC_WII OR APPLE)
175         if (BLUETOOTH_FOUND AND CWIID_FOUND)
176                 target_link_libraries(libsclang ${BLUETOOTH_LIBRARIES} ${CWIID_LIBRARIES})
177         elseif(APPLE)
178                 target_link_libraries(libsclang "-framework IOBluetooth")
179         endif()
180 endif()
182 if (SCLANG_SERVER)
183         target_link_libraries(libsclang libscsynth)
184 else()
185         set_property(TARGET libsclang
186                 APPEND
187                 PROPERTY COMPILE_DEFINITIONS NO_INTERNAL_SERVER
188                 )
189 endif()
192 set_property(TARGET libsclang
193         PROPERTY OUTPUT_NAME sclang)
196 ## external libraries
197 if(READLINE_FOUND)
198         message(STATUS "Compiling with Readline support")
199         set_property(TARGET libsclang
200                 APPEND
201                 PROPERTY COMPILE_DEFINITIONS HAVE_READLINE)
202         target_link_libraries(libsclang ${READLINE_LIBRARY})
203 endif(READLINE_FOUND)
205 if (APPLE)
206         target_link_libraries(libsclang "-framework Carbon")
207         target_link_libraries(libsclang "-framework CoreAudio")
208         target_link_libraries(libsclang "-framework CoreMIDI")
209         target_link_libraries(libsclang "-framework IOKit")
210         target_link_libraries(libsclang "-framework CoreServices")
211 endif()
213 if(ALSA_FOUND)
214         message(STATUS "Compiling with ALSA midi support")
215         set_property(TARGET libsclang
216                 APPEND
217                 PROPERTY COMPILE_DEFINITIONS HAVE_ALSA=1)
218         target_link_libraries(libsclang ${ALSA_LIBRARY})
219 endif(ALSA_FOUND)
221 if(SNDFILE_FOUND)
222         include_directories(${SNDFILE_INCLUDE_DIR})
223         target_link_libraries(libsclang ${SNDFILE_LIBRARIES})
224 elseif(NOT NO_LIBSNDFILE)
225         message(SEND_ERROR "Cannot find libsndfile")
226 endif(SNDFILE_FOUND)
228 if (FFTW3F_FOUND)
229         include_directories (${FFTW3F_INCLUDE_DIR})
230         target_link_libraries(libsclang ${FFTW3F_LIBRARY})
231 endif()
233 if (WIN32)
234         target_link_libraries(libsclang wsock32 ws2_32)
235 endif()
237 if (GC_SANITYCHECK)
238         add_definitions(-DGC_SANITYCHECK)
239 endif()
241 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
242         target_link_libraries(libsclang rt)
243 endif()
245 target_link_libraries(libsclang ${PTHREADS_LIBRARY} supercollider_boost_thread)
247 if(SC_QT)
248         target_link_libraries(libsclang ${QT_COLLIDER_LIBS})
249 endif()
251 add_executable(sclang LangSource/cmdLineFuncs.cpp)
252 target_link_libraries(sclang libsclang boost_thread)
254 set_property(TARGET sclang
255         APPEND
256         PROPERTY COMPILE_DEFINITIONS USE_SC_TERMINAL_CLIENT)
258 if(LTO)
259     set_property(TARGET sclang libsclang
260                  APPEND PROPERTY COMPILE_FLAGS "-flto -flto-report")
262     set_property(TARGET sclang libsclang
263                  APPEND PROPERTY LINK_FLAGS "-flto -flto-report -fwhole-program")
264 endif()
266 if(APPLE)
267         # determines the app name and app install location (scappbundlename, scappdir):
268         include (${CMAKE_SOURCE_DIR}/cmake_modules/MacAppFolder.cmake)
270         install(TARGETS sclang
271                         DESTINATION "${scappauxresourcesdir}"
272                         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
273 elseif(WIN32)
274         install(TARGETS sclang
275                         DESTINATION "SuperCollider"
276                         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
277 else()
278         install(TARGETS sclang
279                         LIBRARY DESTINATION "lib"
280                         RUNTIME DESTINATION "bin"
281                         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
282 endif()