CMakeLists.txt 22 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
if(ANDROID)
	find_library(ANDROID_CPU_FEATURES_LIBRARY NAMES cpufeatures)
26
	find_library(ANDROID_SUPPORT_LIBRARY NAMES support)
27
endif()
28

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

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

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

60 61
bc_git_version(ms2 ${PROJECT_VERSION})

62 63
add_custom_target(ms2-basedescs-header
	COMMAND ${CMAKE_COMMAND} -DAWK_PROGRAM=${AWK_PROGRAM} -DAWK_SCRIPTS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../"
64
		-DINPUT_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR}
65
		-DTYPE=base -DSOURCE_FILES="${BASE_SOURCE_FILES_C}"
66 67
		-P "${CMAKE_CURRENT_SOURCE_DIR}/generate_descs_header.cmake"
	BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/basedescs.h")
68 69 70

add_definitions(
	-D_TRUE_TIME
71
	-DMS2_EXPORTS
72 73
	-DMS2_INTERNAL
	-DMS2_FILTERS
74
	-DBCTBX_LOG_DOMAIN="mediastreamer"
75
)
76

77
set(BASE_LIBS
78
	${BCTOOLBOX_CORE_LIBRARIES} ${ORTP_LIBRARIES}
79
)
80
if(WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
81
	list(APPEND BASE_LIBS ${LIBGCC} ${LIBMINGWEX} ole32 oleaut32 uuid Winmm Ws2_32)
82 83 84 85
endif()
if(HAVE_DLOPEN)
	list(APPEND BASE_LIBS dl)
endif()
86

87
bc_apply_compile_flags(BASE_SOURCE_FILES_C STRICT_OPTIONS_CPP STRICT_OPTIONS_C)
88

89
if(ENABLE_STATIC)
90
	add_library(mediastreamer_base-static STATIC ${MEDIASTREAMER2_HEADER_FILES} ${BASE_SOURCE_FILES_C})
91
	set_target_properties(mediastreamer_base-static PROPERTIES OUTPUT_NAME mediastreamer_base)
92 93
	target_include_directories(mediastreamer_base-static PUBLIC ${MEDIASTREAMER2_INCLUDE_DIRS})
	target_link_libraries(mediastreamer_base-static INTERFACE ${BASE_LIBS})
94
	add_dependencies(mediastreamer_base-static ms2-git-version ms2-basedescs-header)
95 96 97 98 99 100
	install(TARGETS mediastreamer_base-static EXPORT ${EXPORT_TARGETS_NAME}Targets
		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
		PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
	)
endif()
if(ENABLE_SHARED)
101
	add_library(mediastreamer_base SHARED ${MEDIASTREAMER2_HEADER_FILES} ${BASE_SOURCE_FILES_C})
102
	set_target_properties(mediastreamer_base PROPERTIES LINKER_LANGUAGE C)
103
	if(IOS)
104 105 106 107 108 109
		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/")
110 111
		set_target_properties(mediastreamer_base PROPERTIES
			FRAMEWORK TRUE
112 113
			MACOSX_FRAMEWORK_IDENTIFIER org.linphone.mediastreamerbase
  			MACOSX_FRAMEWORK_INFO_PLIST Info_base.plist.in
114 115 116
			PUBLIC_HEADER "${MEDIASTREAMER2_HEADER_FILES}"
		) 
	endif()
117
	if(NOT ANDROID)
118 119
		# Do not version shared library on Android
		set_target_properties(mediastreamer_base PROPERTIES SOVERSION ${MEDIASTREAMER_SO_VERSION})
120
	endif()
121
	target_include_directories(mediastreamer_base PUBLIC ${MEDIASTREAMER2_INCLUDE_DIRS})
122
	target_link_libraries(mediastreamer_base PRIVATE ${BASE_LIBS})
123
	add_dependencies(mediastreamer_base ms2-git-version ms2-basedescs-header)
124
	if(MSVC)
125 126
		if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
			install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/mediastreamer_base.pdb
127
				DESTINATION ${CMAKE_INSTALL_BINDIR}
128 129 130 131
				PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
			)
		endif()
	endif()
