CMakeLists.txt 21.6 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
cmake_minimum_required(VERSION 3.0)
24
project(mediastreamer2 VERSION 2.16.1 LANGUAGES C CXX)
25 26


27 28 29 30
set(MEDIASTREAMER_MAJOR_VERSION ${PROJECT_VERSION_MAJOR})
set(MEDIASTREAMER_MINOR_VERSION ${PROJECT_VERSION_MINOR})
set(MEDIASTREAMER_MICRO_VERSION ${PROJECT_VERSION_PATCH})
set(MEDIASTREAMER_VERSION ${PROJECT_VERSION})
31
set(MEDIASTREAMER_SO_VERSION "10") # incremented after Mediastreamer 2.15.1. Do not increment before next release
32

33
string(REGEX MATCH "^(arm*|aarch64)" FIXED_POINT_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}")
34 35 36 37 38 39
if(FIXED_POINT_PROCESSOR)
	set(ENABLE_FIXED_POINT_DEFAULT_VALUE YES)
else()
	set(ENABLE_FIXED_POINT_DEFAULT_VALUE NO)
endif()
if(IOS)
40
	set(ENABLE_MACSND_DEFAULT_VALUE NO)
41 42
	set(ENABLE_MACAQSND_DEFAULT_VALUE YES)
else()
43
	set(ENABLE_MACSND_DEFAULT_VALUE YES)
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
	set(ENABLE_MACAQSND_DEFAULT_VALUE NO)
endif()
set(ENABLE_GLX_DEFAULT_VALUE NO)
set(ENABLE_X11_DEFAULT_VALUE NO)
if(UNIX)
	if(NOT APPLE)
		set(ENABLE_GLX_DEFAULT_VALUE YES)
		set(ENABLE_X11_DEFAULT_VALUE YES)
	endif()
endif()
if(UNIX AND NOT APPLE)
	set(LINUX_OR_BSD 1)
endif()

include(CMakeDependentOption)

60 61
option(ENABLE_SHARED "Build shared library." YES)
option(ENABLE_STATIC "Build static library." YES)
62
option(ENABLE_DEBUG_LOGS "Enable the display of traces showing the execution of the library." NO)
63
option(ENABLE_DOC "Enable documentation generation with Doxygen." YES)
64
option(ENABLE_FIXED_POINT "Turn on fixed point computations." ${ENABLE_FIXED_POINT_DEFAULT_VALUE})
65
option(ENABLE_NON_FREE_CODECS "Allow inclusion of non-free codecs in the build." NO)
66
option(ENABLE_PCAP "Enable PCAP support." NO)
67
option(ENABLE_STRICT "Build with strict compile options." YES)
68
option(ENABLE_RELATIVE_PREFIX "Find resources relatively to the installation directory." NO)
69
option(ENABLE_TOOLS "Turn on or off compilation of tools." YES)
70 71
option(ENABLE_UNIT_TESTS "Enable compilation of unit tests." YES)

72
option(ENABLE_SRTP "Build with the SRTP transport support." YES)
73
cmake_dependent_option(ENABLE_ZRTP "Build with ZRTP support." YES "ENABLE_SRTP" NO)
74 75 76

