CMakeLists.txt 6.22 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
set(INCLUDES ${ANTLR3C_INCLUDE_DIRS})
24
set(LIBS ${ANTLR3C_LIBRARIES})
25

26 27
list(APPEND INCLUDES ${BCTOOLBOX_CORE_INCLUDE_DIR})
list(APPEND LIBS ${BCTOOLBOX_CORE_LIBRARIES})
28

29
if(Threads_FOUND)
30 31
	if(CMAKE_USE_PTHREADS_INIT AND NOT CMAKE_SYSTEM_NAME MATCHES "QNX" AND NOT ANDROID)
		list(APPEND LIBS ${CMAKE_THREAD_LIBS_INIT})
Ghislain MARY's avatar
Ghislain MARY committed
32 33
	endif()
endif()
34
if(HAVE_LIBDL)
35
	list(APPEND LIBS dl)
Ghislain MARY's avatar
Ghislain MARY committed
36
endif()
37
if(HAVE_LIBRT)
38 39
	list(APPEND LIBS rt)
endif()
40
if(HAVE_RESINIT)
41
	list(APPEND LIBS resolv)
Ghislain MARY's avatar
Ghislain MARY committed
42
endif()
Ghislain MARY's avatar
Ghislain MARY committed
43 44 45
if(ZLIB_FOUND)
	list(APPEND LIBS ${ZLIB_LIBRARIES})
endif()
46 47
if(WIN32)
	list(APPEND LIBS ws2_32)
Ghislain MARY's avatar
Ghislain MARY committed
48
endif()
Ghislain MARY's avatar
Ghislain MARY committed
49

50
set(SDP_GENERATED_SOURCE_FILES_C
51 52 53 54
	${CMAKE_CURRENT_BINARY_DIR}/grammars/belle_sdpLexer.c
	${CMAKE_CURRENT_BINARY_DIR}/grammars/belle_sdpLexer.h
	${CMAKE_CURRENT_BINARY_DIR}/grammars/belle_sdpParser.c
	${CMAKE_CURRENT_BINARY_DIR}/grammars/belle_sdpParser.h
55 56
)
add_custom_command(
57
	OUTPUT ${SDP_GENERATED_SOURCE_FILES_C}
58
	COMMAND ${ANTLR3_COMMAND} -make -Xmultithreaded -Xconversiontimeout 10000 -fo ${CMAKE_CURRENT_BINARY_DIR}/grammars ${CMAKE_CURRENT_SOURCE_DIR}/grammars/belle_sdp.g
59
	DEPENDS grammars/belle_sdp.g
60 61
)

62
set(SIP_MESSAGE_GENERATED_SOURCE_FILES_C
63 64 65 66
	${CMAKE_CURRENT_BINARY_DIR}/grammars/belle_sip_messageLexer.c
	${CMAKE_CURRENT_BINARY_DIR}/grammars/belle_sip_messageLexer.h
	${CMAKE_CURRENT_BINARY_DIR}/grammars/belle_sip_messageParser.c
	${CMAKE_CURRENT_BINARY_DIR}/grammars/belle_sip_messageParser.h
67 68
)
add_custom_command(
69
	OUTPUT ${SIP_MESSAGE_GENERATED_SOURCE_FILES_C}
70
	COMMAND ${ANTLR3_COMMAND} -make -Xmultithreaded -Xconversiontimeout 10000 -fo ${CMAKE_CURRENT_BINARY_DIR}/grammars ${CMAKE_CURRENT_SOURCE_DIR}/grammars/belle_sip_message.g
71
	DEPENDS grammars/belle_sip_message.g
72 73
)

74
set_source_files_properties(${SDP_GENERATED_SOURCE_FILES_C} ${SIP_MESSAGE_GENERATED_SOURCE_FILES_C} PROPERTIES GENERATED TRUE)
75

76
if(ENABLE_TUNNEL)
77
	set(TUNNEL_SOURCE_FILES_C
78 79
		transports/tunnel_listeningpoint.c
		transports/tunnel_channel.c
80 81
	)
	set(TUNNEL_SOURCE_FILES_CXX
82 83 84
		transports/tunnel_wrapper.cc
	)
	list(APPEND LIBS ${TUNNEL_LIBRARIES})
Ghislain MARY's avatar
Ghislain MARY committed
85
endif()
86

