FFT: Prevent user from attempting hops smaller than SC's block size
[supercollider.git] / server / scsynth / CMakeLists.txt
blob92d39709dc078fcbf6b53a1a88fb9353e98707b0
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 string(TOLOWER "$ENV{AUDIOAPI}" AUDIOAPI)
35 if(AUDIOAPI STREQUAL "")
36         if(APPLE)
37                 set(AUDIOAPI coreaudio)
38         elseif(WIN32)
39                 set(AUDIOAPI portaudio)
40         else()
41                 set(AUDIOAPI jack)
42         endif(APPLE)
43 endif()
45 if(NOT AUDIOAPI MATCHES "^(jack|coreaudio|portaudio)$")
46         message(WARNING "Unrecognised audio API: ${AUDIOAPI}")
47 endif()
49 if(AUDIOAPI STREQUAL jack)
50         find_package(Jack)
51         if(NOT JACK_FOUND)
52                 message(FATAL_ERROR "Jack selected as audio API, but development files not found")
53         endif()
54 elseif(AUDIOAPI STREQUAL portaudio)
55         find_package(Portaudio)
56         if(NOT PORTAUDIO_FOUND)
57                 message(FATAL_ERROR "Portaudio selected as audio API, but development files not found")
58         endif()
59 endif()
60 message(STATUS "Audio API: ${AUDIOAPI}")
62 set(scsynth_sources
63         Samp.cpp
64         SC_BufGen.cpp
65         SC_Carbon.cpp
67         SC_ComPort.cpp
68         SC_CoreAudio.cpp
69         SC_Errors.cpp
70         SC_Graph.cpp
71         SC_GraphDef.cpp
72         SC_Group.cpp
73         SC_Lib_Cintf.cpp
74         SC_Lib.cpp
75         SC_MiscCmds.cpp
76         SC_Node.cpp
77         SC_Rate.cpp
78         SC_SequencedCommand.cpp
79         SC_Str4.cpp
80         SC_Unit.cpp
81         SC_UnitDef.cpp
82         SC_World.cpp
83         Rendezvous.cpp
85         ${CMAKE_SOURCE_DIR}/common/SC_fftlib.cpp
86         ${CMAKE_SOURCE_DIR}/common/SC_AllocPool.cpp
87         ${CMAKE_SOURCE_DIR}/common/SC_DirUtils.cpp
88         ${CMAKE_SOURCE_DIR}/common/SC_Reply.cpp
89         ${CMAKE_SOURCE_DIR}/common/SC_Sem.cpp
90         ${CMAKE_SOURCE_DIR}/common/SC_StandAloneInfo_Darwin.cpp
91         ${CMAKE_SOURCE_DIR}/common/SC_StringBuffer.cpp
92         ${CMAKE_SOURCE_DIR}/common/SC_StringParser.cpp
93         ${CMAKE_SOURCE_DIR}/common/scsynthsend.cpp
94         ${CMAKE_SOURCE_DIR}/common/sc_popen.cpp
96         ${CMAKE_SOURCE_DIR}/external_libraries/TLSF-2.4.6/src/tlsf.c
99 if(WIN32)
100     list(APPEND scsynth_sources ${CMAKE_SOURCE_DIR}/common/SC_Win32Utils.cpp)
101 endif()
103 if (FFT_GREEN)
104         list(APPEND scsynth_sources ../../common/fftlib.c)
105 endif()
107 if (FFTW3F_FOUND)
108         include_directories (${FFTW3F_INCLUDE_DIR})
109 endif()
112 include_directories(${CMAKE_SOURCE_DIR}/include/common
113                     ${CMAKE_SOURCE_DIR}/common
114                     ${CMAKE_SOURCE_DIR}/include/server
115                     ${CMAKE_SOURCE_DIR}/include/plugin_interface)
117 include_directories (${CMAKE_SOURCE_DIR}/external_libraries/TLSF-2.4.6/src)
119 set_property(DIRECTORY
120              APPEND
121              PROPERTY COMPILE_DEFINITIONS SC_MEMORY_ALIGNMENT=32)
123 if (AUDIOAPI STREQUAL jack)
124         list(APPEND scsynth_sources SC_Jack.cpp)
125         add_definitions("-DSC_AUDIO_API=SC_AUDIO_API_JACK" ${JACK_DEFINITIONS})
126         include_directories(${JACK_INCLUDE_DIRS})
127 elseif (AUDIOAPI STREQUAL portaudio)
128         add_definitions("-DSC_AUDIO_API=SC_AUDIO_API_PORTAUDIO" ${PORTAUDIO_DEFINITIONS})
129         include_directories(${PORTAUDIO_INCLUDE_DIRS})
130 endif()
132 set (FINAL_BUILD 0) # disable final build for scsynth
134 if (LIBSCSYNTH)
135         set (LIBSCSYNTH_TYPE SHARED)
136 else()
137         set (LIBSCSYNTH_TYPE STATIC)
138 endif()
140 if (FINAL_BUILD)
141         CREATE_FINAL_FILE(libscsynth_final.cpp ${scsynth_sources})
142         add_library(libscsynth ${LIBSCSYNTH_TYPE} libscsynth_final.cpp)
143 else()
144         add_library(libscsynth ${LIBSCSYNTH_TYPE} ${scsynth_sources})
145 endif()
147 set_property(TARGET libscsynth
148         APPEND
149         PROPERTY COMPILE_DEFINITIONS BUILDING_SUPERCOLLIDER)
151 find_library(DL NAMES dl)
152 if (DL)
153     target_link_libraries(libscsynth ${DL})
154 endif()
156 if(AVAHI_FOUND)
157         add_definitions("-DHAVE_AVAHI=1")
158         include_directories(${AVAHI_INCLUDE_DIRS})
159         target_link_libraries(libscsynth ${AVAHI_LIBRARIES})
160 endif()
162 if(SNDFILE_FOUND)
163         include_directories(${SNDFILE_INCLUDE_DIR})
164         target_link_libraries(libscsynth ${SNDFILE_LIBRARIES})
165 elseif(NOT NO_LIBSNDFILE)
166         message(SEND_ERROR "Cannot find libsndfile")
167 endif(SNDFILE_FOUND)
169 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
170         add_definitions(-DSC_PLUGIN_DIR="${CMAKE_INSTALL_PREFIX}/lib/SuperCollider/plugins")
171 endif()
173 if (AUDIOAPI STREQUAL jack)
174         target_link_libraries(libscsynth ${JACK_LIBRARIES})
175 elseif(AUDIOAPI STREQUAL portaudio)
176         target_link_libraries(libscsynth ${PORTAUDIO_LIBRARIES})
177 elseif(AUDIOAPI STREQUAL coreaudio)
178         target_link_libraries(libscsynth "-framework CoreAudio")
179 endif()
181 if(PTHREADS_FOUND)
182         target_link_libraries(libscsynth ${PTHREADS_LIBRARIES})
183 endif()
186 if (WIN32)
187         target_link_libraries(libscsynth wsock32 ws2_32 winmm)
188 endif()
191 set_property(TARGET libscsynth PROPERTY OUTPUT_NAME scsynth)
193 if (LIBSCSYNTH)
194         # These two properties are ABI version info, not sc version:
195         set_property(TARGET libscsynth PROPERTY VERSION     1.0.0)
196         set_property(TARGET libscsynth PROPERTY SOVERSION   1)
197 endif()
199 if (FFTW3F_FOUND)
200         target_link_libraries(libscsynth ${FFTW3F_LIBRARY})
201 endif()
203 if (APPLE)
204         target_link_libraries(libscsynth "-framework vecLib -framework CoreServices")
205 endif()
207 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
208         target_link_libraries(libscsynth rt)
209 endif()
212 add_executable(scsynth scsynth_main.cpp)
213 target_link_libraries(scsynth libscsynth ${PTHREADS_LIBRARY})
215 if(LTO)
216     set_property(TARGET scsynth libscsynth
217                  APPEND PROPERTY COMPILE_FLAGS "-flto -flto-report")
219     set_property(TARGET scsynth libscsynth
220                  APPEND PROPERTY LINK_FLAGS "-flto -flto-report -fwhole-program")
221 endif()
223 if (LIBSCSYNTH)
224         set(INSTALL_TARGETS scsynth libscsynth)
225 else()
226         set(INSTALL_TARGETS scsynth)
227 endif()
229 if(APPLE)
230         # TODO allow apple users to install to fhs-ish path if INSTALL_FHS option is enabled
231         # determines the app name and app install location (scappbundlename, scappdir):
232         include (${CMAKE_SOURCE_DIR}/cmake_modules/MacAppFolder.cmake)
233         install(TARGETS ${INSTALL_TARGETS}
234                         RUNTIME DESTINATION "${scappauxresourcesdir}"
235                         LIBRARY DESTINATION "${scappauxresourcesdir}"
236                         PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE OWNER_WRITE)
237 elseif(WIN32)
238         install(TARGETS ${INSTALL_TARGETS}
239                         DESTINATION "SuperCollider"
240                         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
241 else()
242         install(TARGETS ${INSTALL_TARGETS}
243                         RUNTIME DESTINATION "bin"
244                         LIBRARY DESTINATION "lib"
245                         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
246 endif()