CMakeLists.txt 5 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

Ghislain MARY's avatar
Ghislain MARY committed
26
if(${Threads_FOUND})
27
	if(CMAKE_USE_PTHREADS_INIT AND NOT CMAKE_SYSTEM_NAME MATCHES "QNX")
Ghislain MARY's avatar
Ghislain MARY committed
28
		list(APPEND LIBS pthread)
Ghislain MARY's avatar
Ghislain MARY committed
29 30
	endif()
endif()
31 32
if(${HAVE_LIBDL})
	list(APPEND LIBS dl)
Ghislain MARY's avatar
Ghislain MARY committed
33
endif()
34 35 36
if(${HAVE_LIBRT})
	list(APPEND LIBS rt)
endif()
37 38
if(${HAVE_RESINIT})
	list(APPEND LIBS resolv)
Ghislain MARY's avatar
Ghislain MARY committed
39
endif()
40 41
if(WIN32)
	list(APPEND LIBS ws2_32)
Ghislain MARY's avatar
Ghislain MARY committed
42
endif()
Ghislain MARY's avatar
Ghislain MARY committed
43

44
set(SDP_GENERATED_SOURCE_FILES
45 46 47 48
	${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
49 50 51
)
add_custom_command(
	OUTPUT ${SDP_GENERATED_SOURCE_FILES}
52
	COMMAND ${ANTLR3_COMMAND} -make -Xmultithreaded -Xconversiontimeout 10000 -fo ${CMAKE_CURRENT_BINARY_DIR}/grammars ${CMAKE_CURRENT_SOURCE_DIR}/grammars/belle_sdp.g
53
	DEPENDS grammars/belle_sdp.g
54 55 56
)

set(SIP_MESSAGE_GENERATED_SOURCE_FILES
57 58 59 60
	${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
61 62 63
)
add_custom_command(
	OUTPUT ${SIP_MESSAGE_GENERATED_SOURCE_FILES}
64
	COMMAND ${ANTLR3_COMMAND} -make -Xmultithreaded -Xconversiontimeout 10000 -fo ${CMAKE_CURRENT_BINARY_DIR}/grammars ${CMAKE_CURRENT_SOURCE_DIR}/grammars/belle_sip_message.g
65
	DEPENDS grammars/belle_sip_message.g
66 67
)

68 69 70 71 72 73 74
set_source_files_properties(${GRAMMARS_SOURCE_FILES} ${SIP_MESSAGE_GENERATED_SOURCE_FILES} PROPERTIES GENERATED TRUE)

if(${ENABLE_TLS})
	set(TLS_SOURCE_FILES
		transports/tls_listeningpoint_polarssl.c
		transports/tls_channel_polarssl.c
	)
75
	list(APPEND INCLUDES ${POLARSSL_INCLUDE_DIR})
76
	list(APPEND LIBS ${POLARSSL_LIBRARIES})
Ghislain MARY's avatar
Ghislain MARY committed
77
endif()
78 79 80 81 82 83 84

if(${ENABLE_TUNNEL})
	set(TUNNEL_SOURCE_FILES
		transports/tunnel_listeningpoint.c
		transports/tunnel_channel.c
		transports/tunnel_wrapper.cc
	)
85
	set_source_files_properties(transports/tunnel_wrapper.cc PROPERTIES LANGUAGE CXX)
86
	list(APPEND LIBS ${TUNNEL_LIBRARIES})
Ghislain MARY's avatar
Ghislain MARY committed
87
endif()
88

89 90 91 92
set(SOURCE_FILES
	auth_event.c
	auth_helper.c
	belle_sdp_impl.c
93
	belle_sip_dict.c
94
	belle_sip_headers_impl.c
95
	belle_sip_internal.h
96 97 98 99 100 101
	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
102
	bodyhandler.c
103
	channel.c
104 105 106
	channel.h
	clock_gettime.c
	clock_gettime.h
107 108
	dialog.c
	dns.c
109 110 111 112 113
	dns.h
	generic-uri.c
	http-listener.c
	http-message.c
	http-provider.c
114 115 116
	ict.c
	ist.c
	listeningpoint.c
117
	listeningpoint_internal.h
118
	md5.c
119
	md5.h
120 121 122
	message.c
	nict.c
	nist.c
123
	parserutils.h
124
	port.c
125
	port.h
126 127 128 129 130 131
	provider.c
	refresher.c
	siplistener.c
	sipstack.c
	transaction.c
	transports/stream_channel.c
132
	transports/stream_channel.h
133 134 135 136 137
	transports/stream_listeningpoint.c
	transports/udp_channel.c
	transports/udp_listeningpoint.c
	${SDP_GENERATED_SOURCE_FILES}
	${SIP_MESSAGE_GENERATED_SOURCE_FILES}
138 139
	${TLS_SOURCE_FILES}
	${TUNNEL_SOURCE_FILES}
140
)
141 142
if(APPLE)
	list(APPEND SOURCE_FILES backgroundtask.m)
143
	set_source_files_properties(backgroundtask.m PROPERTIES COMPILE_FLAGS "-fmodules")
144
endif()
145

146 147
if(${ENABLE_STATIC})
	add_library(bellesip STATIC ${SOURCE_FILES})
Ghislain MARY's avatar
Ghislain MARY committed
148
else()
149
	add_library(bellesip SHARED ${SOURCE_FILES})
150
	set_target_properties(bellesip PROPERTIES VERSION 0.0.0 SOVERSION 0)
151 152 153 154 155 156 157
	if(MSVC)
		if(CMAKE_BUILD_TYPE STREQUAL "Debug")
			install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/bellesip.pdb
				DESTINATION bin
				PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
			)
		endif()
Ghislain MARY's avatar
Ghislain MARY committed
158 159
	endif()
endif()
160
set_target_properties(bellesip PROPERTIES LINKER_LANGUAGE CXX LINK_FLAGS "${LINK_FLAGS}")
161 162
if("${CMAKE_VERSION}" VERSION_GREATER "2.8.10")
	target_include_directories(bellesip PUBLIC ${INCLUDES})
Ghislain MARY's avatar
Ghislain MARY committed
163
else()
164
	include_directories(${INCLUDES})
Ghislain MARY's avatar
Ghislain MARY committed
165
endif()
166 167
target_link_libraries(bellesip ${LIBS})

168
install(TARGETS bellesip EXPORT BelleSIPTargets
169 170 171
	RUNTIME DESTINATION bin
	LIBRARY DESTINATION lib
	ARCHIVE DESTINATION lib
172 173
	PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)