CMakeLists.txt 20 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
############################################################################
# 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
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
############################################################################

23
find_library(LIBM NAMES m)
Ghislain MARY's avatar
Ghislain MARY committed
24 25
if(ANDROID)
	find_library(ANDROID_CPU_FEATURES_LIBRARY NAMES cpufeatures)
26
	find_library(ANDROID_SUPPORT_LIBRARY NAMES support)
Ghislain MARY's avatar
Ghislain MARY committed
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
find_package(Git)
61 62 63 64
add_custom_target(ms2-git-version
	COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DMEDIASTREAMER_VERSION=${MEDIASTREAMER_VERSION} -DWORK_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/gitversion.cmake
	BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/gitversion.h"
)
65 66
add_custom_target(ms2-basedescs-header
	COMMAND ${CMAKE_COMMAND} -DAWK_PROGRAM=${AWK_PROGRAM} -DAWK_SCRIPTS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../"
67
		-DINPUT_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR}
68
		-DTYPE=base -DSOURCE_FILES="${BASE_SOURCE_FILES_C}"
69 70
		-P "${CMAKE_CURRENT_SOURCE_DIR}/generate_descs_header.cmake"
	BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/basedescs.h")
71 72 73 74 75 76 77 78

add_definitions(
	-DMEDIASTREAMER2_EXPORTS
	-DMEDIASTREAMER2_INTERNAL_EXPORTS
	-D_TRUE_TIME
	-DMS2_INTERNAL
	-DMS2_FILTERS
)
79

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

90 91
apply_compile_flags(BASE_SOURCE_FILES_C "CPP" "C")

92
if(ENABLE_STATIC)
93
	add_library(mediastreamer_base-static STATIC ${MEDIASTREAMER2_HEADER_FILES} ${BASE_SOURCE_FILES_C})
94 95
	set_target_properties(mediastreamer_base-static PROPERTIES OUTPUT_NAME mediastreamer_base)
	target_link_libraries(mediastreamer_base-static ${BASE_LIBS})
96
	add_dependencies(mediastreamer_base-static ms2-git-version ms2-basedescs-header)
97 98 99 100 101 102
	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)
103
	add_library(mediastreamer_base SHARED ${MEDIASTREAMER2_HEADER_FILES} ${BASE_SOURCE_FILES_C})
104
	set_target_properties(mediastreamer_base PROPERTIES LINKER_LANGUAGE C)
105 106
	if(ANDROID)
		set_target_properties(mediastreamer_base PROPERTIES OUTPUT_NAME "mediastreamer_base-${CMAKE_SYSTEM_PROCESSOR}")
107 108 109
	else()
		# Do not version shared library on Android
		set_target_properties(mediastreamer_base PROPERTIES SOVERSION ${MEDIASTREAMER_SO_VERSION})
110
	endif()
111
	target_link_libraries(mediastreamer_base PRIVATE ${BASE_LIBS})
112
	add_dependencies(mediastreamer_base ms2-git-version ms2-basedescs-header)
113
	if(MSVC)
114 115
		if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
			install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/mediastreamer_base.pdb
116
				DESTINATION ${CMAKE_INSTALL_BINDIR}
117 118 119 120
				PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
			)
		endif()
	endif()
121 122 123 124 125 126
	install(TARGETS mediastreamer_base EXPORT ${EXPORT_TARGETS_NAME}Targets
		RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
		LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
		PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
	)
127
endif()
128 129 130