option(ENABLE_SOUND "Can be used to turn off all possible sound backends." YES)
cmake_dependent_option(ENABLE_ALSA "Enable ALSA support." YES "ENABLE_SOUND;LINUX_OR_BSD" NO)
77
cmake_dependent_option(ENABLE_ANDROIDSND "Enable Android sound support." NO "ENABLE_SOUND;ANDROID" NO)
78
cmake_dependent_option(ENABLE_ARTSC "Enable artsc (KDE<4) sound input/output." NO "ENABLE_SOUND;LINUX_OR_BSD" NO)
79
cmake_dependent_option(ENABLE_MACSND "Enable MAC OS X Audio Units sound support." ${ENABLE_MACSND_DEFAULT_VALUE} "ENABLE_SOUND;APPLE" NO)
80 81
cmake_dependent_option(ENABLE_MACAQSND "Enable native MAC OS X Audio Queue sound support." ${ENABLE_MACAQSND_DEFAULT_VALUE} "ENABLE_SOUND;APPLE" NO)
cmake_dependent_option(ENABLE_QSA "Enable QSA (QNX Sound Architecture) support." NO "ENABLE_SOUND" NO)
82 83 84
# OSS is mostly deprecated in 2016, so it should not be built by default (it won't work anyway). Let user defines it
# itself only if he REALLY needs it.
cmake_dependent_option(ENABLE_OSS "Enable OSS support." NO "ENABLE_SOUND;LINUX_OR_BSD" NO)
85 86
cmake_dependent_option(ENABLE_PORTAUDIO "Enable portaudio native support." NO "ENABLE_SOUND" NO)
cmake_dependent_option(ENABLE_PULSEAUDIO "Enable pulseaudio support." YES "ENABLE_SOUND" NO)
87
option(ENABLE_G726 "Build mediastreamer2 with the G726 codec." NO)
88
option(ENABLE_GSM "Build mediastreamer2 with the GSM codec." YES)
89
option(ENABLE_BV16 "Build mediastreamer2 with the BV16 codec." YES)
90
option(ENABLE_OPUS "Build mediastreamer2 with the OPUS codec." YES)
91 92
option(ENABLE_SPEEX_CODEC "Build mediastreamer2 with the SPEEX codec." YES)
option(ENABLE_SPEEX_DSP "Build mediastreamer2 with the SPEEX DSP support." YES)
93 94
option(ENABLE_G729 "Build mediastreamer2 with the G729 codec." YES)
option(ENABLE_G729B_CNG "Build mediastreamer2 with G729 annex B cng." NO)
95
cmake_dependent_option(ENABLE_RESAMPLE "Build mediastreamer2 with the resampling capability." YES "ENABLE_SPEEX_DSP" NO)
96 97 98

option(ENABLE_VIDEO "Build mediastreamer2 with video support." YES)
cmake_dependent_option(ENABLE_FFMPEG "Build mediastreamer2 with ffmpeg video support." YES "ENABLE_VIDEO" NO)
99
cmake_dependent_option(ENABLE_GL "Enable generic OpenGL rendering support." YES "ENABLE_VIDEO" NO)
100 101
cmake_dependent_option(ENABLE_GLX "Enable X11+OpenGL rendering support (requires glx and glew)." ${ENABLE_GLX_DEFAULT_VALUE} "ENABLE_VIDEO;UNIX" NO)
cmake_dependent_option(ENABLE_SDL "Enable SDL support." NO "ENABLE_FFMPEG" NO)
102
cmake_dependent_option(ENABLE_V4L "Enable Video4Linux support." YES "ENABLE_VIDEO;LINUX_OR_BSD" NO)
103 104 105 106
cmake_dependent_option(ENABLE_X11 "Enable X11 support." ${ENABLE_X11_DEFAULT_VALUE} "ENABLE_FFMPEG;UNIX" NO)
cmake_dependent_option(ENABLE_XV "Enable XV support." ${ENABLE_X11_DEFAULT_VALUE} "ENABLE_FFMPEG;UNIX" NO)
cmake_dependent_option(ENABLE_THEORA "Enable theora video codec support." YES "ENABLE_VIDEO" NO)
cmake_dependent_option(ENABLE_VPX "Build mediastreamer2 with VPX codec." YES "ENABLE_VIDEO" NO)
107
option(ENABLE_MKV "Enable support of MKV files reading and writing." YES)
108
cmake_dependent_option(ENABLE_QNX "Build medistreamer2 with BB10 filters." NO "ENABLE_VIDEO" NO)
109
cmake_dependent_option(ENABLE_VT_H264 "Build mediastreamer2 with H264 encoder/decoder based on VirtualToolbox (Apple only)" YES "ENABLE_VIDEO" NO)
110
option(ENABLE_JPEG "Enable JPEG support" YES)
111 112


113
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
114 115 116

include(CheckIncludeFile)
include(CheckLibraryExists)
117
include(CMakePushCheckState)
118 119 120 121 122 123
include(GNUInstallDirs)

