CMakeLists.txt 10.8 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 24
if(MSVC)
	find_library(LIBGCC NAMES gcc)
25
	find_library(LIBMINGWEX NAMES mingwex)
26
endif()
Ghislain MARY's avatar
Ghislain MARY committed
27 28


29 30 31
find_program(AWK_PROGRAM awk)
if(NOT AWK_PROGRAM)
	message(FATAL_ERROR "You need the awk program to build mediastreamer2.")
32
endif()
33

34 35 36
set(BASE_SOURCE_FILES
	base/eventqueue.c
	base/mscommon.c
37
	base/msfactory.c
38 39 40 41 42 43 44 45 46 47 48 49 50 51
	base/msfilter.c
	base/msqueue.c
	base/mssndcard.c
	base/msticker.c
	base/mswebcam.c
	base/mtu.c
	otherfilters/itc.c
	otherfilters/join.c
	otherfilters/tee.c
	otherfilters/void.c
)

set(BASE_GENERATED_SOURCE_FILES
	${CMAKE_CURRENT_BINARY_DIR}/basedescs.h
52
	${CMAKE_CURRENT_BINARY_DIR}/gitversion.h
53
)
54 55 56 57 58 59 60 61 62
set_source_files_properties(${BASE_GENERATED_SOURCE_FILES} PROPERTIES GENERATED TRUE)
find_package(Git)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gitversion.h
	COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/gitversion.cmake)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/basedescs.h
	COMMAND ${CMAKE_COMMAND} -DAWK_PROGRAM=${AWK_PROGRAM} -DAWK_SCRIPTS_DIR=${CMAKE_CURRENT_SOURCE_DIR}/../
		-DINPUT_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR}
		-DTYPE=base -DSOURCE_FILES="${BASE_SOURCE_FILES}"
		-P ${CMAKE_CURRENT_SOURCE_DIR}/generate_descs_header.cmake)
63 64 65 66 67 68 69 70

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

72
set(BASE_LIBS
73
	${LIBGCC}
74
	${LIBMINGWEX}
75
	${ORTP_LIBRARIES}
76
)
77 78 79 80 81 82
if(WIN32)
	list(APPEND BASE_LIBS ole32 oleaut32 uuid)
endif()
if(HAVE_DLOPEN)
	list(APPEND BASE_LIBS dl)
endif()
83

84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
if(ENABLE_STATIC)
	add_library(mediastreamer_base STATIC ${BASE_SOURCE_FILES} ${BASE_GENERATED_SOURCE_FILES})
	target_link_libraries(mediastreamer_base ${BASE_LIBS})
else()
	add_library(mediastreamer_base SHARED ${BASE_SOURCE_FILES} ${BASE_GENERATED_SOURCE_FILES})
	set_target_properties(mediastreamer_base PROPERTIES VERSION ${MEDIASTREAMER_VERSION} SOVERSION ${MEDIASTREAMER_SO_VERSION} LINKER_LANGUAGE C)
	target_link_libraries(mediastreamer_base ${BASE_LIBS})
	if(MSVC)
		if(CMAKE_BUILD_TYPE STREQUAL "Debug")
			install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/mediastreamer_base.pdb
				DESTINATION bin
				PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
			)
		endif()
	endif()
endif()
100

