CMakeLists.txt 20.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
############################################################################
# CMakeLists.txt
# Copyright (C) 2014  Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 21 22
#
############################################################################

23
find_library(LIBM NAMES m)
24

25 26
if(ANDROID)
	find_library(ANDROID_CPU_FEATURES_LIBRARY NAMES cpufeatures)
27
	find_library(ANDROID_SUPPORT_LIBRARY NAMES support)
28
endif()
29

30
if(MSVC AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
31
	find_library(LIBGCC NAMES gcc)
32
	find_library(LIBMINGWEX NAMES mingwex)
33
endif()
Ghislain MARY's avatar
Ghislain MARY committed
34

35 36 37
find_program(AWK_PROGRAM awk)
if(NOT AWK_PROGRAM)
	message(FATAL_ERROR "You need the awk program to build mediastreamer2.")
38
endif()
39

40
set(BASE_SOURCE_FILES_C
41 42
	base/eventqueue.c
	base/mscommon.c
43
	base/msfactory.c
44 45 46 47
	base/msfilter.c
	base/msqueue.c
	base/mssndcard.c
	base/msticker.c
48
	base/msvideopresets.c
49 50
	base/mswebcam.c
	base/mtu.c
51
	base/msasync.c
52 53 54 55 56
	otherfilters/itc.c
	otherfilters/join.c
	otherfilters/tee.c
	otherfilters/void.c
)
57 58 59
if(ANDROID)
	list(APPEND BASE_SOURCE_FILES_C utils/msjava.c)
endif()
60

61 62
bc_git_version(ms2 ${PROJECT_VERSION})

63 64
add_definitions(
	-D_TRUE_TIME
65
	-DMS2_EXPORTS
66 67
	-DMS2_INTERNAL
	-DMS2_FILTERS
68
	-DBCTBX_LOG_DOMAIN="mediastreamer"
69
)
70

71

72
set(VOIP_SOURCE_FILES_C
73 74 75
	audiofilters/alaw.c
	audiofilters/audiomixer.c
	audiofilters/chanadapt.c
76
	audiofilters/devices.c
77 78
	audiofilters/dtmfgen.c
	audiofilters/equalizer.c
79
	audiofilters/flowcontrol.c
80 81
	audiofilters/g711.c
	audiofilters/g711.h
johan's avatar
johan committed
82
	audiofilters/genericplc.h
83
	audiofilters/genericplc.c
johan's avatar
johan committed
84
	audiofilters/msgenericplc.c
85 86 87
	audiofilters/l16.c
	audiofilters/msfileplayer.c
	audiofilters/msfilerec.c
88 89
	audiofilters/asyncrw.c
	audiofilters/asyncrw.h
90
	audiofilters/msg722.c
91
	audiofilters/msvaddtx.c
92 93 94 95
	audiofilters/msvolume.c
	audiofilters/tonedetector.c
	audiofilters/ulaw.c
	audiofilters/waveheader.h
96
	crypto/dtls_srtp.c
97
	crypto/ms_srtp.c
98
	crypto/zrtp.c
99 100
	otherfilters/msrtp.c
	utils/_kiss_fft_guts.h
101
	utils/audiodiff.c
102 103 104 105 106 107 108 109
	utils/dsptools.c
	utils/g722.h
	utils/g722_decode.c
	utils/g722_encode.c
	utils/kiss_fft.c
	utils/kiss_fft.h
	utils/kiss_fftr.c
	utils/kiss_fftr.h
110 111
	utils/pcap_sender.c
	utils/pcap_sender.h
112
	utils/stream_regulator.c
DanmeiChen's avatar
DanmeiChen committed
113
	utils/srtp_prefix.h
114 115
	voip/audioconference.c
	voip/audiostream.c
116
	voip/bandwidthcontroller.c
117 118 119 120
	voip/bitratecontrol.c
	voip/bitratedriver.c
	voip/ice.c
	voip/mediastream.c
121
	voip/msiframerequestslimiter.c
122
	voip/msmediaplayer.c
123 124 125
	voip/msvoip.c
	voip/private.h
	voip/qosanalyzer.c
126
	voip/qosanalyzer.h
127
	voip/qualityindicator.c
128 129
	otherfilters/rfc4103_source.c
	otherfilters/rfc4103_sink.c
130
	otherfilters/msudp.c
131
	voip/rfc4103_textstream.c
132
	voip/ringstream.c
133
	voip/stun.c
134
)
135
set(VOIP_SOURCE_FILES_CXX
136 137
	utils/filter-wrapper/decoding-filter-wrapper.cpp
	utils/filter-wrapper/encoding-filter-wrapper.cpp
138
)
139
set(VOIP_SOURCE_FILES_OBJC )
140
set(VOIP_SOURCE_FILES_ASM )
141

142
if(ENABLE_ALSA)
143
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/alsa.c)
144
endif()
145 146 147
if(ANDROID)
	list(APPEND VOIP_SOURCE_FILES_CXX voip/msvoip_jni.cc)