if(NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX)
	set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
	message(STATUS "Setting install rpath to ${CMAKE_INSTALL_RPATH}")
endif()
124

125 126 127 128 129
if(MSVC AND MSVC_VERSION LESS 1800)
	set(MSVC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/MSVC")
	list(APPEND CMAKE_REQUIRED_INCLUDES "${MSVC_INCLUDE_DIR}")
endif()

130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
check_include_file(sys/shm.h HAVE_SYS_SHM_H)
check_include_file(alloca.h HAVE_ALLOCA_H)
if(ENABLE_OSS)
	check_include_file(soundcard.h HAVE_SOUNDCARD_H)
	check_include_file(sys/soundcard.h HAVE_SYS_SOUNDCARD_H)
	check_include_file(machine/soundcard.h HAVE_MACHINE_SOUNDCARD_H)
	check_include_file(sys/audio.h HAVE_SYS_AUDIO_H)
	if(NOT (HAVE_SOUNDCARD_H OR HAVE_SYS_SOUNDCARD_H OR HAVE_MACHINE_SOUNDCARD_H OR HAVE_SYS_AUDIO_H))
		set(ENABLE_OSS OFF CACHE BOOL "Enable OSS support." FORCE)
	endif()
endif()

check_library_exists("dl" "dlopen" "" HAVE_DLOPEN)

include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)

147 148 149 150 151
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
	include("${EP_ortp_CONFIG_DIR}/ORTPConfig.cmake")
else()
	find_package(ORTP REQUIRED)
endif()
johan's avatar
johan committed
152 153


154 155 156
if(ENABLE_PCAP)
	find_package(PCAP QUIET)
endif()
157

158 159 160 161 162 163 164
if(ENABLE_SRTP)
	find_package(SRTP)
	if(NOT SRTP_FOUND)
		message(WARNING "Could not find SRTP library, Mediastreamer2 will be compiled without SRTP support.")
		set(ENABLE_SRTP OFF CACHE BOOL "Build with the SRTP transport support." FORCE)
	endif()
endif()
165
if(ENABLE_ZRTP)
166 167 168 169 170
	if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
		include("${EP_bzrtp_CONFIG_DIR}/BZRTPConfig.cmake")
	else()
		find_package(BZRTP)
	endif()
171 172 173 174 175
	if(NOT BZRTP_FOUND)
		message(WARNING "Could not find bzrtp library, mediastreamer2 will be compiled without ZRTP support.")
		set(ENABLE_ZRTP OFF CACHE BOOL "Build mediastreamer2 with ZRTP support." FORCE)
	endif()
endif()
176 177 178
if(ENABLE_G726)
	find_package(SpanDSP REQUIRED)
endif()
179 180 181 182 183 184 185
if(ENABLE_GSM)
	find_package(GSM)
	if(NOT GSM_FOUND)
		message(WARNING "Could not find GSM library, mediastreamer2 will be compiled without the GSM codec.")
		set(ENABLE_GSM OFF CACHE BOOL "Build mediastreamer2 with the GSM codec." FORCE)
	endif()
endif()
186 187 188 189 190 191 192
if(ENABLE_BV16)
	find_package(BV16)
	if(NOT BV16_FOUND)
		message(WARNING "Could not find BV16 library, mediastreamer2 will be compiled without the BV16 codec.")
		set(ENABLE_BV16 OFF CACHE BOOL "Build mediastreamer2 with the BV16 codec." FORCE)
	endif()
endif()
193 194 195 196 197 198 199
if(ENABLE_OPUS)
	find_package(Opus)
	if(NOT OPUS_FOUND)
		message(WARNING "Could not find opus library, mediastreamer2 will be compiled without the OPUS codec.")
		set(ENABLE_OPUS OFF CACHE BOOL "Build mediastreamer2 with the OPUS codec." FORCE)
	endif()
endif()
200
if(ENABLE_SPEEX_CODEC)
201 202 203
	find_package(Speex)
	if(NOT SPEEX_FOUND)
		message(WARNING "Could not find speex library, mediastreamer2 will be compiled without the SPEEX codec.")