Ghislain MARY's avatar
Ghislain MARY committed
101
install(TARGETS mediastreamer_base
Ghislain MARY's avatar
Ghislain MARY committed
102 103 104
	RUNTIME DESTINATION bin
	LIBRARY DESTINATION lib
	ARCHIVE DESTINATION lib
105 106
	PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
107 108 109 110 111 112 113



set(VOIP_SOURCE_FILES
	audiofilters/alaw.c
	audiofilters/audiomixer.c
	audiofilters/chanadapt.c
114 115
	audiofilters/devices.c
	audiofilters/devices.h
116 117
	audiofilters/dtmfgen.c
	audiofilters/equalizer.c
118
	audiofilters/flowcontrol.c
119 120
	audiofilters/g711.c
	audiofilters/g711.h
121
	audiofilters/genericplc.c
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
	audiofilters/l16.c
	audiofilters/msfileplayer.c
	audiofilters/msfilerec.c
	audiofilters/msg722.c
	audiofilters/msvolume.c
	audiofilters/tonedetector.c
	audiofilters/ulaw.c
	audiofilters/waveheader.h
	otherfilters/msrtp.c
	utils/_kiss_fft_guts.h
	utils/dsptools.c
	utils/g722.h
	utils/g722_decode.c
	utils/g722_encode.c
	utils/kiss_fft.c
	utils/kiss_fft.h
	utils/kiss_fftr.c
	utils/kiss_fftr.h
	voip/audioconference.c
	voip/audiostream.c
	voip/bitratecontrol.c
	voip/bitratedriver.c
	voip/ice.c
	voip/mediastream.c
	voip/msvoip.c
	voip/private.h
	voip/qosanalyzer.c
149
	voip/qosanalyzer.h
150 151 152 153
	voip/qualityindicator.c
	voip/ringstream.c
)

154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
if(ENABLE_ALSA)
	list(APPEND VOIP_SOURCE_FILES audiofilters/alsa.c)
endif()
if(ENABLE_ARTSC)
	list(APPEND VOIP_SOURCE_FILES audiofilters/arts.c)
endif()
if(ENABLE_MACSND)
	list(APPEND VOIP_SOURCE_FILES audiofilters/macsnd.c)
endif()
if(ENABLE_MACAQSND)
	list(APPEND VOIP_SOURCE_FILES audiofilters/aqsnd.c)
endif()
if(ENABLE_OSS)
	list(APPEND VOIP_SOURCE_FILES audiofilters/oss.c)
endif()
if(ENABLE_PORTAUDIO)
	list(APPEND VOIP_SOURCE_FILES audiofilters/pasnd.c)
endif()
if(ENABLE_PULSEAUDIO)
	list(APPEND VOIP_SOURCE_FILES audiofilters/pulseaudio.c)
endif()
if(ENABLE_QSA)
	list(APPEND VOIP_SOURCE_FILES audiofilters/qsa.c)
endif()
if(IOS)
	list(APPEND VOIP_SOURCE_FILES audiofilters/msiounit.m audiofilters/aac-eld.c)
endif()
181 182
if(WIN32)
	list(APPEND VOIP_SOURCE_FILES audiofilters/winsnd3.c)
183
endif()
184

185
if(GSM_FOUND)
186
	list(APPEND VOIP_SOURCE_FILES audiofilters/gsm.c)
187 188
endif()
if(OPUS_FOUND)
189
	list(APPEND VOIP_SOURCE_FILES audiofilters/msopus.c)
190 191
endif()
if(ENABLE_RESAMPLE)
192
	list(APPEND VOIP_SOURCE_FILES audiofilters/msresample.c)
193 194
endif()
if(SPEEX_FOUND)
195 196 197 198
	list(APPEND VOIP_SOURCE_FILES
		audiofilters/msspeex.c
		audiofilters/speexec.c
	)
199
endif()
200

201
if(ENABLE_VIDEO)
202
	list(APPEND VOIP_SOURCE_FILES
203
		utils/bits_rw.c
204 205 206 207 208 209 210 211 212 213 214
		videofilters/extdisplay.c
		videofilters/mire.c
		videofilters/pixconv.c
		videofilters/sizeconv.c
		voip/layouts.c
		voip/layouts.h
		voip/msvideo.c
		voip/msvideo_neon.c
		voip/msvideo_neon.h
		voip/rfc2429.h
		voip/rfc3984.c
Ghislain MARY's avatar
Ghislain MARY committed
215
		voip/videostarter.c
216 217
		voip/videostream.c
	)
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
	if(WIN32)
		add_definitions(-DHAVE_DIRECTSHOW)
		list(APPEND VOIP_SOURCE_FILES
			videofilters/msdscap-mingw.cc
			videofilters/drawdib-display.c
		)
		set_source_files_properties(videofilters/msdscap-mingw.cc PROPERTIES LANGUAGE CXX)
	endif(WIN32)
	# if(APPLE)
		# list(APPEND VOIP_SOURCE_FILES
			# utils/opengles_display.c
			# utils/opengles_display.h
			# utils/shaders.c
			# utils/shaders.h
			# videofilters/msosxdisplay.m
			# videofilters/qtcapture.m
		# )
	# endif(APPLE)
	if(FFMPEG_FOUND)
237 238
		list(APPEND VOIP_SOURCE_FILES
			utils/ffmpeg-priv.c
239
			utils/ffmpeg-priv.h
240 241 242 243 244 245 246 247
			utils/swscale.h
			videofilters/h264dec.c
			videofilters/jpegwriter.c
			videofilters/nowebcam.c
			videofilters/videodec.c
			videofilters/videoenc.c
			voip/nowebcam.h
		)
248 249
	endif()
	if(GLX_FOUND)
250 251 252
		list(APPEND VOIP_SOURCE_FILES
			utils/opengles_display.c
			utils/shaders.c
253
			videofilters/glxvideo.c
254
		)
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
	endif()
	if(SDL_FOUND)
		list(APPEND VOIP_SOURCE_FILES videofilters/videoout.c)
	endif()
	if(THEORA_FOUND)
		list(APPEND VOIP_SOURCE_FILES videofilters/theora.c)
	endif()
	if(VPX_FOUND)
		list(APPEND VOIP_SOURCE_FILES
			videofilters/vp8.c
			voip/vp8rtpfmt.c
			voip/vp8rtpfmt.h
		)
	endif()
	if(X11_FOUND)
		list(APPEND VOIP_SOURCE_FILES utils/x11_helper.c)
	endif()
	if(XV_FOUND)
		list(APEEND VOIP_SOURCE_FILES videofilters/x11video.c)
	endif()
endif()
276

277 278 279
set(VOIP_GENERATED_SOURCE_FILES
	${CMAKE_CURRENT_BINARY_DIR}/voipdescs.h
)
280 281 282 283 284 285
set_source_files_properties(${VOIP_GENERATED_SOURCE_FILES} PROPERTIES GENERATED TRUE)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/voipdescs.h
	COMMAND ${CMAKE_COMMAND} -DAWK_PROGRAM=${AWK_PROGRAM} -DAWK_SCRIPTS_DIR=${CMAKE_CURRENT_SOURCE_DIR}/../
		-DINPUT_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR}
		-DTYPE=voip -DSOURCE_FILES="${VOIP_SOURCE_FILES}"
		-P ${CMAKE_CURRENT_SOURCE_DIR}/generate_descs_header.cmake)