132 133 134 135
	install(TARGETS mediastreamer_base EXPORT ${EXPORT_TARGETS_NAME}Targets
		RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
		LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
136
		FRAMEWORK DESTINATION Frameworks
137 138
		PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
	)
139
endif()
140 141 142



143
set(VOIP_SOURCE_FILES_C
144 145 146
	audiofilters/alaw.c
	audiofilters/audiomixer.c
	audiofilters/chanadapt.c
147
	audiofilters/devices.c
148 149
	audiofilters/dtmfgen.c
	audiofilters/equalizer.c
150
	audiofilters/flowcontrol.c
151 152
	audiofilters/g711.c
	audiofilters/g711.h
johan's avatar
johan committed
153
	audiofilters/genericplc.h
154
	audiofilters/genericplc.c
johan's avatar
johan committed
155
	audiofilters/msgenericplc.c
156 157 158
	audiofilters/l16.c
	audiofilters/msfileplayer.c
	audiofilters/msfilerec.c
159 160
	audiofilters/asyncrw.c
	audiofilters/asyncrw.h
161
	audiofilters/msg722.c
162
	audiofilters/msvaddtx.c
163 164 165 166
	audiofilters/msvolume.c
	audiofilters/tonedetector.c
	audiofilters/ulaw.c
	audiofilters/waveheader.h
167
	crypto/dtls_srtp.c
168
	crypto/ms_srtp.c
169
	crypto/zrtp.c
170 171
	otherfilters/msrtp.c
	utils/_kiss_fft_guts.h
172
	utils/audiodiff.c
173 174 175 176
	utils/dsptools.c
	utils/g722.h
	utils/g722_decode.c
	utils/g722_encode.c
177 178
	utils/h264utils.h
	utils/h264utils.c
179 180 181 182
	utils/kiss_fft.c
	utils/kiss_fft.h
	utils/kiss_fftr.c
	utils/kiss_fftr.h
183 184
	utils/pcap_sender.c
	utils/pcap_sender.h
185
	utils/stream_regulator.c
186 187
	voip/audioconference.c
	voip/audiostream.c
188
	voip/bandwidthcontroller.c
189 190 191 192
	voip/bitratecontrol.c
	voip/bitratedriver.c
	voip/ice.c
	voip/mediastream.c
193
	voip/msiframerequestslimiter.c
194
	voip/msmediaplayer.c
195 196 197
	voip/msvoip.c
	voip/private.h
	voip/qosanalyzer.c
198
	voip/qosanalyzer.h
199
	voip/qualityindicator.c
200 201
	otherfilters/rfc4103_source.c
	otherfilters/rfc4103_sink.c
202
	otherfilters/msudp.c
203
	voip/rfc4103_textstream.c
204
	voip/ringstream.c
205
	voip/stun.c
206
)
207 208
set(VOIP_SOURCE_FILES_CXX )
set(VOIP_SOURCE_FILES_OBJC )
209
set(VOIP_SOURCE_FILES_ASM )
210

211
if(ENABLE_ALSA)
212
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/alsa.c)
213
endif()
214 215 216
if(ANDROID)
	list(APPEND VOIP_SOURCE_FILES_CXX voip/msvoip_jni.cc)
endif()
217 218 219 220 221 222 223 224 225 226 227
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
228 229
		#audiofilters/aac-eld-android.cpp
		#Not working on Android, to be fix
230 231
	)
endif()
232
if(ENABLE_ARTSC)
233
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/arts.c)
234 235
endif()
if(ENABLE_MACSND)
236
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/macsnd.c)
237 238
endif()
if(ENABLE_MACAQSND)
239
	list(APPEND VOIP_SOURCE_FILES_OBJC audiofilters/aqsnd.m)