204
		set(ENABLE_SPEEX_CODEC OFF CACHE BOOL "Build mediastreamer2 with the SPEEX codec." FORCE)
205 206
	endif()
endif()
207 208 209
if(ENABLE_SPEEX_DSP)
	find_package(SpeexDsp REQUIRED)
endif()
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
if(ENABLE_ALSA)
	find_package(ALSA)
	if(NOT ALSA_FOUND)
		set(ENABLE_ALSA OFF CACHE BOOL "Enable ALSA support." FORCE)
	endif()
endif()
if(ENABLE_ARTSC)
	find_package(Arts REQUIRED)
endif()
if(ENABLE_PORTAUDIO)
	find_package(PortAudio REQUIRED)
endif()
if(ENABLE_PULSEAUDIO)
	find_package(PulseAudio)
	if(NOT PULSEAUDIO_FOUND)
		set(ENABLE_PULSEAUDIO OFF CACHE BOOL "Enable pulseaudio support." FORCE)
	endif()
endif()
if(ENABLE_QSA)
	find_package(QSA REQUIRED)
230
	find_package(QnxAudioManager REQUIRED)
231 232 233 234 235 236 237 238 239
endif()
if(ENABLE_VIDEO)
	add_definitions(-DVIDEO_ENABLED)
endif()
if(ENABLE_FFMPEG)
	find_package(FFMpeg REQUIRED)
else()
	add_definitions(-DNO_FFMPEG)
endif()
240 241 242 243 244 245
if(ENABLE_V4L)
	find_package(V4L)
	if(NOT V4L_FOUND)
		message(FATAL_ERROR "Missing V4L. It is highly recommended to build with libv4l2 headers and library. Many camera will won't work or will crash your application if libv4l2 is not installed. If you know what you are doing, you can use -DENABLE_V4L=0 to disable this check.")
	endif()
endif()
246 247 248 249 250 251 252 253 254 255 256 257 258 259
if(ENABLE_X11)
	find_package(X11)
	if(NOT X11_FOUND)
		set(ENABLE_X11 OFF CACHE BOOL "Enable X11 support." FORCE)
	endif()
endif()
if(ENABLE_XV)
	find_package(Xv)
	if(XV_FOUND)
		set(HAVE_XV 1)
	else()
		set(ENABLE_XV OFF CACHE BOOL "Enable XV support." FORCE)
	endif()
endif()
260 261
if(ENABLE_GL)
	if(WIN32)
262 263
		find_package(QtAngle)
		if(QTANGLE_FOUND)
264 265 266 267 268
			set(HAVE_GL 1)
		else()
			set(ENABLE_GL OFF CACHE BOOL "Enable generic OpenGL rendering support." FORCE)
		endif()
	else()
269 270
		find_package(OpenGL)
		if(OPENGL_FOUND)
271 272 273 274 275 276
			set(HAVE_GL 1)
		else()
			set(ENABLE_GL OFF CACHE BOOL "Enable generic OpenGL rendering support." FORCE)
		endif()
	endif()
endif()
277 278 279
if(ENABLE_GLX)
	find_package(GLX)
	if(GLX_FOUND)
280
		set(HAVE_GLX 1)
281 282 283 284 285
	else()
		set(ENABLE_GLX OFF CACHE BOOL "Enable X11+OpenGL rendering support (requires glx and glew)." FORCE)
	endif()
endif()
# TODO: Handle SDL option
286 287 288 289 290 291 292
if(ENABLE_THEORA)
	find_package(Theora)
	if(NOT THEORA_FOUND)
		message(WARNING "Could not find theora library, mediastreamer2 will be compiled without theora support.")
		set(ENABLE_THEORA OFF CACHE BOOL "Enable theora video codec support." FORCE)
	endif()
endif()
293 294
if(ENABLE_VPX)
	find_package(VPX)
Ghislain MARY's avatar
Ghislain MARY committed
295 296 297
	if(VPX_FOUND)
		set(HAVE_VPX 1)
	else()
298 299 300
		set(ENABLE_VPX OFF CACHE BOOL "Build mediastreamer2 with VPX codec." FORCE)
	endif()