131
set(VOIP_SOURCE_FILES_C
132 133 134
	audiofilters/alaw.c
	audiofilters/audiomixer.c
	audiofilters/chanadapt.c
135
	audiofilters/devices.c
136 137
	audiofilters/dtmfgen.c
	audiofilters/equalizer.c
138
	audiofilters/flowcontrol.c
139 140
	audiofilters/g711.c
	audiofilters/g711.h
johan's avatar
johan committed
141
	audiofilters/genericplc.h
142
	audiofilters/genericplc.c
johan's avatar
johan committed
143
	audiofilters/msgenericplc.c
144 145 146
	audiofilters/l16.c
	audiofilters/msfileplayer.c
	audiofilters/msfilerec.c
147 148
	audiofilters/asyncrw.c
	audiofilters/asyncrw.h
149
	audiofilters/msg722.c
150
	audiofilters/msvaddtx.c
151 152 153 154
	audiofilters/msvolume.c
	audiofilters/tonedetector.c
	audiofilters/ulaw.c
	audiofilters/waveheader.h
155
	crypto/dtls_srtp.c
156
	crypto/ms_srtp.c
157
	crypto/zrtp.c
158 159
	otherfilters/msrtp.c
	utils/_kiss_fft_guts.h
160
	utils/audiodiff.c
161 162 163 164
	utils/dsptools.c
	utils/g722.h
	utils/g722_decode.c
	utils/g722_encode.c
François Grisez's avatar
François Grisez committed
165 166
	utils/h264utils.h
	utils/h264utils.c
167 168 169 170
	utils/kiss_fft.c
	utils/kiss_fft.h
	utils/kiss_fftr.c
	utils/kiss_fftr.h
171
	utils/stream_regulator.c
172 173 174 175 176 177
	voip/audioconference.c
	voip/audiostream.c
	voip/bitratecontrol.c
	voip/bitratedriver.c
	voip/ice.c
	voip/mediastream.c
178
	voip/msiframerequestslimiter.c
179
	voip/msmediaplayer.c
180 181 182
	voip/msvoip.c
	voip/private.h
	voip/qosanalyzer.c
183
	voip/qosanalyzer.h
184
	voip/qualityindicator.c
185 186
	otherfilters/rfc4103_source.c
	otherfilters/rfc4103_sink.c
187
	voip/rfc4103_textstream.c
188
	voip/ringstream.c
189
	voip/stun.c
190
)
191 192
set(VOIP_SOURCE_FILES_CXX )
set(VOIP_SOURCE_FILES_OBJC )
193
set(VOIP_SOURCE_FILES_ASM )
194

195
if(ENABLE_ALSA)
196
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/alsa.c)
197
endif()
198 199 200 201 202 203 204 205 206 207 208 209 210 211
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
		audiofilters/aac-eld-android.cpp
	)
endif()
212
if(ENABLE_ARTSC)
213
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/arts.c)
214 215
endif()
if(ENABLE_MACSND)
216
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/macsnd.c)
217 218
endif()
if(ENABLE_MACAQSND)
219
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/aqsnd.c)
220 221
endif()
if(ENABLE_OSS)
222
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/oss.c)
223 224
endif()
if(ENABLE_PORTAUDIO)
225
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/pasnd.c)
226 227
endif()
if(ENABLE_PULSEAUDIO)
228
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/pulseaudio.c)
229 230
endif()
if(ENABLE_QSA)
231
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/qsa.c)
232 233
endif()
if(IOS)
234 235
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/aac-eld.c)
	list(APPEND VOIP_SOURCE_FILES_OBJC audiofilters/msiounit.m)
236
endif()
237
if(WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
238
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/winsnd3.c)
239
endif()
240

241 242 243
if(ENABLE_G726)
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/g726.c)
endif()
244
if(GSM_FOUND)
245
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/gsm.c)
246
endif()
247 248 249
if(BV16_FOUND)
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/bv16.c)
endif()
250
if(OPUS_FOUND)
251
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/msopus.c)
252 253
endif()
if(ENABLE_RESAMPLE)
254
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/msresample.c)
255 256
endif()
if(SPEEX_FOUND)
257 258 259 260
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/msspeex.c)
endif()
if(SPEEXDSP_FOUND)
	list(APPEND VOIP_SOURCE_FILES_C audiofilters/speexec.c)