240 241
endif()
if(ENABLE_OSS)
242
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/oss.c)
243 244
endif()
if(ENABLE_PORTAUDIO)
245
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/pasnd.c)
246 247
endif()
if(ENABLE_PULSEAUDIO)
248
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/pulseaudio.c)
249 250
endif()
if(ENABLE_QSA)
251
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/qsa.c)
252
endif()
253
if(APPLE)
254
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/aac-eld.c)
255 256
endif()
if(IOS)
257
	list(APPEND VOIP_SOURCE_FILES_OBJC audiofilters/msiounit.m)
258
endif()
259

260 261 262
if(ENABLE_G726)
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/g726.c)
endif()
263 264 265
if(BCG729_FOUND AND ENABLE_G729)
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/g729.c)
endif()
266
if(GSM_FOUND)
267
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/gsm.c)
268
endif()
269 270 271
if(BV16_FOUND)
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/bv16.c)
endif()
272
if(OPUS_FOUND)
273
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/msopus.c)
274 275
endif()
if(ENABLE_RESAMPLE)
276
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/msresample.c)
277 278
endif()
if(SPEEX_FOUND)
279 280 281 282
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/msspeex.c)
endif()
if(SPEEXDSP_FOUND)
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/speexec.c)
283
endif()
284

285
if(ENABLE_VIDEO)
286
	list(APPEND VOIP_SOURCE_FILES_C
287
		utils/bits_rw.c
288 289
		videofilters/extdisplay.c
		videofilters/mire.c
290
		videofilters/nowebcam.c
291 292 293 294 295 296 297
		videofilters/pixconv.c
		videofilters/sizeconv.c
		voip/layouts.c
		voip/layouts.h
		voip/msvideo.c
		voip/msvideo_neon.c
		voip/msvideo_neon.h
298
		voip/nowebcam.h
299 300
		voip/rfc2429.h
		voip/rfc3984.c
Ghislain MARY's avatar
Ghislain MARY committed
301
		voip/videostarter.c
302
		voip/videostream.c
303
		voip/video_preset_high_fps.c
304
	)
305 306 307 308 309 310 311 312 313
	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()
314
	if(WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
315
		add_definitions(-DHAVE_DIRECTSHOW)
316
		list(APPEND VOIP_SOURCE_FILES_C
317 318
			videofilters/drawdib-display.c
		)
319
		list(APPEND VOIP_SOURCE_FILES_CXX
320
			videofilters/msdscap.cc
321
		)
322
	endif()
323
	if(APPLE)
324
		if(IOS)
325
			list(APPEND VOIP_SOURCE_FILES_C
Ronan's avatar
Ronan committed
326 327
				utils/opengl_functions.c
				utils/opengl_functions.h
328 329
				utils/opengles_display.c
				utils/opengles_display.h
Ronan's avatar
Ronan committed
330 331
				utils/shader_util.c
				utils/shader_util.h
332 333 334
				voip/scaler.c
			)
			list(APPEND VOIP_SOURCE_FILES_OBJC
335 336 337 338 339
				videofilters/iosdisplay.m
				videofilters/ioscapture.m
				voip/ioshardware.m
			)
		else()
340
			list(APPEND VOIP_SOURCE_FILES_OBJC
341
				videofilters/msosxdisplay.m
342
				videofilters/avfound-capture.m
343
			)
344

345
			list(APPEND VOIP_SOURCE_FILES_C
Ronan's avatar
Ronan committed
346 347
				utils/opengl_functions.c
				utils/opengl_functions.h
348 349
				utils/opengles_display.c
				utils/opengles_display.h
Ronan's avatar
Ronan committed
350 351
				utils/shader_util.c
				utils/shader_util.h
352 353
			)
		endif()
354
	endif()
355
	if(APPLE)
François Grisez's avatar
François Grisez committed
356
		list(APPEND VOIP_SOURCE_FILES_C videofilters/videotoolbox.c)
357
	endif()
358 359 360 361 362 363
	if(ANDROID)
		list(APPEND VOIP_SOURCE_FILES_C
			android/mediacodech264dec.c
			android/mediacodech264enc.c
			android/android-display.c
			android/android-opengl-display.c
Ronan's avatar
Ronan committed
364 365
			utils/opengl_functions.c
			utils/opengl_functions.h
366 367
			utils/opengles_display.c
			utils/opengles_display.h
Ronan's avatar
Ronan committed
368 369
			utils/shader_util.c
			utils/shader_util.h
370 371
			voip/scaler.c
		)
372
		if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a")
373 374 375 376 377 378 379 380 381 382
			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()
383
	if (ENABLE_QNX)
384 385 386 387 388
		list(APPEND VOIP_SOURCE_FILES_CXX
			videofilters/bb10_display.cpp
			videofilters/bb10_capture.cpp
		)
	endif()
389
	if(FFMPEG_FOUND)
390
		list(APPEND VOIP_SOURCE_FILES_C
391
			utils/ffmpeg-priv.c
392
			utils/ffmpeg-priv.h
393 394 395 396 397
			utils/swscale.h
			videofilters/h264dec.c
			videofilters/videodec.c
			videofilters/videoenc.c
		)
398 399 400 401 402 403 404 405 406 407
		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
		)