endif()
301
if(ENABLE_MKV)
302 303 304
	find_package(BcMatroska2 QUIET)
	if(NOT BCMATROSKA2_FOUND)
		message(WARNING "Could not find BcMatroska2 library, mediastreamer2 will be compiled without MKV support.")
305 306 307
		set(ENABLE_MKV OFF CACHE BOOL "Enable support of MKV files reading and writing." FORCE)
	endif()
endif()
308

309
if(ENABLE_QNX)
310 311 312 313 314 315 316 317 318
	find_package(Screen)
	if(NOT SCREEN_FOUND)
		message(FATAL_ERROR "SCREEN NOT FOUND")
	endif()
	find_package(CamApi)
	if(NOT CAMAPI_FOUND)
		message(FATAL_ERROR "CAMAPI NOT FOUND")
	endif()
endif()
319

320
if(ENABLE_SOUND AND NOT(WIN32 OR ENABLE_ALSA OR ENABLE_ARTSC OR ENABLE_MACSND OR ENABLE_MACAQSND OR ENABLE_OSS OR ENABLE_PORTAUDIO OR ENABLE_PULSEAUDIO OR ENABLE_QSA OR ENABLE_ANDROIDSND))
321 322
	message(FATAL_ERROR "Could not find a support sound driver API. Use -DENABLE_SOUND=NO if you don't care about having sound.")
endif()
323

324
if(ENABLE_G729 OR ENABLE_G729B_CNG)
325 326 327 328 329
	if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
		include("${EP_bcg729_CONFIG_DIR}/Bcg729Config.cmake")
	else()
		find_package(Bcg729 1.0.1)
	endif()
jehan's avatar
jehan committed
330
	if(NOT BCG729_FOUND)
331 332 333
		message(WARNING "Could not find bcg729, mediastreamer2 will be compiled without G729 codec and G729 AnnexB in RFC3389.")
		set(ENABLE_G729 OFF CACHE BOOL "Build mediastreamer2 with the G729 codec." FORCE)
		set(ENABLE_G729_CNG OFF CACHE BOOL "Build mediastreamer2 with G729 Annex B cng." FORCE)
jehan's avatar
jehan committed
334 335 336
	endif()
endif()

337 338 339 340 341 342 343 344
if(ENABLE_JPEG)
	find_package(TurboJpeg)
	if(NOT TURBOJPEG_FOUND)
		message(WARNING "Could not find libturbo-jpeg, mediastreamer2 will be compiled without LibJpeg-Turbo")
		set(ENABLE_JPEG OFF CACHE BOOL "Enable JPEG support" FORCE)
	endif()
endif()

jehan's avatar
jehan committed
345
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
346
	set(BcToolbox_FIND_COMPONENTS tester)
jehan's avatar
jehan committed
347 348
	include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake")
else()
349
	find_package(BcToolbox 0.0.3 REQUIRED OPTIONAL_COMPONENTS tester)
jehan's avatar
jehan committed
350
endif()
351

352
include_directories(
Ghislain MARY's avatar
Ghislain MARY committed
353 354 355 356
	include
	src/audiofilters
	src/utils
	src/voip
357
	${CMAKE_CURRENT_BINARY_DIR}
Ghislain MARY's avatar
Ghislain MARY committed
358
	${CMAKE_CURRENT_BINARY_DIR}/src
359 360 361
)

