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 74
	-DMS2_INTERNAL
	-DMS2_FILTERS
)
75

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

86
bc_apply_compile_flags(BASE_SOURCE_FILES_C STRICT_OPTIONS_CPP STRICT_OPTIONS_C)
87

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



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

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

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

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

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

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

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

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

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

509

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


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

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

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

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