286

287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
# if(APPLE)
# list(APPEND VOIP_GENERATED_SOURCE_FILES
	# ${CMAKE_CURRENT_BINARY_DIR}/yuv2rgb.fs.h
	# ${CMAKE_CURRENT_BINARY_DIR}/yuv2rgb.vs.h
# )
# execute_process(
	# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
	# COMMAND xxd -i yuv2rgb.fs | sed s/}\;/,0x00}\;/
	# OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/yuv2rgb.fs.h
# )
# execute_process(
	# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
	# COMMAND xxd -i yuv2rgb.vs | sed s/}\;/,0x00}\;/
	# OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/yuv2rgb.vs.h
# )
# endif(APPLE)
303

304 305

set(VOIP_LIBS
306
	${LIBGCC}
307
	${LIBMINGWEX}
308
	${ORTP_LIBRARIES}
Ghislain MARY's avatar
Ghislain MARY committed
309
	mediastreamer_base
310
)
311 312 313 314
if(WIN32)
	list(APPEND VOIP_LIBS ole32 oleaut32 uuid)
	if(ENABLE_VIDEO)
		list(APPEND VOIP_LIBS gdi32 user32 vfw32)
315
	endif()
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
endif()
if(HAVE_DLOPEN)
	list(APPEND VOIP_LIBS dl)
endif()
if(ENABLE_MACSND)
	list(APPEND CMAKE_SHARED_LINKER_FLAGS "-framework Carbon" "-framework AudioUnit")
endif()
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()
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})
endif()
if(FFMPEG_FOUND)
	list(APPEND VOIP_LIBS ${FFMPEG_LIBRARIES})
	if(MSVC)
		add_definitions(-Dinline=__inline)
	endif()
endif()
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()
365

366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
if(ENABLE_STATIC)
	add_library(mediastreamer_voip STATIC ${VOIP_SOURCE_FILES} ${VOIP_GENERATED_SOURCE_FILES})
	target_link_libraries(mediastreamer_voip ${VOIP_LIBS})
else()
	add_library(mediastreamer_voip SHARED ${VOIP_SOURCE_FILES} ${VOIP_GENERATED_SOURCE_FILES})
	set_target_properties(mediastreamer_voip PROPERTIES VERSION ${MEDIASTREAMER_VERSION} SOVERSION ${MEDIASTREAMER_SO_VERSION} LINKER_LANGUAGE CXX)
	target_link_libraries(mediastreamer_voip ${VOIP_LIBS})
	if(MSVC)
		if(CMAKE_BUILD_TYPE STREQUAL "Debug")
			install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/mediastreamer_voip.pdb
				DESTINATION bin
				PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
			)
		endif()
	endif()
endif()
382

Ghislain MARY's avatar
Ghislain MARY committed
383
install(TARGETS mediastreamer_voip
Ghislain MARY's avatar
Ghislain MARY committed
384 385 386
	RUNTIME DESTINATION bin
	LIBRARY DESTINATION lib
	ARCHIVE DESTINATION lib
387 388
	PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
389 390 391 392 393 394

if(ENABLE_VIDEO)
	install(FILES voip/nowebcamCIF.jpg
		DESTINATION ${PACKAGE_DATA_DIR}/images
        PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
	)
395
endif()
396 397 398 399 400 401 402


# if(MS2_ENABLE_VIDEO)
	# if(APPLE)
		# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -framework Cocoa -framework OpenGL -framework QuartzCore")
	# endif(APPLE)
# endif(MS2_ENABLE_VIDEO)