endif()
148 149 150 151 152 153 154 155 156 157 158
if(ENABLE_ANDROIDSND)
	list(APPEND VOIP_SOURCE_FILES_CXX
		android/androidsound.cpp
		android/androidsound_depr.cpp
		android/androidsound_opensles.cpp
		android/AudioRecord.cpp
		android/AudioSystem.cpp
		android/AudioTrack.cpp
		android/hardware_echo_canceller.cpp
		android/loader.cpp
		android/String8.cpp
Erwan Croze's avatar
Erwan Croze committed
159 160
		#audiofilters/aac-eld-android.cpp
		#Not working on Android, to be fix
161 162
	)
endif()
163
if(ENABLE_ARTSC)
164
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/arts.c)
165 166
endif()
if(ENABLE_MACSND)
167
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/macsnd.c)
168 169
endif()
if(ENABLE_MACAQSND)
170
	list(APPEND VOIP_SOURCE_FILES_OBJC audiofilters/aqsnd.m)
171 172
endif()
if(ENABLE_OSS)
173
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/oss.c)
174 175
endif()
if(ENABLE_PORTAUDIO)
176
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/pasnd.c)
177 178
endif()
if(ENABLE_PULSEAUDIO)
179
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/pulseaudio.c)
180 181
endif()
if(ENABLE_QSA)
182
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/qsa.c)
183
endif()
184
if(APPLE)
185
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/aac-eld.c)
186 187
endif()
if(IOS)
188
	list(APPEND VOIP_SOURCE_FILES_OBJC audiofilters/msiounit.m)
189
endif()
190

191 192 193
if(ENABLE_G726)
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/g726.c)
endif()
194 195 196
if(BCG729_FOUND AND ENABLE_G729)
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/g729.c)
endif()
197
if(GSM_FOUND)
198
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/gsm.c)
199
endif()
200 201 202
if(BV16_FOUND)
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/bv16.c)
endif()
203
if(OPUS_FOUND)
204
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/msopus.c)
205 206
endif()
if(ENABLE_RESAMPLE)
207
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/msresample.c)
208 209
endif()
if(SPEEX_FOUND)
210 211 212 213
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/msspeex.c)
endif()
if(SPEEXDSP_FOUND)
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/speexec.c)
214
endif()
215

216
if(ENABLE_VIDEO)
217
	list(APPEND VOIP_SOURCE_FILES_C
218
		utils/bits_rw.c
219 220
		videofilters/extdisplay.c
		videofilters/mire.c
221
		videofilters/nowebcam.c
222 223 224 225 226 227
		videofilters/pixconv.c
		videofilters/sizeconv.c
		voip/layouts.c
		voip/layouts.h
		voip/msvideo_neon.c
		voip/msvideo_neon.h
228
		voip/msvideo.c
229
		voip/nowebcam.h
230
		voip/rfc2429.h
231
		voip/video_preset_high_fps.c
Ghislain MARY's avatar
Ghislain MARY committed
232
		voip/videostarter.c
233 234
		voip/videostream.c
	)