261
endif()
262

263
if(ENABLE_VIDEO)
264
	list(APPEND VOIP_SOURCE_FILES_C
265
		utils/bits_rw.c
266 267
		videofilters/extdisplay.c
		videofilters/mire.c
268
		videofilters/nowebcam.c
269 270 271 272 273 274 275
		videofilters/pixconv.c
		videofilters/sizeconv.c
		voip/layouts.c
		voip/layouts.h
		voip/msvideo.c
		voip/msvideo_neon.c
		voip/msvideo_neon.h
276
		voip/nowebcam.h
277 278
		voip/rfc2429.h
		voip/rfc3984.c
Ghislain MARY's avatar
Ghislain MARY committed
279
		voip/videostarter.c
280
		voip/videostream.c
281
		voip/video_preset_high_fps.c
282
	)
283
	if(WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
284
		add_definitions(-DHAVE_DIRECTSHOW)
285
		list(APPEND VOIP_SOURCE_FILES_C
286 287
			videofilters/drawdib-display.c
		)
288
		list(APPEND VOIP_SOURCE_FILES_CXX
289
			videofilters/msdscap.cc
290
		)
291
	endif()
292
	if(APPLE)
293
		if(IOS)
294
			list(APPEND VOIP_SOURCE_FILES_C
295 296 297 298
				utils/opengles_display.c
				utils/opengles_display.h
				utils/shaders.c
				utils/shaders.h
299 300 301
				voip/scaler.c
			)
			list(APPEND VOIP_SOURCE_FILES_OBJC
302 303 304 305 306
				videofilters/iosdisplay.m
				videofilters/ioscapture.m
				voip/ioshardware.m
			)
		else()
307
			list(APPEND VOIP_SOURCE_FILES_OBJC
308 309 310
				videofilters/msosxdisplay.m
				videofilters/qtcapture.m
			)
311
			list(APPEND VOIP_SOURCE_FILES_C
312 313 314 315 316 317
				utils/opengles_display.c
				utils/opengles_display.h
				utils/shaders.c
				utils/shaders.h
			)
		endif()
318
	endif()
319
	if(APPLE)
François Grisez's avatar
François Grisez committed
320
		list(APPEND VOIP_SOURCE_FILES_C videofilters/videotoolbox.c)
321
	endif()
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344
	if(ANDROID)
		list(APPEND VOIP_SOURCE_FILES_C
			android/mediacodech264dec.c
			android/mediacodech264enc.c
			android/android-display.c
			android/android-opengl-display.c
			utils/opengles_display.c
			utils/opengles_display.h
			utils/shaders.c
			utils/shaders.h
			voip/scaler.c
		)
		if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armeabi-v7a")
			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()
345
	if (ENABLE_QNX)
346 347 348 349 350
		list(APPEND VOIP_SOURCE_FILES_CXX
			videofilters/bb10_display.cpp
			videofilters/bb10_capture.cpp
		)
	endif()
351
	if(FFMPEG_FOUND)
352
		list(APPEND VOIP_SOURCE_FILES_C
353
			utils/ffmpeg-priv.c
354
			utils/ffmpeg-priv.h
355 356 357 358 359 360
			utils/swscale.h
			videofilters/h264dec.c
			videofilters/jpegwriter.c
			videofilters/videodec.c
			videofilters/videoenc.c
		)
361 362
	endif()
	if(GLX_FOUND)
363
		list(APPEND VOIP_SOURCE_FILES_C
364 365
			utils/opengles_display.c
			utils/shaders.c
366
			videofilters/glxvideo.c
367
		)
368 369
	endif()
	if(SDL_FOUND)
370
		list(APPEND VOIP_SOURCE_FILES_C videofilters/videoout.c)
371 372
	endif()
	if(THEORA_FOUND)
373
		list(APPEND VOIP_SOURCE_FILES_C videofilters/theora.c)
374
	endif()
375 376
	if(V4L_FOUND)
		if(HAVE_LINUX_VIDEODEV_H)
377
			list(APPEND VOIP_SOURCE_FILES_C videofilters/msv4l.c)
378 379
		endif()
		if(HAVE_LINUX_VIDEODEV2_H)
380
			list(APPEND VOIP_SOURCE_FILES_C videofilters/msv4l2.c)
381 382
		endif()
	endif()
383
	if(VPX_FOUND)
384
		list(APPEND VOIP_SOURCE_FILES_C
385 386 387 388 389 390
			videofilters/vp8.c
			voip/vp8rtpfmt.c
			voip/vp8rtpfmt.h
		)
	endif()
	if(X11_FOUND)
391
		list(APPEND VOIP_SOURCE_FILES_C utils/x11_helper.c)
392 393
	endif()
	if(XV_FOUND)
394
		list(APPEND VOIP_SOURCE_FILES_C videofilters/x11video.c)
395 396
	endif()
endif()
397 398 399 400 401 402 403 404
if(MATROSKA2_FOUND)
	list(APPEND VOIP_SOURCE_FILES_C
		videofilters/mkv.c
		utils/mkv_reader.c
		voip/rfc2429.h
		voip/rfc3984.c
	)
endif()
405

406
set(VOIP_SOURCE_FILES_ALL ${VOIP_SOURCE_FILES_C} ${VOIP_SOURCE_FILES_CXX} ${VOIP_SOURCE_FILES_OBJC})
407 408 409

add_custom_target(ms2-voipdescs-header
	COMMAND ${CMAKE_COMMAND} -DAWK_PROGRAM=${AWK_PROGRAM} -DAWK_SCRIPTS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../"
410
		-DINPUT_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR}
411
		-DTYPE=voip -DSOURCE_FILES="${VOIP_SOURCE_FILES_ALL}"
412 413
		-P "${CMAKE_CURRENT_SOURCE_DIR}/generate_descs_header.cmake"
	BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/voipdescs.h"
414
)
415