set(MEDIASTREAMER2_INCLUDE_DIRS
362
	${ORTP_INCLUDE_DIRS}
363
	${BCTOOLBOX_CORE_INCLUDE_DIRS}
364
)
365
if(BZRTP_FOUND)
366
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${BZRTP_INCLUDE_DIRS})
367
endif()
368
if(SRTP_FOUND)
369
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${SRTP_INCLUDE_DIRS})
370
endif()
371
if(SPANDSP_FOUND)
372
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${SPANDSP_INCLUDE_DIRS})
373
endif()
374
if(GSM_FOUND)
375
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${GSM_INCLUDE_DIRS})
376 377
endif()
if(OPUS_FOUND)
378
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${OPUS_INCLUDE_DIRS})
379 380
endif()
if(SPEEX_FOUND)
381
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${SPEEX_INCLUDE_DIRS})
382
endif()
383
if(SPEEXDSP_FOUND)
384
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${SPEEXDSP_INCLUDE_DIRS})
385
endif()
386
if(FFMPEG_FOUND)
387
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS})
388 389
endif()
if(VPX_FOUND)
390
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${VPX_INCLUDE_DIRS})
391
endif()
392 393
if(BCMATROSKA2_FOUND)
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${BCMATROSKA2_INCLUDE_DIRS})
394 395
endif()
if(V4L_FOUND)
396
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${V4L_INCLUDE_DIRS})
397
endif()
398
if(ALSA_FOUND)
399
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${ALSA_INCLUDE_DIRS})
400 401
endif()
if(ARTS_FOUND)
402
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${ARTS_INCLUDE_DIRS})
403 404
endif()
if(PORTAUDIO_FOUND)
405
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${PORTAUDIO_INCLUDE_DIRS})
406 407
endif()
if(PULSEAUDIO_FOUND)
408
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${PULSEAUDIO_INCLUDE_DIRS})
409 410
endif()
if(QSA_FOUND)
411
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${QSA_INCLUDE_DIRS})
412
endif()
413
if(QNXAUDIOMANAGER_FOUND)
414
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${QNXAUDIOMANAGER_INCLUDE_DIRS})
415
endif()
416
if(X11_FOUND)
417
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${X11_INCLUDE_DIRS})
418 419
endif()
if(XV_FOUND)
420
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${XV_INCLUDE_DIRS})
421
endif()
422
if(QTANGLE_FOUND)
423
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${QTANGLE_INCLUDE_DIRS})
424
endif()
425
if(OPENGL_FOUND)
426
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
427
endif()
428
if(GLX_FOUND)
429
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${GLX_INCLUDE_DIRS})
430
endif()
431
if(SCREEN_FOUND)
432
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${SCREEN_INCLUDE_DIRS})
433
endif()
434
if(CAMAPI_FOUND)
435
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${CAMAPI_INCLUDE_DIRS})
436 437
endif()
if(PCAP_FOUND)
438
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${PCAP_INCLUDE_DIRS})
439
endif()
440
if(MSVC_INCLUDE_DIR)
441
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${MSVC_INCLUDE_DIR})
442
endif()
443
if(TURBOJPEG_FOUND)
444
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${TURBOJPEG_INCLUDE_DIRS})
445
endif()
446 447 448 449 450 451
if(ENABLE_ANDROIDSND)
	include_directories(
		src/android
		src/android/media
	)
endif()
452 453 454
if(BCG729_FOUND)
	list(APPEND MEDIASTREAMER2_INCLUDE_DIRS ${BCG729_INCLUDE_DIRS})
endif()
455 456 457 458 459 460
if(ENABLE_DEBUG_LOGS)
	add_definitions(-DDEBUG)
endif()
if(ENABLE_FIXED_POINT)
	set(MS_FIXED_POINT 1)
endif()
461 462
if(ENABLE_NON_FREE_CODECS)
	set(HAVE_NON_FREE_CODECS 1)
463 464
else()
	set(HAVE_NON_FREE_CODECS 0)
465
endif()
466 467 468
if(PCAP_FOUND)
	set(HAVE_PCAP 1)
endif()
469 470 471
if(SRTP_FOUND)
	set(HAVE_SRTP 1)
endif()
472 473 474
if(BZRTP_FOUND)
	set(HAVE_ZRTP 1)
endif()
475 476 477 478 479
if(ENABLE_ALSA)
	set(__ALSA_ENABLED__ 1)
endif()
if(ENABLE_ARTSC)
	set(__ARTS_ENABLED__ 1)
480
endif()
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495
if(ENABLE_MACSND)
	set(__MACSND_ENABLED__ 1)
endif()
if(ENABLE_MACAQSND)
	set(__MAC_AQ_ENABLED__ 1)