235 236 237 238 239 240 241 242 243
	if(FFMPEG_FOUND AND NOT TURBOJPEG_FOUND)
		list(APPEND VOIP_SOURCE_FILES_C
			videofilters/ffmpegnowebcam.c
		)
	elseif(TURBOJPEG_FOUND)
		list(APPEND VOIP_SOURCE_FILES_C
			videofilters/turbojpegnowebcam.c
		)
	endif()
244
	if(WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
245
		add_definitions(-DHAVE_DIRECTSHOW)
246
		list(APPEND VOIP_SOURCE_FILES_C
247 248
			videofilters/drawdib-display.c
		)
249
		list(APPEND VOIP_SOURCE_FILES_CXX
250
			videofilters/msdscap.cc
251
		)
252
	endif()
253
	if(APPLE)
254
		if(IOS)
255
			list(APPEND VOIP_SOURCE_FILES_C
Ronan's avatar
Ronan committed
256 257
				utils/opengl_functions.c
				utils/opengl_functions.h
258 259
				utils/opengles_display.c
				utils/opengles_display.h
Ronan's avatar
Ronan committed
260 261
				utils/shader_util.c
				utils/shader_util.h
262 263 264
				voip/scaler.c
			)
			list(APPEND VOIP_SOURCE_FILES_OBJC
265 266 267 268 269
				videofilters/iosdisplay.m
				videofilters/ioscapture.m
				voip/ioshardware.m
			)
		else()
270
			list(APPEND VOIP_SOURCE_FILES_OBJC
271
				videofilters/msosxdisplay.m
272
				videofilters/avfound-capture.m
273
			)
274

275
			list(APPEND VOIP_SOURCE_FILES_C
Ronan's avatar
Ronan committed
276 277
				utils/opengl_functions.c
				utils/opengl_functions.h
278 279
				utils/opengles_display.c
				utils/opengles_display.h
Ronan's avatar
Ronan committed
280 281
				utils/shader_util.c
				utils/shader_util.h
282 283
			)
		endif()
284
	endif()
285 286 287 288
	if(ANDROID)
		list(APPEND VOIP_SOURCE_FILES_C
			android/android-display.c
			android/android-opengl-display.c
289
			android/android-texture-display.c
Ronan's avatar
Ronan committed
290 291
			utils/opengl_functions.c
			utils/opengl_functions.h
292 293
			utils/opengles_display.c
			utils/opengles_display.h
Ronan's avatar
Ronan committed
294 295
			utils/shader_util.c
			utils/shader_util.h
296 297
			voip/scaler.c
		)
298
		if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a")
299 300 301 302 303 304 305 306 307 308
			list(APPEND VOIP_SOURCE_FILES_ASM
				voip/scaler_arm.S
			)
		endif()
		list(APPEND VOIP_SOURCE_FILES_CXX
			android/android_mediacodec.cpp
			android/android-display-bad.cpp
			android/androidvideo.cpp
		)
	endif()
309
	if (ENABLE_QNX)
310 311 312 313 314
		list(APPEND VOIP_SOURCE_FILES_CXX
			videofilters/bb10_display.cpp
			videofilters/bb10_capture.cpp
		)
	endif()
315
	if(FFMPEG_FOUND)
316
		list(APPEND VOIP_SOURCE_FILES_C
317
			utils/ffmpeg-priv.c
318
			utils/ffmpeg-priv.h
319 320 321 322
			utils/swscale.h
			videofilters/videodec.c
			videofilters/videoenc.c
		)
323 324 325
		list(APPEND VOIP_SOURCE_FILES_CXX
			videofilters/h264dec.cpp
		)
326 327 328 329 330 331 332 333 334 335
		if(NOT TURBOJPEG_FOUND)
			list(APPEND VOIP_SOURCE_FILES_C
				videofilters/ffmpegjpegwriter.c
			)
		endif()
	endif()
	if(TURBOJPEG_FOUND)
		list(APPEND VOIP_SOURCE_FILES_C
			videofilters/turbojpegwriter.c
		)
336 337 338
		if(TURBOJPEG_USE_CONST_BUFFERS)
			set_source_files_properties(videofilters/turbojpegwriter.c PROPERTIES COMPILE_DEFINITIONS "TURBOJPEG_USE_CONST_BUFFERS")
		endif()
339
	endif()
Erwan Croze's avatar
Erwan Croze committed
340 341
	if(ZXING_FOUND)
		list(APPEND VOIP_SOURCE_FILES_CXX
342
			videofilters/zxing_qrcode.cpp
Erwan Croze's avatar
Erwan Croze committed
343 344 345
			utils/qrcode_image.cpp
		)
	endif()
346
	if(OPENGL_FOUND OR QTANGLE_FOUND)
347
		list(APPEND VOIP_SOURCE_FILES_C
Ronan's avatar
Ronan committed
348
			utils/opengl_functions.c
349
			utils/opengles_display.c
Ronan's avatar
Ronan committed
350
			utils/shader_util.c
351
			videofilters/generic_opengl_display.c
352
		)
353
	endif()
354
	if(GLX_FOUND)
355 356 357 358 359 360
		list(APPEND VOIP_SOURCE_FILES_C
			utils/opengl_functions.c
			utils/opengles_display.c
			utils/shader_util.c
			videofilters/glxvideo.c
		)
361
	endif()
Ghislain MARY's avatar
Ghislain MARY committed
362
	if(NOT APPLE AND NOT ANDROID AND OPENGL_FOUND OR GLX_FOUND)
jehan's avatar
jehan committed
363 364
		find_package(Glew REQUIRED)
	endif()
365
	if(SDL_FOUND)
366
		list(APPEND VOIP_SOURCE_FILES_C videofilters/videoout.c)
367 368
	endif()
	if(THEORA_FOUND)
369
		list(APPEND VOIP_SOURCE_FILES_C videofilters/theora.c)
370
	endif()
371 372
	if(V4L_FOUND)
		if(HAVE_LINUX_VIDEODEV_H)
373
			list(APPEND VOIP_SOURCE_FILES_C videofilters/msv4l.c)
374 375
		endif()
		if(HAVE_LINUX_VIDEODEV2_H)
376
			list(APPEND VOIP_SOURCE_FILES_C videofilters/msv4l2.c)
377 378
		endif()
	endif()
379
	if(VPX_FOUND)
380
		list(APPEND VOIP_SOURCE_FILES_C
381 382 383 384 385 386
			videofilters/vp8.c
			voip/vp8rtpfmt.c
			voip/vp8rtpfmt.h
		)
	endif()
	if(X11_FOUND)
387
		list(APPEND VOIP_SOURCE_FILES_C utils/x11_helper.c)
388 389
	endif()
	if(XV_FOUND)
390
		list(APPEND VOIP_SOURCE_FILES_C videofilters/x11video.c)
391 392
	endif()
endif()
393
if(BCMATROSKA2_FOUND)
394 395 396
	list(APPEND VOIP_SOURCE_FILES_C
		utils/mkv_reader.c
		voip/rfc2429.h
397 398 399
	)
	list(APPEND VOIP_SOURCE_FILES_CXX
		videofilters/mkv.cpp
400 401
	)
endif()
402

403
if(PCAP_FOUND)
jehan's avatar
jehan committed
404
	list(APPEND VOIP_SOURCE_FILES_C otherfilters/mspcapfileplayer.c)
405
endif()
406 407 408 409 410 411 412 413 414 415 416 417 418 419

if(ENABLE_VIDEO)
	add_subdirectory(voip/h26x)
endif()

set(VOIP_SOURCE_FILES_ALL ${VOIP_SOURCE_FILES_C} ${VOIP_SOURCE_FILES_CXX} ${VOIP_SOURCE_FILES_OBJC} ${VOIP_SOURCE_FILES_ASM})
set(SOURCE_FILES_ALL ${BASE_SOURCE_FILES_C} ${VOIP_SOURCE_FILES_ALL})

add_custom_target(ms2-basedescs-header
	COMMAND ${CMAKE_COMMAND} -DAWK_PROGRAM=${AWK_PROGRAM} -DAWK_SCRIPTS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../"
		-DINPUT_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR}
		-DTYPE=base -DSOURCE_FILES="${BASE_SOURCE_FILES_C}"
		-P "${CMAKE_CURRENT_SOURCE_DIR}/generate_descs_header.cmake"
	BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/basedescs.h")
420 421 422

add_custom_target(ms2-voipdescs-header
	COMMAND ${CMAKE_COMMAND} -DAWK_PROGRAM=${AWK_PROGRAM} -DAWK_SCRIPTS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../"
423
		-DINPUT_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR}
424
		-DTYPE=voip -DSOURCE_FILES="${VOIP_SOURCE_FILES_ALL}"
425 426
		-P "${CMAKE_CURRENT_SOURCE_DIR}/generate_descs_header.cmake"
	BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/voipdescs.h"
427
)
428