408 409 410
		if(TURBOJPEG_USE_CONST_BUFFERS)
			set_source_files_properties(videofilters/turbojpegwriter.c PROPERTIES COMPILE_DEFINITIONS "TURBOJPEG_USE_CONST_BUFFERS")
		endif()
411
	endif()
412
	if(OPENGL_FOUND OR QTANGLE_FOUND)
413
		list(APPEND VOIP_SOURCE_FILES_C
Ronan's avatar
Ronan committed
414
			utils/opengl_functions.c
415
			utils/opengles_display.c
Ronan's avatar
Ronan committed
416
			utils/shader_util.c
417
			videofilters/generic_opengl_display.c
418
		)
419
	endif()
420
	if(GLX_FOUND)
421 422 423 424 425 426
		list(APPEND VOIP_SOURCE_FILES_C
			utils/opengl_functions.c
			utils/opengles_display.c
			utils/shader_util.c
			videofilters/glxvideo.c
		)
427
	endif()
Ghislain MARY's avatar
Ghislain MARY committed
428
	if(NOT APPLE AND NOT ANDROID AND OPENGL_FOUND OR GLX_FOUND)
jehan's avatar
jehan committed
429 430
		find_package(Glew REQUIRED)
	endif()
431
	if(SDL_FOUND)
432
		list(APPEND VOIP_SOURCE_FILES_C videofilters/videoout.c)
433 434
	endif()
	if(THEORA_FOUND)
435
		list(APPEND VOIP_SOURCE_FILES_C videofilters/theora.c)
436
	endif()
437 438
	if(V4L_FOUND)
		if(HAVE_LINUX_VIDEODEV_H)
439
			list(APPEND VOIP_SOURCE_FILES_C videofilters/msv4l.c)
440 441
		endif()
		if(HAVE_LINUX_VIDEODEV2_H)
442
			list(APPEND VOIP_SOURCE_FILES_C videofilters/msv4l2.c)
443 444
		endif()
	endif()
445
	if(VPX_FOUND)
446
		list(APPEND VOIP_SOURCE_FILES_C
447 448 449 450 451 452
			videofilters/vp8.c
			voip/vp8rtpfmt.c
			voip/vp8rtpfmt.h
		)
	endif()
	if(X11_FOUND)
453
		list(APPEND VOIP_SOURCE_FILES_C utils/x11_helper.c)
454 455
	endif()
	if(XV_FOUND)
456
		list(APPEND VOIP_SOURCE_FILES_C videofilters/x11video.c)