416
if(APPLE OR ANDROID OR GLX_FOUND)
417
	find_package(PythonInterp REQUIRED)
418 419 420 421 422
	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
423
		COMMAND ${CMAKE_COMMAND} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DSED_PROGRAM=${SED_PROGRAM}
424 425 426 427 428 429
			-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
430
		COMMAND ${CMAKE_COMMAND} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DSED_PROGRAM=${SED_PROGRAM}
431 432 433 434 435
			-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"
	)
436
endif()
437 438 439 440 441 442 443

apply_compile_flags(VOIP_SOURCE_FILES_C "CPP" "C")
apply_compile_flags(VOIP_SOURCE_FILES_OBJC "CPP" "OBJC")
if(VOIP_SOURCE_FILES_CXX)
	set_source_files_properties(${VOIP_SOURCE_FILES_CXX} PROPERTIES LANGUAGE CXX)
	apply_compile_flags(VOIP_SOURCE_FILES_CXX "CPP" "CXX")
endif()
444

445

446 447 448 449 450 451 452 453 454 455 456
if(ENABLE_VIDEO AND ANDROID AND CMAKE_SYSTEM_PROCESSOR STREQUAL "armeabi-v7a")
	set_source_files_properties(voip/msvideo_neon.c voip/scaler.c PROPERTIES COMPILE_FLAGS "-mfpu=neon")
endif()


if(VOIP_SOURCE_FILES_ASM)
	if(ANDROID AND CMAKE_SYSTEM_PROCESSOR STREQUAL "armeabi-v7a")
		set(ARCH_OPTIONS "-mfpu=neon")
	endif()
	get_directory_property(DIRECTORY_PROPERTY_COMPILE_OPTIONS "COMPILE_OPTIONS")
	string(REPLACE ";" " " DIRECTORY_PROPERTY_COMPILE_OPTIONS "${DIRECTORY_PROPERTY_COMPILE_OPTIONS}")