429
if(APPLE OR ANDROID OR OPENGL_FOUND OR GLX_FOUND OR QTANGLE_FOUND)
430
	find_package(PythonInterp REQUIRED)
431 432 433 434 435
	find_program(SED_PROGRAM sed)
	if(NOT SED_PROGRAM)
		message(FATAL_ERROR "You need the sed program to build mediastreamer2.")
	endif()
	add_custom_target(ms2-yuv2rgb-fs-header
436
		COMMAND ${CMAKE_COMMAND} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DSED_PROGRAM=${SED_PROGRAM}
437 438 439 440 441 442
			-DINPUT_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR}
			-DSOURCE_FILE="yuv2rgb.fs"
			-P "${CMAKE_CURRENT_SOURCE_DIR}/generate_yuv2rgb_header.cmake"
		BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/yuv2rgb.fs.h"
	)
	add_custom_target(ms2-yuv2rgb-vs-header
443
		COMMAND ${CMAKE_COMMAND} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DSED_PROGRAM=${SED_PROGRAM}
444 445 446 447 448
			-DINPUT_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR}
			-DSOURCE_FILE="yuv2rgb.vs"
			-P "${CMAKE_CURRENT_SOURCE_DIR}/generate_yuv2rgb_header.cmake"
		BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/yuv2rgb.vs.h"
	)