457 458
	endif()
endif()
459
if(BCMATROSKA2_FOUND)
460 461 462 463 464 465 466
	list(APPEND VOIP_SOURCE_FILES_C
		videofilters/mkv.c
		utils/mkv_reader.c
		voip/rfc2429.h
		voip/rfc3984.c
	)
endif()
467

468
if(PCAP_FOUND)
jehan's avatar
jehan committed
469
	list(APPEND VOIP_SOURCE_FILES_C otherfilters/mspcapfileplayer.c)
470
endif()
471
set(VOIP_SOURCE_FILES_ALL ${VOIP_SOURCE_FILES_C} ${VOIP_SOURCE_FILES_CXX} ${VOIP_SOURCE_FILES_OBJC})
472 473 474

add_custom_target(ms2-voipdescs-header
	COMMAND ${CMAKE_COMMAND} -DAWK_PROGRAM=${AWK_PROGRAM} -DAWK_SCRIPTS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../"
475
		-DINPUT_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR}
476
		-DTYPE=voip -DSOURCE_FILES="${VOIP_SOURCE_FILES_ALL}"
477 478
		-P "${CMAKE_CURRENT_SOURCE_DIR}/generate_descs_header.cmake"
	BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/voipdescs.h"
479
)
480

481
if(APPLE OR ANDROID OR OPENGL_FOUND OR GLX_FOUND OR QTANGLE_FOUND)
482
	find_package(PythonInterp REQUIRED)
483 484 485 486 487
	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
488
		COMMAND ${CMAKE_COMMAND} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DSED_PROGRAM=${SED_PROGRAM}
489 490 491 492 493 494
			-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
495
		COMMAND ${CMAKE_COMMAND} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DSED_PROGRAM=${SED_PROGRAM}
496 497 498 499 500
			-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"
	)
501
endif()
502

503 504
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)
505 506
if(VOIP_SOURCE_FILES_CXX)
	set_source_files_properties(${VOIP_SOURCE_FILES_CXX} PROPERTIES LANGUAGE CXX)
507
	bc_apply_compile_flags(VOIP_SOURCE_FILES_CXX STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX)
508
endif()
509

510

511
if(ENABLE_VIDEO AND ANDROID AND CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a")
512 513 514 515
	set(NEON_SOURCE_FILES
		voip/msvideo_neon.c
		voip/scaler.c
	)
516 517 518 519 520 521
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}")
522 523 524 525 526
	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>")
527 528 529 530
	enable_language(ASM)
endif()


531
set(VOIP_LIBS
532
	${BCTOOLBOX_CORE_LIBRARIES}
533
	${ORTP_LIBRARIES}
534
)
535
if(WIN32)
536
	if(NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
Ghislain MARY's avatar
Ghislain MARY committed
537
		list(APPEND VOIP_LIBS ${LIBGCC} ${LIBMINGWEX} ole32 oleaut32 uuid Winmm Ws2_32)
538
		if(ENABLE_VIDEO)
539
			list(APPEND VOIP_LIBS gdi32 strmiids user32 vfw32)
540
		endif()
541
	endif()
542
endif()
543 544 545
if(LIBM)
	list(APPEND VOIP_LIBS ${LIBM})
endif()
546 547 548
if(ANDROID_CPU_FEATURES_LIBRARY)
	list(APPEND VOIP_LIBS ${ANDROID_CPU_FEATURES_LIBRARY})
endif()
549 550 551
if(ANDROID_SUPPORT_LIBRARY)
	list(APPEND VOIP_LIBS ${ANDROID_SUPPORT_LIBRARY})
endif()
552 553 554
if(ANDROID AND ENABLE_VIDEO)
	list(APPEND VOIP_LIBS GLESv2)
endif()
555 556 557
if(HAVE_DLOPEN)
	list(APPEND VOIP_LIBS dl)
endif()
558 559 560
if(PCAP_FOUND)
	list(APPEND VOIP_LIBS ${PCAP_LIBRARIES})
endif()
561 562 563
if(BZRTP_FOUND)
	list(APPEND VOIP_LIBS ${BZRTP_LIBRARIES})
endif()
564 565 566
if(SRTP_FOUND)
	list(APPEND VOIP_LIBS ${SRTP_LIBRARIES})
endif()
567 568 569
if(SPANDSP_FOUND)
	list(APPEND VOIP_LIBS ${SPANDSP_LIBRARIES})
endif()
570 571 572 573 574 575 576 577 578
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()
579 580 581
if(SPEEXDSP_FOUND)
	list(APPEND VOIP_LIBS ${SPEEXDSP_LIBRARIES})
endif()
582 583 584
if(BV16_FOUND)
	list(APPEND VOIP_LIBS ${BV16_LIBRARIES})
endif()
585 586 587 588 589 590 591 592 593 594 595 596 597 598
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})
599
	list(APPEND VOIP_LIBS ${QNXAUDIOMANAGER_LIBRARIES})
