-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCMakeLists.txt
348 lines (289 loc) · 11.1 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
cmake_minimum_required(VERSION 2.8.8)
project(pjproject)
################################################################################
# build options
################################################################################
# miscs
set(CMAKE_VERBOSE_MAKEFILE ON)
# targeted OS
set(TARGET_LINUX OFF CACHE BOOL "target OS is Linux")
set(TARGET_ANDROID OFF CACHE BOOL "target OS is Android")
set(TARGET_MACOSX OFF CACHE BOOL "target OS is Mac OS X")
set(TARGET_IOS OFF CACHE BOOL "target OS is iOS")
set(TARGET_WINDOWS OFF CACHE BOOL "target OS is Windows")
# build type
set(PJSIP_STATIC_BUILD OFF CACHE BOOL "enable static build")
# features
set(WITH_SRTP ON CACHE BOOL "enable SRTP")
set(WITH_SSL ON CACHE BOOL "enable SSL")
set(WITH_BUILTIN_OPENSSL OFF CACHE BOOL "enable built-in OpenSSL")
set(WITH_AUDIODEV_PORTAUDIO OFF CACHE BOOL "enable portaudio audio device")
set(WITH_AUDIODEV_COREAUDIO OFF CACHE BOOL "enable coreaudio audio device")
set(WITH_AUDIODEV_OPENSL OFF CACHE BOOL "enable OpenSL audio device")
set(WITH_AUDIODEV_ALSA OFF CACHE BOOL "enable alsa audio device")
set(WITH_AUDIODEV_WMME OFF CACHE BOOL "enable WMME audio device")
set(WITH_RESAMPLE_LIBRESAMPLE OFF CACHE BOOL "enable libresample ressampling")
set(WITH_RESAMPLE_LIBSAMPLERATE OFF CACHE BOOL "enable libsamplerate ressampling")# TODO: test ON
set(WITH_UUID_LIB ON CACHE BOOL "enable libUUID for callId generation")
set(WITH_PASSTHROUGH_CODECS OFF CACHE BOOL "enable passthrough codecs")
set(WITH_CODEC_SPEEX OFF CACHE BOOL "enable speex codec")
set(WITH_CODEC_ILBC OFF CACHE BOOL "enable ilbc codec")
set(WITH_CODEC_IPP OFF CACHE BOOL "enable ipp codecs") # TODO: test ON
set(WITH_CODEC_GSM OFF CACHE BOOL "enable gsm codec")
set(WITH_CODEC_G722 ON CACHE BOOL "enable g722 codec")
set(WITH_CODEC_G7221 OFF CACHE BOOL "enable g7221 codec")
set(WITH_CODEC_L16 OFF CACHE BOOL "enable l16 codec")
set(WITH_CODEC_AMRNB OFF CACHE BOOL "enable amr narrowband codec")
set(WITH_CODEC_AMRWB OFF CACHE BOOL "enable amr wideband codec")
set(WITH_CODEC_OPUS OFF CACHE BOOL "enable opus codec")
set(WITH_AEC_SPEEX OFF CACHE BOOL "enable speex aec")
# auto-fix incompatibles options
if(NOT WITH_CODEC_SPEEX AND WITH_AEC_SPEEX)
set(WITH_AEC_SPEEX OFF)
message(WARNING "disabling WITH_AEC_SPEEX because WITH_CODEC_SPEEX is OFF...")
endif()
if(WITH_CODEC_AMRWB OR WITH_CODEC_AMRNB)
if(WITH_CODEC_IPP)
set(WITH_CODEC_IPP OFF)
message(WARNING "disabling WITH_CODEC_IPP because WITH_CODEC_AMRWB or WITH_CODEC_AMRNB is ON...")
endif()
if(WITH_PASSTHROUGH_CODECS)
set(WITH_PASSTHROUGH_CODECS OFF)
message(WARNING "disabling WITH_PASSTHROUGH_CODECS because WITH_CODEC_AMRWB or WITH_CODEC_AMRNB is ON...")
endif()
endif()
if(WITH_CODEC_G7221 AND WITH_CODEC_IPP)
set(WITH_CODEC_G7221 OFF)
message(WARNING "disabling WITH_CODEC_G7221 because WITH_CODEC_IPP is ON...")
endif()
################################################################################
# Features specific
################################################################################
set(CODEC_LIBS)
if(WITH_SRTP)
add_definitions(-DPJMEDIA_HAS_SRTP=1)
else()
add_definitions(-DPJMEDIA_HAS_SRTP=0)
endif()
if(WITH_SSL)
add_definitions(-DPJ_HAS_SSL_SOCK=1)
else()
add_definitions(-DPJ_HAS_SSL_SOCK=0)
endif()
if(WITH_AUDIODEV_PORTAUDIO)
add_definitions(-DPJMEDIA_AUDIO_DEV_HAS_PORTAUDIO=1)
else()
add_definitions(-DPJMEDIA_AUDIO_DEV_HAS_PORTAUDIO=0)
endif()
if(WITH_AUDIODEV_COREAUDIO)
add_definitions(-DPJMEDIA_AUDIO_DEV_HAS_COREAUDIO=1)
else()
add_definitions(-DPJMEDIA_AUDIO_DEV_HAS_COREAUDIO=0)
endif()
if(WITH_AUDIODEV_OPENSL)
add_definitions(-DPJMEDIA_AUDIO_DEV_HAS_OPENSL=1)
else()
add_definitions(-DPJMEDIA_AUDIO_DEV_HAS_OPENSL=0)
endif()
if(WITH_AUDIODEV_WMME)
add_definitions(-DPJMEDIA_AUDIO_DEV_HAS_WMME=1)
else()
add_definitions(-DPJMEDIA_AUDIO_DEV_HAS_WMME=0)
endif()
if(WITH_AUDIODEV_ALSA)
add_definitions(-DPJMEDIA_AUDIO_DEV_HAS_ALSA=1)
set(AUDIODEV_LIBS ${AUDIODEV_LIBS} asound)
else()
add_definitions(-DPJMEDIA_AUDIO_DEV_HAS_ALSA=0)
endif()
if(WITH_RESAMPLE_LIBRESAMPLE)
add_definitions(-DPJMEDIA_RESAMPLE_IMP=PJMEDIA_RESAMPLE_LIBRESAMPLE)
set(RESAMPLING_NAME "resample")
elseif(WITH_RESAMPLE_LIBSAMPLERATE)
add_definitions(-DPJMEDIA_RESAMPLE_IMP=PJMEDIA_RESAMPLE_LIBSAMPLERATE)
set(RESAMPLING_NAME "libsamplerate")
else()
add_definitions(-DPJMEDIA_RESAMPLE_IMP=PJMEDIA_RESAMPLE_NONE)
set(RESAMPLING_NAME "none")
endif()
if(WITH_PASSTHROUGH_CODECS)
add_definitions(-DPJMEDIA_HAS_PASSTHROUGH_CODECS=1)
else()
add_definitions(-DPJMEDIA_HAS_PASSTHROUGH_CODECS=0)
endif()
if(WITH_CODEC_SPEEX)
add_definitions(-DPJMEDIA_HAS_SPEEX_CODEC=1)
else()
add_definitions(-DPJMEDIA_HAS_SPEEX_CODEC=0)
endif()
if(WITH_CODEC_ILBC)
add_definitions(-DPJMEDIA_HAS_ILBC_CODEC=1)
else()
add_definitions(-DPJMEDIA_HAS_ILBC_CODEC=0)
endif()
if(WITH_CODEC_IPP)
add_definitions(-DPJMEDIA_HAS_INTEL_IPP=1)
else()
add_definitions(-DPJMEDIA_HAS_INTEL_IPP=0)
endif()
if(WITH_CODEC_GSM)
add_definitions(-DPJMEDIA_HAS_GSM_CODEC=1)
else()
add_definitions(-DPJMEDIA_HAS_GSM_CODEC=0)
endif()
if(WITH_CODEC_G722)
add_definitions(-DPJMEDIA_HAS_G722_CODEC=1)
else()
add_definitions(-DPJMEDIA_HAS_G722_CODEC=0)
endif()
if(WITH_CODEC_G7221)
add_definitions(-DPJMEDIA_HAS_G7221_CODEC=1)
else()
add_definitions(-DPJMEDIA_HAS_G7221_CODEC=0)
endif()
if(WITH_CODEC_L16)
add_definitions(-DPJMEDIA_HAS_L16_CODEC=1)
else()
add_definitions(-DPJMEDIA_HAS_L16_CODEC=0)
endif()
if(WITH_AEC_SPEEX)
add_definitions(-DPJMEDIA_HAS_SPEEX_AEC=1)
else()
add_definitions(-DPJMEDIA_HAS_SPEEX_AEC=0)
endif()
if(WITH_CODEC_AMRNB)
add_definitions(-DPJMEDIA_HAS_OPENCORE_AMRNB_CODEC=1)
set(CODEC_LIBS ${CODEC_LIBS} opencore-amrnb)
else()
add_definitions(-DPJMEDIA_HAS_OPENCORE_AMRNB_CODEC=0)
endif()
if(WITH_CODEC_AMRWB)
add_definitions(-DPJMEDIA_HAS_OPENCORE_AMRWB_CODEC=1)
set(CODEC_LIBS ${CODEC_LIBS} opencore-amrwb)
else()
add_definitions(-DPJMEDIA_HAS_OPENCORE_AMRWB_CODEC=0)
endif()
if(WITH_CODEC_OPUS)
add_definitions(-DPJMEDIA_HAS_OPUS_CODEC=1)
else()
add_definitions(-DPJMEDIA_HAS_OPUS_CODEC=0)
endif()
################################################################################
# Hardware specific
################################################################################
if(WITH_FLOATING_POINT)
add_definitions(-DPJ_HAS_FLOATING_POINT=1)
else()
add_definitions(-DPJ_HAS_FLOATING_POINT=0)
endif()
################################################################################
# OS specific
################################################################################
# Linux
if(TARGET_LINUX)
set(CMAKE_SYSTEM_NAME Linux)
add_definitions(-DPJ_LINUX=1 -DPJ_SOCK_HAS_GETADDRINFO=1 -DPJ_SOCK_HAS_INET_ATON=1 -DPJ_SOCK_HAS_INET_PTON=1 -DPJ_SOCK_HAS_INET_NTOP=1)
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -fPIC)
set(OS_LIBS rt m pthread)
if(WITH_SSL AND NOT WITH_BUILTIN_OPENSSL)
set(OS_LIBS ${OS_LIBS} ssl crypto)
endif()
if(WITH_AUDIODEV_PORTAUDIO)
set(AUDIODEV_LIBS ${AUDIODEV_LIBS} asound)
endif()
endif()
# Mac OS X
if(TARGET_MACOSX)
set(CMAKE_SYSTEM_NAME Darwin)
add_definitions(-DPJ_DARWINOS=1 -DPJ_HAS_SEMAPHORE_H=1 -DPJ_SOCK_HAS_INET_ATON=1 -DPJ_SOCK_HAS_INET_PTON=1 -DPJ_SOCK_HAS_INET_NTOP=1)
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -fPIC)
set(OS_LIBS)
if(WITH_SSL)
set(OS_LIBS ${OS_LIBS} ssl crypto)
endif()
endif()
# Windows
if(TARGET_WINDOWS)
set(CMAKE_SYSTEM_NAME Windows)
add_definitions(-DPJ_WIN32=1)
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
set(OS_LIBS)
endif()
# Android
if(TARGET_ANDROID)
set(CMAKE_SYSTEM_NAME Android)
add_definitions(-DPJ_ANDROID=1 -DANDROID_ABI=${ANDROID_ABI} -DPJ_HAS_SEMAPHORE_H=1 -DPJ_SOCK_HAS_INET_ATON=1 -DPJ_SOCK_HAS_INET_PTON=1 -DPJ_SOCK_HAS_INET_NTOP=1 -DPJ_HAS_THREADS=1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fvisibility=hidden")
include_directories(SYSTEM ${ANDROID_NDK}/platforms/${ANDROID_LEVEL}/arch-arm/usr/include)
if(ANDROID_ABI STREQUAL "armeabi-v7a" OR ANDROID_ABI STREQUAL "armeabi")
add_definitions(-mno-thumb-interwork -DPJ_ANDROID_ARM=1 -D__ARM_EABI__)
endif()
if(ANDROID_ABI STREQUAL "x86")
add_definitions(-DPJ_ANDROID_X86=1)
endif()
set(OS_LIBS log z OpenSLES)
endif()
# iOS
if(TARGET_IOS)
add_definitions(-DPJ_DARWINOS=1 -DPJ_IOS=1 -w -DPJ_HAS_SEMAPHORE_H=1 -DPJ_SOCK_HAS_INET_ATON=1 -DPJ_SOCK_HAS_INET_PTON=1 -DPJ_SOCK_HAS_INET_NTOP=1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
################################################################################
# Print summary
################################################################################
message("Target OS: ${CMAKE_SYSTEM_NAME}")
if(TARGET_ANDROID)
message("Android:")
message("- NDK: ${ANDROID_NDK}")
message("- ABI: ${ANDROID_ABI}")
message("- API Level: ${ANDROID_NATIVE_API_LEVEL}")
endif()
message("Options:")
message("- SRTP: ${WITH_SRTP}")
message("- SSL: ${WITH_SSL}")
message("- Built-in SSL: ${WITH_BUILTIN_OPENSSL}")
message("- Speex AEC: ${WITH_AEC_SPEEX}")
message("Codecs:")
message("- passthrough: ${WITH_PASSTHROUGH_CODECS}")
message("- speex: ${WITH_CODEC_SPEEX}")
message("- gsm: ${WITH_CODEC_GSM}")
message("- ilbc: ${WITH_CODEC_ILBC}")
message("- intel ipp: ${WITH_CODEC_IPP}")
message("- g722: ${WITH_CODEC_G722}")
message("- g7221: ${WITH_CODEC_G7221}")
message("- l16: ${WITH_CODEC_L16}")
message("- amr narrowband:${WITH_CODEC_AMRNB}")
message("- amr wideband: ${WITH_CODEC_AMRWB}")
message("- opus: ${WITH_CODEC_OPUS}")
message("Resampling: ${RESAMPLING_NAME}")
message("Audio dev libs: ${AUDIODEV_LIBS}")
################################################################################
# Common
################################################################################
# sub-directories
set(PJSIP_SUBDIRECTORIES pjlib pjlib-util pjnath pjmedia pjsip)
foreach(SUBDIRECTORY ${PJSIP_SUBDIRECTORIES})
set(PJSIP_INCLUDES ${PJSIP_INCLUDES} ${SUBDIRECTORY}/include/)
endforeach()
include_directories(${CMAKE_FIND_ROOT_PATH}/usr/include})
include_directories(AFTER SYSTEM . ${PJSIP_INCLUDES} ${CMAKE_BINARY_DIR})
add_subdirectory(third_party/build)
foreach(SUBDIRECTORY ${PJSIP_SUBDIRECTORIES})
add_subdirectory(${SUBDIRECTORY}/build)
set(TARGET_OBJECTS_LIST ${TARGET_OBJECTS_LIST} $<TARGET_OBJECTS:${SUBDIRECTORY}>)
endforeach()
# build target
if(TARGET_ANDROID AND NOT PJSIP_STATIC_BUILD)
set(PROJECT_NAME sipCore)
add_library(${PROJECT_NAME} SHARED ${TARGET_OBJECTS_LIST} ${THIRDPARTY_OBJECTS_LIST})
else()
add_library(${PROJECT_NAME} STATIC ${TARGET_OBJECTS_LIST} ${THIRDPARTY_OBJECTS_LIST})
endif()
target_link_libraries(${PROJECT_NAME} ${OS_LIBS} ${CODEC_LIBS} ${AUDIODEV_LIBS})
if(BUILD_PJSUA-APP)
file(GLOB PJSUA-APP_SRC pjsip-apps/src/pjsua/pjsua_app*)
set(PJSUA-APP_SRC ${PJSUA-APP_SRC}
pjsip-apps/src/pjsua/main.c)
add_executable(pjsua ${PJSUA-APP_SRC})
target_link_libraries(pjsua ${PROJECT_NAME})
endif()