endif()
if(ENABLE_PORTAUDIO)
	set(__PORTAUDIO_ENABLED__ 1)
endif()
if(ENABLE_PULSEAUDIO)
	set(__PULSEAUDIO_ENABLED__ 1)
endif()
if(ENABLE_QSA)
	set(__QSA_ENABLED__ 1)
endif()
496 497 498
if(ENABLE_QNX)
	set(__QNX__ 1)
endif()
499
if(SPEEXDSP_FOUND)
500 501
	set(HAVE_SPEEXDSP 1)
endif()
502
if(BCMATROSKA2_FOUND)
503 504
	set(HAVE_MATROSKA 1)
endif()
505 506 507
if(TURBO_JPEG_FOUND)
	set(HAVE_TURBO_JPEG 1)
endif()
508
if(ENABLE_RELATIVE_PREFIX)
509 510 511 512
	if(CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" OR CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
		set(PACKAGE_PLUGINS_DIR ".")
		set(PACKAGE_DATA_DIR ".")
	else()
513 514
		set(PACKAGE_PLUGINS_DIR "./${CMAKE_INSTALL_LIBDIR}/mediastreamer/plugins")
		set(PACKAGE_DATA_DIR "./${CMAKE_INSTALL_DATADIR}")
515
	endif()
516
else()
517 518
	set(PACKAGE_PLUGINS_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/mediastreamer/plugins")
	set(PACKAGE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}")
519
endif()
520
set(LINK_FLAGS )
521
if(APPLE)
522
	list(APPEND LINK_FLAGS "-framework CoreFoundation" "-framework AudioToolbox" "-framework CoreAudio")
523
	if(IOS) # Necessary for Mediastreamer's tools and testers
524
		list(APPEND LINK_FLAGS "-framework Foundation" "-framework QuartzCore" "-framework OpenGLES" "-framework UIKit" "-framework AVFoundation")
525 526
		if(ENABLE_VIDEO)
			list(APPEND LINK_FLAGS "-framework CoreGraphics" "-framework CoreMedia" "-framework CoreVideo")
527
			if(ENABLE_VT_H264) # Necessary on iOS for Mediastreamer's tools and testers
528 529
				list(APPEND LINK_FLAGS "-framework VideoToolbox")
			endif()
530
		endif()
531 532 533 534 535
	else()
		list(APPEND LINK_FLAGS "-framework AppKit")
		if(ENABLE_MACSND)
			list(APPEND LINK_FLAGS "-framework Carbon" "-framework AudioUnit")
		endif()
536
		if(ENABLE_VIDEO)
537
			list(APPEND LINK_FLAGS "-framework Cocoa" "-framework OpenGL" "-framework QuartzCore" "-framework AVFoundation")
538 539 540
			if(ENABLE_VT_H264)
				list(APPEND LINK_FLAGS "-framework VideoToolbox -framework CoreMedia")
			endif()
541 542
		endif()
		add_definitions("-DTARGET_OS_MAC=1")
543
	endif()
544
endif()
545
string(REPLACE ";" " " LINK_FLAGS_STR "${LINK_FLAGS}")
546 547
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mediastreamer-config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/mediastreamer-config.h)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/mediastreamer-config.h PROPERTIES GENERATED ON)
548
add_definitions("-DHAVE_CONFIG_H")
549

550
set(MEDIASTREAMER2_CPPFLAGS ${ORTP_CPPFLAGS} ${BZRTP_CPPFLAGS} ${BCTOOLBOX_CPPFLAGS} ${BCG729_CPPFLAGS})
551 552
if(ENABLE_STATIC)
	list(APPEND MEDIASTREAMER2_CPPFLAGS "-DMS2_STATIC")
553 554
endif()
if(MEDIASTREAMER2_CPPFLAGS)
Ghislain MARY's avatar
Ghislain MARY committed
555
	list(REMOVE_DUPLICATES MEDIASTREAMER2_CPPFLAGS)
556 557
	add_definitions(${MEDIASTREAMER2_CPPFLAGS})
endif()
558