600 601 602 603 604 605 606
endif()
if(FFMPEG_FOUND)
	list(APPEND VOIP_LIBS ${FFMPEG_LIBRARIES})
	if(MSVC)
		add_definitions(-Dinline=__inline)
	endif()
endif()
607 608 609
if(V4L_FOUND)
	list(APPEND VOIP_LIBS ${V4L_LIBRARIES})
endif()
610 611 612 613 614 615 616 617 618
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
619 620 621
if(GLEW_FOUND)
	list(APPEND VOIP_LIBS ${GLEW_LIBRARIES})
endif()
622 623 624
if(THEORA_FOUND)
	list(APPEND VOIP_LIBS ${THEORA_LIBRARIES})
endif()
625 626 627
if(VPX_FOUND)
	list(APPEND VOIP_LIBS ${VPX_LIBRARIES})
endif()
628 629
if(BCMATROSKA2_FOUND)
	list(APPEND VOIP_LIBS ${BCMATROSKA2_LIBRARIES})
630
endif()
631 632 633 634 635
if (SCREEN_FOUND)
	list(APPEND VOIP_LIBS ${SCREEN_LIBRARIES})
endif()
if (CAMAPI_FOUND)
	list(APPEND VOIP_LIBS ${CAMAPI_LIBRARIES})
636
endif()
637 638 639
if(TURBOJPEG_FOUND)
	list(APPEND VOIP_LIBS ${TURBOJPEG_LIBRARIES})
endif()
640 641 642 643
if(BCG729_FOUND)
	if(ENABLE_G729_CNG)
		add_definitions("-DHAVE_G729B=1")
	endif()
jehan's avatar
jehan committed
644 645
	list(APPEND VOIP_LIBS ${BCG729_LIBRARIES})
endif()
646
set(MS2_VOIP_DEPENDENCIES ms2-git-version ms2-voipdescs-header)
647
if(APPLE OR ANDROID OR OPENGL_FOUND OR GLX_FOUND OR QTANGLE_FOUND)
648
	list(APPEND MS2_VOIP_DEPENDENCIES ms2-yuv2rgb-fs-header ms2-yuv2rgb-vs-header)
649 650 651
endif()

string(REPLACE ";" " " LINK_FLAGS_STR "${LINK_FLAGS}")
652
if(ENABLE_STATIC)
653
	add_library(mediastreamer_voip-static STATIC ${MEDIASTREAMER2_HEADER_FILES} ${VOIP_SOURCE_FILES_C} ${VOIP_SOURCE_FILES_CXX} ${VOIP_SOURCE_FILES_OBJC} ${VOIP_SOURCE_FILES_ASM})
