1 cmake_minimum_required(VERSION 2.8)
4 IF("${AUDIO_API}" STREQUAL "")
5 SET(AUDIO_API "portaudio")
6 ENDIF("${AUDIO_API}" STREQUAL "")
8 SET(ENV_CFLAGS $ENV{CFLAGS})
10 SET(CFLAGS ${ENV_CFLAGS})
13 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -std=c89 -Wall ${CFLAGS} -D_XOPEN_SOURCE=501L")
15 # tell where to look for additional cmake modules
16 SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
18 OPTION(BUILD_SHARED "Build libsvc as a shared library" OFF)
19 OPTION(BUILD_ENET_SVC "Build SVC ENet client/server" OFF)
20 OPTION(BUILD_TESTS "Build libsvc tests" OFF)
21 OPTION(BUILD_P2P "Build libsvc P2P simple client" ON)
23 OPTION(BUILD_SVCD "Build SVC daemon" ON)
24 OPTION(BUILD_SVCDC "Build SVC daemon cli controller" ON)
25 OPTION(BUILD_SVCC "Build SVC client" ON)
26 OPTION(BUILD_SVCCC "Build SVC client cli controller" ON)
29 FIND_PACKAGE(Celt REQUIRED)
30 FIND_PACKAGE(ENet REQUIRED)
31 FIND_PACKAGE(PortAudio REQUIRED)
33 FIND_PACKAGE(Jack REQUIRED)
34 #FIND_PACKAGE(OSS REQUIRED)
35 IF(NOT CMAKE_HOST_WIN32)
36 # those scripts will fail on windows
37 FIND_PACKAGE(ALSA REQUIRED)
38 ENDIF(NOT CMAKE_HOST_WIN32)
40 # correct pthread to use
42 find_library(PTHREAD_WIN32 pthreadGC2)
44 MESSAGE(FATAL_ERROR "Win32 SVC needs pthread-win32")
45 ENDIF(NOT PTHREAD_WIN32)
47 SET(PTHREAD_LIB "${PTHREAD_WIN32}")
48 ELSE(CMAKE_HOST_WIN32)
49 SET(PTHREAD_LIB "pthread")
50 ENDIF(CMAKE_HOST_WIN32)
53 # check if ENet SVC client and server should be built
56 MESSAGE(STATUS "SVC ENet client/server enabled")
57 IF(NOT ENET_LIBRARIES)
58 MESSAGE(FATAL_ERROR "Can't build SVC ENet client/server without ENet")
59 ENDIF(NOT ENET_LIBRARIES)
63 MESSAGE(STATUS "SVC ENet client/server disabled.")
70 IF("${AUDIO_API}" STREQUAL "portaudio")
71 MESSAGE(STATUS "Using PortAudio backend")
73 IF(NOT PORTAUDIO_LIBRARIES)
74 MESSAGE(FATAL_ERROR "Can't use PortAudio backend, libraries not found.")
75 ENDIF(NOT PORTAUDIO_LIBRARIES)
77 SET(AUDIOAPI_LIBRARIES ${PORTAUDIO_LIBRARIES})
78 ELSEIF("${AUDIO_API}" STREQUAL "jack")
79 MESSAGE(STATUS "Using Jack backend")
81 IF(NOT JACK_LIBRARIES)
82 MESSAGE(FATAL_ERROR "Can't use Jack backed, libraries not found.")
83 ENDIF(NOT JACK_LIBRARIES)
85 SET(AUDIOAPI_LIBRARIES ${JACK_LIBRARIES})
86 ELSEIF("${AUDIO_API}" STREQUAL "oss")
87 MESSAGE(STATUS "Using OSS backend")
90 MESSAGE(STATUS "OSS_INCLUDES is '${OSS_INCLUDES}'")
92 MESSAGE(STATUS "-DOSS_INCLUDES missing, using default include path")
95 SET(AUDIOAPI_LIBRARIES "")
96 ELSEIF("${AUDIO_API}" STREQUAL "alsa")
97 MESSAGE(STATUS "Using ALSA backend")
99 IF(NOT ALSA_LIBRARIES)
100 MESSAGE(FATAL_ERROR "Can't use ALSA backed, libraries not found.")
101 ENDIF(NOT ALSA_LIBRARIES)
103 SET(AUDIOAPI_LIBRARIES ${ALSA_LIBRARIES})
104 ELSEIF("${AUDIO_API}" STREQUAL "dummy")
105 MESSAGE(STATUS "Using dummy backend")
106 ELSE("${AUDIO_API}" STREQUAL "portaudio")
108 MESSAGE(FATAL_ERROR "Unknown AUDIO_API [${AUDIO_API}]")
110 ENDIF("${AUDIO_API}" STREQUAL "portaudio")
117 # FIXME: this is only for SVC[D/DC/C/CC] targets!
118 src/network/svc/common
119 # ${ENET_INCLUDE_DIR}
120 # ${CELT_INCLUDE_DIR}
121 # ${PORTAUDIO_INCLUDE_DIR}
127 MESSAGE(STATUS "Building shared libsvc")
128 SET(LIBSVC_TYPE SHARED)
130 MESSAGE(STATUS "Building static libsvc")
131 SET(LIBSVC_TYPE STATIC)
135 ADD_LIBRARY(svc ${LIBSVC_TYPE}
136 src/libsvc/packet_queue.c
138 src/libsvc/audio_api_${AUDIO_API}.c
139 src/libsvc/packet_cage.c
142 src/libsvc/libsvc_incoming.c
144 src/libsvc/network_packet.c
147 # Build SVC main daemon
149 MESSAGE(STATUS "Main SVC daemon build enabled.")
151 src/network/svc/server/main.c
152 src/network/svc/server/peer.c
153 src/network/svc/common/net.c
155 src/common/dstrutils.c
158 TARGET_LINK_LIBRARIES(svcd
162 MESSAGE(STATUS "Main SVC daemon build disabled.")
165 # Build SVC P2P simple client
167 MESSAGE(STATUS "Simple P2P client enabled.")
168 ADD_EXECUTABLE(svcp2p
169 src/network/svcp2p/main.c
172 TARGET_LINK_LIBRARIES(svcp2p
174 ${AUDIOAPI_LIBRARIES}
179 MESSAGE(STATUS "Simple P2P client disabled.")
183 # Build SVC ENet client and server
185 ADD_EXECUTABLE(svceclient
186 src/network/svcenet/client/main.c
188 TARGET_LINK_LIBRARIES(svceclient
191 ${AUDIOAPI_LIBRARIES}
196 ADD_EXECUTABLE(svceserver
197 src/network/svcenet/server/main.c
200 TARGET_LINK_LIBRARIES(svceserver
204 ENDIF(BUILD_ENET_SVC)
210 MESSAGE(STATUS "Tests enabled.")
212 ADD_EXECUTABLE(test_threads
213 src/tests/test_threads.c
216 TARGET_LINK_LIBRARIES(test_threads
221 ADD_EXECUTABLE(test_audio_api
222 src/tests/test_audio_api.c
224 src/libsvc/audio_api_${AUDIO_API}.c
227 TARGET_LINK_LIBRARIES(test_audio_api
228 ${AUDIOAPI_LIBRARIES}
234 ADD_EXECUTABLE(test_libsvc
235 src/tests/test_libsvc.c
236 src/libsvc/packet_queue.c
238 src/libsvc/audio_api_${AUDIO_API}.c
239 src/libsvc/packet_cage.c
242 src/libsvc/libsvc_incoming.c
244 src/libsvc/network_packet.c
246 TARGET_LINK_LIBRARIES(test_libsvc
247 ${AUDIOAPI_LIBRARIES}
253 ADD_EXECUTABLE(test_dstr
254 src/tests/test_dstr.c
256 src/tests/tests_utils.c
259 ADD_EXECUTABLE(test_dstrutils
260 src/tests/test_dstrutils.c
261 src/common/dstrutils.c
263 src/tests/tests_utils.c
268 MESSAGE(STATUS "Tests disabled.")
272 SET_SOURCE_FILES_PROPERTIES(src/libsvc/audio_api_oss.c
273 PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wextra")