Ghislain MARY's avatar
Ghislain MARY committed
457 458 459 460 461
	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>")
462 463 464 465
	enable_language(ASM)
endif()


466
set(VOIP_LIBS
467
	${BCTOOLBOX_CORE_LIBRARIES}
468
	${ORTP_LIBRARIES}
469
)
470
if(WIN32)
471
	if(NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
472
		list(APPEND VOIP_LIBS ${LIBGCC} ${LIBMINGWEX} ole32 oleaut32 uuid Ws2_32)
473
		if(ENABLE_VIDEO)
474
			list(APPEND VOIP_LIBS gdi32 strmiids user32 vfw32)
475
		endif()
476
	endif()
477
endif()
478 479 480
if(LIBM)
	list(APPEND VOIP_LIBS ${LIBM})
endif()
Ghislain MARY's avatar
Ghislain MARY committed
481 482 483
if(ANDROID_CPU_FEATURES_LIBRARY)
	list(APPEND VOIP_LIBS ${ANDROID_CPU_FEATURES_LIBRARY})
endif()
484 485 486
if(ANDROID_SUPPORT_LIBRARY)
	list(APPEND VOIP_LIBS ${ANDROID_SUPPORT_LIBRARY})
endif()
487 488 489
if(ANDROID AND ENABLE_VIDEO)
	list(APPEND VOIP_LIBS GLESv2)
endif()
490 491 492
if(HAVE_DLOPEN)
	list(APPEND VOIP_LIBS dl)
endif()
493 494 495
if(PCAP_FOUND)
	list(APPEND VOIP_LIBS ${PCAP_LIBRARIES})
endif()
496 497 498
if(BZRTP_FOUND)
	list(APPEND VOIP_LIBS ${BZRTP_LIBRARIES})
endif()
johan's avatar
johan committed
499 500 501
if(SRTP_FOUND)
	list(APPEND VOIP_LIBS ${SRTP_LIBRARIES})
endif()
502 503 504
if(SPANDSP_FOUND)
	list(APPEND VOIP_LIBS ${SPANDSP_LIBRARIES})
endif()
505 506 507 508 509 510 511 512 513
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()
514 515 516
if(SPEEXDSP_FOUND)
	list(APPEND VOIP_LIBS ${SPEEXDSP_LIBRARIES})
endif()
517 518 519
if(BV16_FOUND)
	list(APPEND VOIP_LIBS ${BV16_LIBRARIES})
endif()
520 521 522 523 524 525 526 527 528 529 530 531 532 533
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})
534
	list(APPEND VOIP_LIBS ${QNXAUDIOMANAGER_LIBRARIES})
535 536 537 538 539 540 541
endif()
if(FFMPEG_FOUND)
	list(APPEND VOIP_LIBS ${FFMPEG_LIBRARIES})
	if(MSVC)
		add_definitions(-Dinline=__inline)
	endif()
endif()
542 543 544
if(V4L_FOUND)
	list(APPEND VOIP_LIBS ${V4L_LIBRARIES})
endif()
545 546 547 548 549 550 551 552 553 554 555 556
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()
if(VPX_FOUND)
	list(APPEND VOIP_LIBS ${VPX_LIBRARIES})
endif()
557 558
if(MATROSKA2_FOUND)
	list(APPEND VOIP_LIBS ${MATROSKA2_LIBRARIES})
559
endif()
560 561 562 563 564
if (SCREEN_FOUND)
	list(APPEND VOIP_LIBS ${SCREEN_LIBRARIES})
endif()
if (CAMAPI_FOUND)
	list(APPEND VOIP_LIBS ${CAMAPI_LIBRARIES})
565
endif()
jehan's avatar
jehan committed
566 567 568 569
if (BCGG729_FOUND)
	 add_definitions(-DHAVE_G729B=1)
	list(APPEND VOIP_LIBS ${BCG729_LIBRARIES})