449
endif()
450

451
bc_apply_compile_flags(BASE_SOURCE_FILES_C STRICT_OPTIONS_CPP STRICT_OPTIONS_C)
452 453
bc_apply_compile_flags(VOIP_SOURCE_FILES_C STRICT_OPTIONS_CPP STRICT_OPTIONS_C)
bc_apply_compile_flags(VOIP_SOURCE_FILES_OBJC STRICT_OPTIONS_CPP STRICT_OPTIONS_OBJC)
454 455
if(VOIP_SOURCE_FILES_CXX)
	set_source_files_properties(${VOIP_SOURCE_FILES_CXX} PROPERTIES LANGUAGE CXX)
456
	bc_apply_compile_flags(VOIP_SOURCE_FILES_CXX STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX)
457
endif()
458

459

460
if(ENABLE_VIDEO AND ANDROID AND CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a")
461 462 463 464
	set(NEON_SOURCE_FILES
		voip/msvideo_neon.c
		voip/scaler.c
	)
465 466 467 468 469 470
endif()


if(VOIP_SOURCE_FILES_ASM)
	get_directory_property(DIRECTORY_PROPERTY_COMPILE_OPTIONS "COMPILE_OPTIONS")
	string(REPLACE ";" " " DIRECTORY_PROPERTY_COMPILE_OPTIONS "${DIRECTORY_PROPERTY_COMPILE_OPTIONS}")
471 472 473 474 475
	set(CMAKE_ASM_TARGET_FLAG "")
	if(CMAKE_C_COMPILER_TARGET)
		set(CMAKE_ASM_TARGET_FLAG "--target=${CMAKE_C_COMPILER_TARGET}")
	endif()
	set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> ${CMAKE_ASM_TARGET_FLAG} ${CMAKE_CPP_FLAGS} ${CMAKE_C_FLAGS} ${DIRECTORY_PROPERTY_COMPILE_OPTIONS} ${ARCH_OPTIONS} -o <OBJECT> -c <SOURCE>")
476 477 478 479
	enable_language(ASM)
endif()


480
set(VOIP_LIBS
481
	${BCTOOLBOX_CORE_LIBRARIES}
482
	${ORTP_LIBRARIES}
483
)
484
if(WIN32)
485
	if(NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
Ghislain MARY's avatar
Ghislain MARY committed
486
		list(APPEND VOIP_LIBS ${LIBGCC} ${LIBMINGWEX} ole32 oleaut32 uuid Winmm Ws2_32)
487
		if(ENABLE_VIDEO)
488
			list(APPEND VOIP_LIBS gdi32 strmiids user32 vfw32)
489
		endif()
490
	endif()
491
endif()
492 493 494
if(LIBM)
	list(APPEND VOIP_LIBS ${LIBM})
endif()
495 496 497
if(ANDROID_CPU_FEATURES_LIBRARY)
	list(APPEND VOIP_LIBS ${ANDROID_CPU_FEATURES_LIBRARY})
endif()
498 499 500
if(ANDROID_SUPPORT_LIBRARY)
	list(APPEND VOIP_LIBS ${ANDROID_SUPPORT_LIBRARY})
endif()
501
if(ANDROID AND ENABLE_VIDEO)
502
	list(APPEND VOIP_LIBS EGL GLESv2 android)
503
endif()
504 505 506
if(HAVE_DLOPEN)
	list(APPEND VOIP_LIBS dl)
endif()
507 508 509
if(PCAP_FOUND)
	list(APPEND VOIP_LIBS ${PCAP_LIBRARIES})
endif()
510 511 512
if(BZRTP_FOUND)
	list(APPEND VOIP_LIBS ${BZRTP_LIBRARIES})
endif()
513 514 515
if(SRTP_FOUND)
	list(APPEND VOIP_LIBS ${SRTP_LIBRARIES})
endif()
516 517 518
if(SPANDSP_FOUND)
	list(APPEND VOIP_LIBS ${SPANDSP_LIBRARIES})
endif()
519 520 521 522 523 524 525 526 527
if(GSM_FOUND)
	list(APPEND VOIP_LIBS ${GSM_LIBRARIES})
endif()
if(OPUS_FOUND)
	list(APPEND VOIP_LIBS ${OPUS_LIBRARIES})
endif()
if(SPEEX_FOUND)
	list(APPEND VOIP_LIBS ${SPEEX_LIBRARIES})
endif()
528 529 530
if(SPEEXDSP_FOUND)
	list(APPEND VOIP_LIBS ${SPEEXDSP_LIBRARIES})
endif()
531 532 533
if(BV16_FOUND)
	list(APPEND VOIP_LIBS ${BV16_LIBRARIES})
endif()
534 535 536 537 538 539 540 541 542 543 544 545 546 547
if(ALSA_FOUND)
	list(APPEND VOIP_LIBS ${ALSA_LIBRARIES})
endif()
if(ARTS_FOUND)
	list(APPEND VOIP_LIBS ${ARTS_LIBRARIES})
endif()
if(PORTAUDIO_FOUND)
	list(APPEND VOIP_LIBS ${PORTAUDIO_LIBRARIES})
endif()
if(PULSEAUDIO_FOUND)
	list(APPEND VOIP_LIBS ${PULSEAUDIO_LIBRARIES})
endif()
if(QSA_FOUND)
	list(APPEND VOIP_LIBS ${QSA_LIBRARIES})
548
	list(APPEND VOIP_LIBS ${QNXAUDIOMANAGER_LIBRARIES})
549 550 551 552 553 554 555
endif()
if(FFMPEG_FOUND)
	list(APPEND VOIP_LIBS ${FFMPEG_LIBRARIES})
	if(MSVC)
		add_definitions(-Dinline=__inline)
	endif()
endif()
556 557 558
if(V4L_FOUND)
	list(APPEND VOIP_LIBS ${V4L_LIBRARIES})
endif()
559 560 561 562 563 564 565 566 567
if(X11_FOUND)
	list(APPEND VOIP_LIBS ${X11_LIBRARIES})
endif()
if(XV_FOUND)
	list(APPEND VOIP_LIBS ${XV_LIBRARIES})
endif()
if(GLX_FOUND)
	list(APPEND VOIP_LIBS ${GLX_LIBRARIES})
endif()
jehan's avatar
jehan committed
568 569 570
if(GLEW_FOUND)
	list(APPEND VOIP_LIBS ${GLEW_LIBRARIES})
endif()
571 572 573
if(THEORA_FOUND)
	list(APPEND VOIP_LIBS ${THEORA_LIBRARIES})
endif()
574 575 576
if(VPX_FOUND)
	list(APPEND VOIP_LIBS ${VPX_LIBRARIES})
endif()
577 578
if(BCMATROSKA2_FOUND)
	list(APPEND VOIP_LIBS ${BCMATROSKA2_LIBRARIES})
579
endif()
580 581 582 583 584
if (SCREEN_FOUND)
	list(APPEND VOIP_LIBS ${SCREEN_LIBRARIES})
endif()
if (CAMAPI_FOUND)
	list(APPEND VOIP_LIBS ${CAMAPI_LIBRARIES})
585
endif()
586 587 588
if(TURBOJPEG_FOUND)
	list(APPEND VOIP_LIBS ${TURBOJPEG_LIBRARIES})
endif()
Erwan Croze's avatar
Erwan Croze committed
589 590 591
if(ZXING_FOUND)
	list(APPEND VOIP_LIBS ${ZXING_LIBRARIES})
endif()
592 593 594 595
if(BCG729_FOUND)
	if(ENABLE_G729_CNG)
		add_definitions("-DHAVE_G729B=1")
	endif()
jehan's avatar
jehan committed
596 597
	list(APPEND VOIP_LIBS ${BCG729_LIBRARIES})
endif()
598
set(MS2_DEPENDENCIES ms2-git-version ms2-basedescs-header ms2-voipdescs-header)
599
if(APPLE OR ANDROID OR OPENGL_FOUND OR GLX_FOUND OR QTANGLE_FOUND)
600
	list(APPEND MS2_DEPENDENCIES ms2-yuv2rgb-fs-header ms2-yuv2rgb-vs-header)
601 602 603
endif()

string(REPLACE ";" " " LINK_FLAGS_STR "${LINK_FLAGS}")
604
if(ENABLE_STATIC)
605 606
	add_library(mediastreamer-static STATIC ${MEDIASTREAMER2_HEADER_FILES} ${SOURCE_FILES_ALL})
	set_target_properties(mediastreamer-static PROPERTIES OUTPUT_NAME mediastreamer)
607
	if(LINK_FLAGS_STR)
608
		set_target_properties(mediastreamer-static PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
609
	endif()
610 611 612 613
	add_dependencies(mediastreamer-static ${MS2_DEPENDENCIES})
	target_include_directories(mediastreamer-static PUBLIC ${MEDIASTREAMER2_INCLUDE_DIRS})
	target_link_libraries(mediastreamer-static INTERFACE ${VOIP_LIBS})
	install(TARGETS mediastreamer-static EXPORT ${EXPORT_TARGETS_NAME}Targets
614 615 616 617 618
		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
		PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
	)
endif()
if(ENABLE_SHARED)
619 620
	add_library(mediastreamer SHARED ${MEDIASTREAMER2_HEADER_FILES} ${SOURCE_FILES_ALL})
	set_target_properties(mediastreamer PROPERTIES LINKER_LANGUAGE CXX)
621
	if(LINK_FLAGS_STR)
622
		set_target_properties(mediastreamer PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
623
	endif()
624
	add_dependencies(mediastreamer ${MS2_DEPENDENCIES})
625
	#TODO: replace by if(APPLE) when we want to make apple framework on linphone-desktop too
626
	if(IOS)
627 628 629 630 631 632
		if(IOS)
			set(MIN_OS ${LINPHONE_IOS_DEPLOYMENT_TARGET})
		else()
			set(MIN_OS ${CMAKE_OSX_DEPLOYMENT_TARGET})
		endif()
		set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/build/osx/")
633 634 635 636 637
		# According to Apple documentation (https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/IncludingFrameworks.html),
		# framework header files must be included in application code using the #include directive using the followin patern: #include <Framework_name/Header_filename.h>,
		# so name the framework mediastreamer2 instead of mediastreamer.
		set_target_properties(mediastreamer PROPERTIES OUTPUT_NAME mediastreamer2)
		set_target_properties(mediastreamer PROPERTIES
638
			FRAMEWORK TRUE
639 640 641
			MACOSX_FRAMEWORK_IDENTIFIER org.linphone.mediastreamer2
  			MACOSX_FRAMEWORK_INFO_PLIST Info.plist.in
			PUBLIC_HEADER "${MEDIASTREAMER2_HEADER_FILES}"
642
		)
643
	endif()
Sylvain Berfini's avatar
Sylvain Berfini committed
644
	if(ANDROID)
645
		if(ENABLE_VPX)
646
			set_target_properties(mediastreamer PROPERTIES LINK_FLAGS "-Wl,--exclude-libs,libvpx.a")
647 648
		endif()
	else()
649
		# Do not version shared library on Android
650
		set_target_properties(mediastreamer PROPERTIES SOVERSION ${MEDIASTREAMER_SO_VERSION})
651
	endif()
652 653
	target_include_directories(mediastreamer PUBLIC ${MEDIASTREAMER2_INCLUDE_DIRS})
	target_link_libraries(mediastreamer PRIVATE ${VOIP_LIBS})
654
	if(IOS)
655
		target_link_libraries(mediastreamer INTERFACE "-framework Foundation" "-framework AVFoundation")
656
	endif()
657
	if(MSVC)
658
		if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
659
			install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/mediastreamer.pdb
660
				DESTINATION ${CMAKE_INSTALL_BINDIR}
661 662 663 664
				PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
			)
		endif()
	endif()
665
	install(TARGETS mediastreamer EXPORT ${EXPORT_TARGETS_NAME}Targets
666 667 668
		RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
		LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
669
		FRAMEWORK DESTINATION Frameworks
670 671
		PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
	)
672 673
endif()

674
if(FFMPEG_FOUND AND NOT WIN32)
675
	set(NO_DEPRECATED_DECLARATIONS_SOURCE_FILES
676
		videofilters/videoenc.c
677
		videofilters/videodec.c
678
		videofilters/h264dec.cpp
679
	)
680 681 682 683 684 685 686
	if(NOT TURBOJPEG_FOUND)
		set(NO_DEPRECATED_DECLARATIONS_SOURCE_FILES
			${NO_DEPRECATED_DECLARATIONS_SOURCE_FILES}
			videofilters/ffmpegjpegwriter.c
			videofilters/nowebcam.c
		)
	endif()
687 688 689 690
	foreach(file ${NO_DEPRECATED_DECLARATIONS_SOURCE_FILES})
		get_source_file_property(NO_DEPRECATED_DECLARATIONS_COMPILE_FLAGS ${file} COMPILE_FLAGS)
		set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS "${NO_DEPRECATED_DECLARATIONS_COMPILE_FLAGS} -Wno-error=deprecated-declarations")
	endforeach()
691 692
endif()

693 694 695 696 697
if(ENABLE_VIDEO)
	install(FILES voip/nowebcamCIF.jpg
		DESTINATION ${PACKAGE_DATA_DIR}/images
        PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
	)
698
endif()