87
set(BELLE_SIP_SOURCE_FILES_C
88 89 90
	auth_event.c
	auth_helper.c
	belle_sdp_impl.c
91
	belle_sip_dict.c
92
	belle_sip_headers_impl.c
93
	belle_sip_internal.h
94 95 96 97 98 99
	belle_sip_loop.c
	belle_sip_object.c
	belle_sip_parameters.c
	belle_sip_resolver.c
	belle_sip_uri_impl.c
	belle_sip_utils.c
Ghislain MARY's avatar
Ghislain MARY committed
100
	bodyhandler.c
101
	channel.c
102 103 104
	channel.h
	clock_gettime.c
	clock_gettime.h
105 106
	dialog.c
	dns.c
107 108 109 110 111
	dns.h
	generic-uri.c
	http-listener.c
	http-message.c
	http-provider.c
112 113 114
	ict.c
	ist.c
	listeningpoint.c
115
	listeningpoint_internal.h
116
	md5.c
117
	md5.h
118 119 120
	message.c
	nict.c
	nist.c
121
	parserutils.h
122
	port.c
123
	port.h
124 125 126 127 128 129
	provider.c
	refresher.c
	siplistener.c
	sipstack.c
	transaction.c
	transports/stream_channel.c
130
	transports/stream_channel.h
131 132 133
	transports/stream_listeningpoint.c
	transports/udp_channel.c
	transports/udp_listeningpoint.c
134 135
	transports/tls_listeningpoint.c
	transports/tls_channel.c
136 137 138 139
	${SDP_GENERATED_SOURCE_FILES_C}
	${SIP_MESSAGE_GENERATED_SOURCE_FILES_C}
	${TUNNEL_SOURCE_FILES_C}
)
140 141 142
if(ANDROID)
	list(APPEND BELLE_SIP_SOURCE_FILES_C wakelock.c)
endif()
143 144
set(BELLE_SIP_SOURCE_FILES_CXX
	${TUNNEL_SOURCE_FILES_CXX}
145
)
146
if(APPLE)
147 148 149 150 151 152 153 154 155 156
	set(BELLE_SIP_SOURCE_FILES_OBJC
		backgroundtask.m
	)
endif()

apply_compile_flags(BELLE_SIP_SOURCE_FILES_C "CPP" "C")
apply_compile_flags(BELLE_SIP_SOURCE_FILES_OBJC "CPP" "OBJC")
if(BELLE_SIP_SOURCE_FILES_CXX)
	set_source_files_properties(${BELLE_SIP_SOURCE_FILES_CXX} PROPERTIES LANGUAGE CXX)
	apply_compile_flags(BELLE_SIP_SOURCE_FILES_CXX "CPP" "CXX")
157
endif()
158

159
string(REPLACE ";" " " LINK_FLAGS_STR "${LINK_FLAGS}")
160
if(ENABLE_STATIC)
161
	add_library(bellesip-static STATIC ${BELLE_SIP_HEADER_FILES} ${BELLE_SIP_SOURCE_FILES_C} ${BELLE_SIP_SOURCE_FILES_CXX} ${BELLE_SIP_SOURCE_FILES_OBJC})
162
	set_target_properties(bellesip-static PROPERTIES OUTPUT_NAME bellesip)
163
	target_include_directories(bellesip-static PUBLIC ${INCLUDES})
164 165
	target_link_libraries(bellesip-static ${LIBS})
	if(NOT "${LINK_FLAGS_STR}" STREQUAL "")
Ghislain MARY's avatar
Ghislain MARY committed
166
		set_target_properties(bellesip-static PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
167 168 169 170 171 172 173
	endif()
	install(TARGETS bellesip-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)
174
	add_library(bellesip SHARED ${BELLE_SIP_HEADER_FILES} ${BELLE_SIP_SOURCE_FILES_C} ${BELLE_SIP_SOURCE_FILES_CXX} ${BELLE_SIP_SOURCE_FILES_OBJC})
175
	set_target_properties(bellesip PROPERTIES SOVERSION 0)
176
	set_target_properties(bellesip PROPERTIES LINKER_LANGUAGE CXX)
177
	target_include_directories(bellesip PUBLIC ${INCLUDES})
178 179 180 181
	target_link_libraries(bellesip ${LIBS})
	if(NOT "${LINK_FLAGS_STR}" STREQUAL "")
		set_target_properties(bellesip PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
	endif()
182 183 184
	if(MSVC)
		if(CMAKE_BUILD_TYPE STREQUAL "Debug")
			install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/bellesip.pdb
185
				DESTINATION ${CMAKE_INSTALL_BINDIR}
186 187 188
				PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
			)
		endif()
Ghislain MARY's avatar
Ghislain MARY committed
189
	endif()
190 191 192 193 194 195
	install(TARGETS bellesip 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
	)
Ghislain MARY's avatar
Ghislain MARY committed
196
endif()