559 560
set(STRICT_OPTIONS_CPP )
set(STRICT_OPTIONS_C )
561
set(STRICT_OPTIONS_OBJC "-Wno-error")
562 563 564 565 566 567
if(MSVC)
	list(APPEND STRICT_OPTIONS_CPP "/wd4142") # Disable "benign redefinition of type" warnings
	if(ENABLE_STRICT)
		list(APPEND STRICT_OPTIONS_CPP "/WX")
	endif()
else()
568
	list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized")
569
	list(APPEND STRICT_OPTIONS_C "-Wdeclaration-after-statement" "-Wstrict-prototypes" "-Wno-error=strict-prototypes")
570
	if(CMAKE_C_COMPILER_ID MATCHES "Clang")
571
		list(APPEND STRICT_OPTIONS_CPP "-Qunused-arguments" "-Wno-unused-function" "-Wno-array-bounds")
572 573
	elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
		list(APPEND STRICT_OPTIONS_CPP "-Wno-format-truncation")
574 575
	endif()
	if(APPLE)
576
		list(APPEND STRICT_OPTIONS_CPP "-Wno-error=unknown-warning-option" "-Qunused-arguments" "-Wno-tautological-compare" "-Wno-unused-function" "-Wno-array-bounds")
577 578
	endif()
	if(ENABLE_STRICT)
François Grisez's avatar
François Grisez committed
579
		list(APPEND STRICT_OPTIONS_CPP "-Werror" "-Wextra" "-Wno-unused-parameter" "-fno-strict-aliasing" "-Wno-missing-field-initializers" "-Wno-error=deprecated-declarations")
580 581
	endif()
endif()
582 583 584 585 586 587 588 589 590
if(STRICT_OPTIONS_CPP)
	list(REMOVE_DUPLICATES STRICT_OPTIONS_CPP)
endif()
if(STRICT_OPTIONS_C)
	list(REMOVE_DUPLICATES STRICT_OPTIONS_C)
endif()
if(STRICT_OPTIONS_OBJC)
	list(REMOVE_DUPLICATES STRICT_OPTIONS_OBJC)
endif()
591

592

593 594 595 596 597 598 599
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
	set(EXPORT_TARGETS_NAME "LinphoneBuilder")
else()
	set(EXPORT_TARGETS_NAME "Mediastreamer2")
endif()


600 601 602
if(ENABLE_DOC)
	add_subdirectory(help)
endif()
603 604
add_subdirectory(include)
add_subdirectory(src)
605
if(ENABLE_UNIT_TESTS AND BCTOOLBOX_TESTER_FOUND)
606 607
	add_subdirectory(tester)
endif()
608 609 610
if(ENABLE_TOOLS)
	add_subdirectory(tools)
endif()
611 612 613 614 615 616 617 618


include(CMakePackageConfigHelpers)
write_basic_package_version_file(
	"${CMAKE_CURRENT_BINARY_DIR}/Mediastreamer2ConfigVersion.cmake"
	VERSION ${MEDIASTREAMER_VERSION}
	COMPATIBILITY AnyNewerVersion
)
619
export(EXPORT ${EXPORT_TARGETS_NAME}Targets
620 621 622 623 624 625 626
	FILE "${CMAKE_CURRENT_BINARY_DIR}/Mediastreamer2Targets.cmake"
)
configure_file(cmake/Mediastreamer2Config.cmake.in
	"${CMAKE_CURRENT_BINARY_DIR}/Mediastreamer2Config.cmake"
	@ONLY
)

627
set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_DATADIR}/Mediastreamer2/cmake")
628
install(EXPORT ${EXPORT_TARGETS_NAME}Targets
629
	FILE Mediastreamer2Targets.cmake
630
	DESTINATION ${CONFIG_PACKAGE_LOCATION}
631 632 633 634
)
install(FILES
	"${CMAKE_CURRENT_BINARY_DIR}/Mediastreamer2Config.cmake"
	"${CMAKE_CURRENT_BINARY_DIR}/Mediastreamer2ConfigVersion.cmake"
635
	DESTINATION ${CONFIG_PACKAGE_LOCATION}
636
)
637

638
add_subdirectory(build)