CMakeLists.txt 4.23 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) 2015  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 24
string(REPLACE ";" " " LINK_FLAGS_STR "${LINK_FLAGS}")

25 26 27
set(USE_BUNDLE )
if (IOS)
	set(USE_BUNDLE MACOSX_BUNDLE)
28 29
endif()

30 31 32 33 34 35 36 37 38
if(ENABLE_SHARED)
	set(MS2_LIBS_FOR_TOOLS mediastreamer_voip mediastreamer_base)
else()
	set(MS2_LIBS_FOR_TOOLS mediastreamer_voip-static mediastreamer_base-static)
	if(XV_FOUND)
		list(APPEND MS2_LIBS_FOR_TOOLS Xext)
	endif()
endif()

39
set(simple_executables bench ring mtudiscover tones)
40
if(ENABLE_VIDEO)
41 42 43 44
	list(APPEND simple_executables videodisplay)
	if(X11_FOUND)
		list(APPEND simple_executables test_x11window)
	endif()
45
endif()
46
foreach(simple_executable ${simple_executables})
47
	set(${simple_executable}_SOURCE_FILES ${simple_executable}.c)
48
	bc_apply_compile_flags(${simple_executable}_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_C)
49
	add_executable(${simple_executable} ${USE_BUNDLE} ${simple_executable}.c)
50 51 52 53
	target_link_libraries(${simple_executable} ${MS2_LIBS_FOR_TOOLS} ${ORTP_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES})
	if(simple_executable STREQUAL "test_x11window")
		target_link_libraries(${simple_executable} ${X11_LIBRARIES})
	endif()
54 55 56
	if(LINK_FLAGS_STR)
		set_target_properties(${simple_executable} PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
	endif()
57 58
endforeach()

59
set(ECHO_SOURCE_FILES echo.c)
François Grisez's avatar
François Grisez committed
60
bc_apply_compile_flags(ECHO_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_C)
61
add_executable(ms-echo ${USE_BUNDLE} ${ECHO_SOURCE_FILES}) # Do not name the target "echo" to avoid conflict with the shell echo command
62
target_link_libraries(ms-echo ${MS2_LIBS_FOR_TOOLS} ${ORTP_LIBRARIES})
63 64 65
if(LINK_FLAGS_STR)
	set_target_properties(ms-echo PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
endif()
66

67
if(PCAP_FOUND)
68
	set(PCAP_PLAYBACK_SOURCE_FILES pcap_playback.c common.c)
69
	bc_apply_compile_flags(PCAP_PLAYBACK_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_C)
70
	add_executable(pcap_playback ${USE_BUNDLE} ${PCAP_PLAYBACK_SOURCE_FILES})
71
	target_link_libraries(pcap_playback ${MS2_LIBS_FOR_TOOLS} ${PCAP_LIBRARIES})
72
	target_include_directories(pcap_playback PUBLIC ${PCAP_INCLUDE_DIRS})
73 74 75
	if(LINK_FLAGS_STR)
		set_target_properties(pcap_playback PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
	endif()
76 77
endif()

78 79 80 81 82 83
if (NOT IOS)
	set(MEDIASTREAM_SOURCE_FILES_C mediastream.c common.c)
	set(MEDIASTREAM_SOURCE_FILES_OBJC )
	if(APPLE)
		list(APPEND MEDIASTREAM_SOURCE_FILES_OBJC mediastream_cocoa.m)
	endif()
84 85
	bc_apply_compile_flags(MEDIASTREAM_SOURCE_FILES_C STRICT_OPTIONS_CPP STRICT_OPTIONS_C)
	bc_apply_compile_flags(MEDIASTREAM_SOURCE_FILES_OBJC STRICT_OPTIONS_CPP STRICT_OPTIONS_OBJC)
86
	add_executable(mediastream ${USE_BUNDLE} ${MEDIASTREAM_SOURCE_FILES_C} ${MEDIASTREAM_SOURCE_FILES_OBJC})
87
	target_link_libraries(mediastream ${MS2_LIBS_FOR_TOOLS} ${ORTP_LIBRARIES})
88 89 90
	if(LINK_FLAGS_STR)
		set_target_properties(mediastream PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
	endif()
91
endif()
92

93
if(ENABLE_VIDEO)
94
	set(MKVSTREAM_SOURCE_FILES mkvstream.c)
95
	bc_apply_compile_flags(MKVSTREAM_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_C)
96
	add_executable(mkvstream ${USE_BUNDLE} ${MKVSTREAM_SOURCE_FILES})
97
	target_link_libraries(mkvstream ${MS2_LIBS_FOR_TOOLS} ${ORTP_LIBRARIES})
98 99 100
	if(LINK_FLAGS_STR)
		set_target_properties(mkvstream PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
	endif()
101

102 103 104 105 106
	if (NOT IOS)
		install(TARGETS mediastream mkvstream
			RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
		)
	endif()
107
endif()