654 655 656 657
	set_target_properties(mediastreamer_voip-static PROPERTIES OUTPUT_NAME mediastreamer_voip)
	if(LINK_FLAGS_STR)
		set_target_properties(mediastreamer_voip-static PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
	endif()
658
	add_dependencies(mediastreamer_voip-static ${MS2_VOIP_DEPENDENCIES})
659 660
	target_include_directories(mediastreamer_voip-static PUBLIC ${MEDIASTREAMER2_INCLUDE_DIRS})
	target_link_libraries(mediastreamer_voip-static INTERFACE mediastreamer_base-static ${VOIP_LIBS})
661 662 663 664 665 666
	install(TARGETS mediastreamer_voip-static EXPORT ${EXPORT_TARGETS_NAME}Targets
		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
		PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
	)
endif()
if(ENABLE_SHARED)
667
	add_library(mediastreamer_voip SHARED ${MEDIASTREAMER2_HEADER_FILES} ${VOIP_SOURCE_FILES_C} ${VOIP_SOURCE_FILES_CXX} ${VOIP_SOURCE_FILES_OBJC} ${VOIP_SOURCE_FILES_ASM})
668
	set_target_properties(mediastreamer_voip PROPERTIES LINKER_LANGUAGE CXX)
669 670 671
	if(LINK_FLAGS_STR)
		set_target_properties(mediastreamer_voip PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
	endif()
672
	add_dependencies(mediastreamer_voip ${MS2_VOIP_DEPENDENCIES})
673
	if(IOS)
674 675 676 677 678 679
		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/")
680 681
		set_target_properties(mediastreamer_voip PROPERTIES
			FRAMEWORK TRUE
682 683
			MACOSX_FRAMEWORK_IDENTIFIER org.linphone.mediastreamervoip
  			MACOSX_FRAMEWORK_INFO_PLIST Info_voip.plist.in
684 685 686
			PUBLIC_HEADER "${MEDIASTREAMER2_HEADER_FILES}"
		) 
	endif()
687
	if(NOT ANDROID)
688 689
		# Do not version shared library on Android
		set_target_properties(mediastreamer_voip PROPERTIES SOVERSION ${MEDIASTREAMER_SO_VERSION})
690
	endif()
691
	target_include_directories(mediastreamer_voip PUBLIC ${MEDIASTREAMER2_INCLUDE_DIRS})
692
	target_link_libraries(mediastreamer_voip PRIVATE mediastreamer_base ${VOIP_LIBS})
693 694 695
	if(IOS)
		target_link_libraries(mediastreamer_voip INTERFACE "-framework Foundation" "-framework AVFoundation")
	endif()
696
	if(MSVC)
697 698
		if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
			install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/mediastreamer_voip.pdb
699
				DESTINATION ${CMAKE_INSTALL_BINDIR}
700 701 702 703
				PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
			)
		endif()
	endif()
704 705 706 707
	install(TARGETS mediastreamer_voip EXPORT ${EXPORT_TARGETS_NAME}Targets
		RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
		LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
708
		FRAMEWORK DESTINATION Frameworks
709 710
		PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
	)
711 712
endif()

713
if(FFMPEG_FOUND AND NOT WIN32)
714
	set(NO_DEPRECATED_DECLARATIONS_SOURCE_FILES
715
		videofilters/videoenc.c
716 717
		videofilters/videodec.c
		videofilters/h264dec.c
718
	)
719 720 721 722 723 724 725
	if(NOT TURBOJPEG_FOUND)
		set(NO_DEPRECATED_DECLARATIONS_SOURCE_FILES
			${NO_DEPRECATED_DECLARATIONS_SOURCE_FILES}
			videofilters/ffmpegjpegwriter.c
			videofilters/nowebcam.c
		)
	endif()
726 727 728 729
	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()
730 731
endif()

732 733 734 735 736
if(ENABLE_VIDEO)
	install(FILES voip/nowebcamCIF.jpg
		DESTINATION ${PACKAGE_DATA_DIR}/images
        PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
	)
737
endif()