endif()
570
set(MS2_VOIP_DEPENDENCIES ms2-git-version ms2-voipdescs-header)
571
if(APPLE OR ANDROID OR GLX_FOUND)
572
	list(APPEND MS2_VOIP_DEPENDENCIES ms2-yuv2rgb-fs-header ms2-yuv2rgb-vs-header)
573 574 575
endif()

string(REPLACE ";" " " LINK_FLAGS_STR "${LINK_FLAGS}")
576
if(ENABLE_STATIC)
577
	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})
578 579 580 581
	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()
582
	add_dependencies(mediastreamer_voip-static ${MS2_VOIP_DEPENDENCIES})
583
	target_link_libraries(mediastreamer_voip-static mediastreamer_base-static ${VOIP_LIBS})
584 585 586 587 588 589
	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)
590
	add_library(mediastreamer_voip SHARED ${MEDIASTREAMER2_HEADER_FILES} ${VOIP_SOURCE_FILES_C} ${VOIP_SOURCE_FILES_CXX} ${VOIP_SOURCE_FILES_OBJC} ${VOIP_SOURCE_FILES_ASM})
591
	set_target_properties(mediastreamer_voip PROPERTIES LINKER_LANGUAGE CXX)
592 593 594
	if(LINK_FLAGS_STR)
		set_target_properties(mediastreamer_voip PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
	endif()
595
	add_dependencies(mediastreamer_voip ${MS2_VOIP_DEPENDENCIES})
596 597
	if(ANDROID)
		set_target_properties(mediastreamer_voip PROPERTIES OUTPUT_NAME "mediastreamer_voip-${CMAKE_SYSTEM_PROCESSOR}")
598 599 600
	else()
		# Do not version shared library on Android
		set_target_properties(mediastreamer_voip PROPERTIES SOVERSION ${MEDIASTREAMER_SO_VERSION})
601
	endif()
602
	target_link_libraries(mediastreamer_voip mediastreamer_base ${VOIP_LIBS})
603
	if(MSVC)
604 605
		if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
			install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/mediastreamer_voip.pdb
606
				DESTINATION ${CMAKE_INSTALL_BINDIR}
607 608 609 610
				PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
			)
		endif()
	endif()
611 612 613 614 615 616
	install(TARGETS mediastreamer_voip EXPORT ${EXPORT_TARGETS_NAME}Targets
		RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
		LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
		PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
	)
617 618
endif()

619 620 621 622
if(FFMPEG_FOUND AND NOT WIN32)
	set_source_files_properties(
		videofilters/jpegwriter.c
		videofilters/videoenc.c
623 624 625
		videofilters/videodec.c
		videofilters/nowebcam.c
		videofilters/h264dec.c
626 627 628 629
		PROPERTIES COMPILE_FLAGS "-Wno-error=deprecated-declarations"
	)
endif()

630 631 632 633 634
if(ENABLE_VIDEO)
	install(FILES voip/nowebcamCIF.jpg
		DESTINATION ${PACKAGE_DATA_DIR}/images
        PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
	)
635
endif()
636 637 638 639 640 641 642 643


if(ENABLE_VIDEO AND CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
	add_library(mswinrtjpeg2yuv MODULE "videofilters/winrtjpeg2yuv.cpp")
	set_target_properties(mswinrtjpeg2yuv PROPERTIES LINKER_LANGUAGE CXX VS_WINRT_COMPONENT TRUE)
	target_link_libraries(mswinrtjpeg2yuv mediastreamer_voip)

	install(TARGETS mswinrtjpeg2yuv
644 645 646
		RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
		LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
647 648 649
		PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
	)

650 651
	if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
		install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/mswinrtjpeg2yuv.pdb
652
			DESTINATION ${CMAKE_INSTALL_BINDIR}
653 654 655 656
			PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
		)
	endif()
endif()