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