Fix scvim regsitry file for updated filename (thanks Carlo Capocasa)
[supercollider.git] / server / scsynth / CMakeLists.txt
blob1c938246b0f6ea69006620377fbd785b86ed0849
1 find_package(Sndfile)
2 if (WIN32)
3         find_package(Portaudio)
4 endif()
6 # here we choose who provides us with the FFT lib
7 if (FFT_GREEN)
8         add_definitions("-DSC_FFT_GREEN")
9 elseif (APPLE)
10         add_definitions("-DSC_FFT_VDSP")
11 else()
12         find_package(FFTW3f)
14         if (FFTW3F_FOUND)
15                 add_definitions("-DSC_FFT_FFTW")
16         else()
17                 message(SEND_ERROR "Cannot find libfftw3f")
18         endif()
19 endif()
22 if (NO_AVAHI)
24 elseif (APPLE)
25         add_definitions(-DUSE_RENDEZVOUS=1)
26 else()
27         find_package(Avahi)
28         if (AVAHI_FOUND)
29                 add_definitions(-DUSE_RENDEZVOUS=1)
30         endif()
31 endif()
33 # Here we work out which audio API to use, from system type and/or user option.
34 if(AUDIOAPI STREQUAL "default")
35         if(APPLE)
36                 set(AUDIOAPI coreaudio)
37         elseif(WIN32)
38                 set(AUDIOAPI portaudio)
39         else()
40                 set(AUDIOAPI jack)
41         endif(APPLE)
42 endif()
44 if(NOT AUDIOAPI MATCHES "^(jack|coreaudio|portaudio)$")
45         message(WARNING "Unrecognised audio API: ${AUDIOAPI}")
46 endif()
48 if(AUDIOAPI STREQUAL jack)
49         find_package(Jack)
50         if(NOT JACK_FOUND)
51                 message(FATAL_ERROR "Jack selected as audio API, but development files not found")
52         endif()
53 elseif(AUDIOAPI STREQUAL portaudio)
54         find_package(Portaudio)
55         if(NOT PORTAUDIO_FOUND)
56                 message(FATAL_ERROR "Portaudio selected as audio API, but development files not found")
57         endif()
58 endif()
59 message(STATUS "Audio API: ${AUDIOAPI}")
61 set(scsynth_sources
62         Samp.cpp
63         SC_BufGen.cpp
64         SC_Carbon.cpp
66         SC_ComPort.cpp
67         SC_CoreAudio.cpp
68         SC_Errors.cpp
69         SC_Graph.cpp
70         SC_GraphDef.cpp
71         SC_Group.cpp
72         SC_Lib_Cintf.cpp
73         SC_Lib.cpp
74         SC_MiscCmds.cpp
75         SC_Node.cpp
76         SC_Rate.cpp
77         SC_SequencedCommand.cpp
78         SC_Str4.cpp
79         SC_Unit.cpp
80         SC_UnitDef.cpp
81         SC_World.cpp
82         Rendezvous.cpp
84         ${CMAKE_SOURCE_DIR}/common/SC_fftlib.cpp
85         ${CMAKE_SOURCE_DIR}/common/SC_AllocPool.cpp
86         ${CMAKE_SOURCE_DIR}/common/SC_DirUtils.cpp
87         ${CMAKE_SOURCE_DIR}/common/SC_Reply.cpp
88         ${CMAKE_SOURCE_DIR}/common/SC_Sem.cpp
89         ${CMAKE_SOURCE_DIR}/common/SC_StandAloneInfo_Darwin.cpp
90         ${CMAKE_SOURCE_DIR}/common/SC_StringBuffer.cpp
91         ${CMAKE_SOURCE_DIR}/common/SC_StringParser.cpp
92         ${CMAKE_SOURCE_DIR}/common/scsynthsend.cpp
93         ${CMAKE_SOURCE_DIR}/common/sc_popen.cpp
95         ${CMAKE_SOURCE_DIR}/external_libraries/TLSF-2.4.6/src/tlsf.c
98 if(WIN32)
99     list(APPEND scsynth_sources ${CMAKE_SOURCE_DIR}/common/SC_Win32Utils.cpp)
100 endif()
102 if (FFT_GREEN)
103         list(APPEND scsynth_sources ../../common/fftlib.c)
104 endif()
106 if (FFTW3F_FOUND)
107         include_directories (${FFTW3F_INCLUDE_DIR})
108 endif()
111 include_directories(${CMAKE_SOURCE_DIR}/include/common
112                     ${CMAKE_SOURCE_DIR}/common
113                     ${CMAKE_SOURCE_DIR}/include/server
114                     ${CMAKE_SOURCE_DIR}/include/plugin_interface)
116 include_directories (${CMAKE_SOURCE_DIR}/external_libraries/TLSF-2.4.6/src)
118 set_property(DIRECTORY
119              APPEND
120              PROPERTY COMPILE_DEFINITIONS SC_MEMORY_ALIGNMENT=32)
122 if (AUDIOAPI STREQUAL jack)
123         list(APPEND scsynth_sources SC_Jack.cpp)
124         add_definitions("-DSC_AUDIO_API=SC_AUDIO_API_JACK" ${JACK_DEFINITIONS})
125         include_directories(${JACK_INCLUDE_DIRS})
126 elseif (AUDIOAPI STREQUAL portaudio)
127         add_definitions("-DSC_AUDIO_API=SC_AUDIO_API_PORTAUDIO" ${PORTAUDIO_DEFINITIONS})
128         include_directories(${PORTAUDIO_INCLUDE_DIRS})
129 endif()
131 set (FINAL_BUILD 0) # disable final build for scsynth
133 if (LIBSCSYNTH)
134         set (LIBSCSYNTH_TYPE SHARED)
135 else()
136         set (LIBSCSYNTH_TYPE STATIC)
137 endif()
139 if (FINAL_BUILD)
140         CREATE_FINAL_FILE(libscsynth_final.cpp ${scsynth_sources})
141         add_library(libscsynth ${LIBSCSYNTH_TYPE} libscsynth_final.cpp)
142 else()
143         add_library(libscsynth ${LIBSCSYNTH_TYPE} ${scsynth_sources})
144 endif()
146 set_property(TARGET libscsynth
147         APPEND
148         PROPERTY COMPILE_DEFINITIONS BUILDING_SUPERCOLLIDER)
150 find_library(DL NAMES dl)
151 if (DL)
152     target_link_libraries(libscsynth ${DL})
153 endif()
155 if(AVAHI_FOUND)
156         add_definitions("-DHAVE_AVAHI=1")
157         include_directories(${AVAHI_INCLUDE_DIRS})
158         target_link_libraries(libscsynth ${AVAHI_LIBRARIES})
159 endif()
161 if(SNDFILE_FOUND)
162         include_directories(${SNDFILE_INCLUDE_DIR})
163         target_link_libraries(libscsynth ${SNDFILE_LIBRARIES})
164 elseif(NOT NO_LIBSNDFILE)
165         message(SEND_ERROR "Cannot find libsndfile")
166 endif(SNDFILE_FOUND)
168 if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
169         add_definitions(-DSC_PLUGIN_DIR="${CMAKE_INSTALL_PREFIX}/lib/SuperCollider/plugins")
170 endif()
172 if (AUDIOAPI STREQUAL jack)
173         target_link_libraries(libscsynth ${JACK_LIBRARIES})
174 elseif(AUDIOAPI STREQUAL portaudio)
175         target_link_libraries(libscsynth ${PORTAUDIO_LIBRARIES})
176 elseif(AUDIOAPI STREQUAL coreaudio)
177         target_link_libraries(libscsynth "-framework CoreAudio")
178 endif()
180 if(PTHREADS_FOUND)
181         target_link_libraries(libscsynth ${PTHREADS_LIBRARIES})
182 endif()
185 if (WIN32)
186         target_link_libraries(libscsynth wsock32 ws2_32 winmm)
187 endif()
190 set_property(TARGET libscsynth PROPERTY OUTPUT_NAME scsynth)
192 if (LIBSCSYNTH)
193         # These two properties are ABI version info, not sc version:
194         set_property(TARGET libscsynth PROPERTY VERSION     1.0.0)
195         set_property(TARGET libscsynth PROPERTY SOVERSION   1)
196 endif()
198 if (FFTW3F_FOUND)
199         target_link_libraries(libscsynth ${FFTW3F_LIBRARY})
200 endif()
202 if (APPLE)
203         target_link_libraries(libscsynth "-framework vecLib -framework CoreServices")
204 endif()
206 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
207         target_link_libraries(libscsynth rt)
208 endif()
211 add_executable(scsynth scsynth_main.cpp)
212 target_link_libraries(scsynth libscsynth ${PTHREADS_LIBRARY})
214 if(LTO)
215     set_property(TARGET scsynth libscsynth
216                  APPEND PROPERTY COMPILE_FLAGS "-flto -flto-report")
218     set_property(TARGET scsynth libscsynth
219                  APPEND PROPERTY LINK_FLAGS "-flto -flto-report -fwhole-program")
220 endif()
222 if (LIBSCSYNTH)
223         set(INSTALL_TARGETS scsynth libscsynth)
224 else()
225         set(INSTALL_TARGETS scsynth)
226 endif()
228 if(APPLE)
229         # TODO allow apple users to install to fhs-ish path if INSTALL_FHS option is enabled
230         # determines the app name and app install location (scappbundlename, scappdir):
231         include (${CMAKE_SOURCE_DIR}/cmake_modules/MacAppFolder.cmake)
232         install(TARGETS ${INSTALL_TARGETS}
233                         RUNTIME DESTINATION "${scappauxresourcesdir}"
234                         LIBRARY DESTINATION "${scappauxresourcesdir}"
235                         PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE OWNER_WRITE)
236 elseif(WIN32)
237         install(TARGETS ${INSTALL_TARGETS}
238                         DESTINATION "SuperCollider"
239                         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
240 else()
241         install(TARGETS ${INSTALL_TARGETS}
242                         RUNTIME DESTINATION "bin"
243                         LIBRARY DESTINATION "lib"
244                         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
245 endif()