• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (C) 2015-2015 Oleg Alexeenkov
3# Copyright (C) 2015-2019 Felix Weinrank
4#
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
10# 1. Redistributions of source code must retain the above copyright
11#    notice, this list of conditions and the following disclaimer.
12# 2. Redistributions in binary form must reproduce the above copyright
13#    notice, this list of conditions and the following disclaimer in the
14#    documentation and/or other materials provided with the distribution.
15# 3. Neither the name of the project nor the names of its contributors
16#    may be used to endorse or promote products derived from this software
17#    without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29# SUCH DAMAGE.
30#
31
32
33#################################################
34# INCLUDE MODULES AND SETTINGS
35#################################################
36
37set(VERSION "1.0.0")
38
39set(prefix 					${CMAKE_INSTALL_PREFIX})
40set(exec_prefix 			${prefix})
41set(libdir 					${exec_prefix}/lib)
42set(includedir 				${prefix}/include/usrsctp)
43set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR})
44set(CMAKE_MACOSX_RPATH 		1)
45
46include(CheckCCompilerFlag)
47
48add_definitions(-D__Userspace__)
49add_definitions(-D__Userspace_os_${CMAKE_SYSTEM_NAME})
50add_definitions(-DSCTP_SIMPLE_ALLOCATOR)
51add_definitions(-DSCTP_PROCESS_LEVEL_LOCKS)
52
53
54#################################################
55# OS DEPENDENT
56#################################################
57
58check_c_compiler_flag(-Wno-address-of-packed-member has_wno_address_of_packed_member)
59if (has_wno_address_of_packed_member)
60	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-address-of-packed-member")
61endif ()
62
63check_c_compiler_flag(-Wno-deprecated-declarations has_wno_deprecated_declarations)
64if (has_wno_deprecated_declarations)
65	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
66endif ()
67
68if (CMAKE_SYSTEM_NAME MATCHES "Linux")
69	add_definitions(-D_GNU_SOURCE)
70endif ()
71
72if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
73	add_definitions(-U__FreeBSD__)
74endif ()
75
76if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
77	add_definitions(-U__APPLE__)
78	add_definitions(-D__APPLE_USE_RFC_2292)
79endif ()
80
81if (CMAKE_SYSTEM_NAME MATCHES "DragonFly")
82	add_definitions(-U__DragonFly__)
83endif ()
84
85if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
86	add_definitions(-U__NetBSD__)
87endif ()
88
89if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
90	add_definitions(-U__OpenBSD__)
91endif ()
92
93#################################################
94# MISC
95#################################################
96
97
98
99#################################################
100# LIBRARY FILES
101#################################################
102
103include_directories(${CMAKE_CURRENT_SOURCE_DIR})
104
105list(APPEND usrsctp_root_headers
106	user_atomic.h
107	user_environment.h
108	user_inpcb.h
109	user_ip_icmp.h
110	user_ip6_var.h
111	user_malloc.h
112	user_mbuf.h
113	user_queue.h
114	user_recv_thread.h
115	user_route.h
116	user_socketvar.h
117	user_uma.h
118	usrsctp.h
119)
120
121list(APPEND usrsctp_netinet_headers
122	netinet/sctp_asconf.h
123	netinet/sctp_auth.h
124	netinet/sctp_bsd_addr.h
125	netinet/sctp_callout.h
126	netinet/sctp_constants.h
127	netinet/sctp_crc32.h
128	netinet/sctp_header.h
129	netinet/sctp_indata.h
130	netinet/sctp_input.h
131	netinet/sctp_lock_userspace.h
132	netinet/sctp_os_userspace.h
133	netinet/sctp_os.h
134	netinet/sctp_output.h
135	netinet/sctp_pcb.h
136	netinet/sctp_peeloff.h
137	netinet/sctp_process_lock.h
138	netinet/sctp_sha1.h
139	netinet/sctp_structs.h
140	netinet/sctp_sysctl.h
141	netinet/sctp_timer.h
142	netinet/sctp_uio.h
143	netinet/sctp_var.h
144	netinet/sctputil.h
145	netinet/sctp.h
146)
147
148list(APPEND usrsctp_netinet6_headers
149	netinet6/sctp6_var.h
150)
151
152list(APPEND usrsctp_headers
153	${usrsctp_root_headers}
154	${usrsctp_netinet_headers}
155	${usrsctp_netinet6_headers}
156)
157
158list(APPEND usrsctp_sources
159	netinet/sctp_asconf.c
160	netinet/sctp_auth.c
161	netinet/sctp_bsd_addr.c
162	netinet/sctp_callout.c
163	netinet/sctp_cc_functions.c
164	netinet/sctp_crc32.c
165	netinet/sctp_indata.c
166	netinet/sctp_input.c
167	netinet/sctp_output.c
168	netinet/sctp_pcb.c
169	netinet/sctp_peeloff.c
170	netinet/sctp_sha1.c
171	netinet/sctp_ss_functions.c
172	netinet/sctp_sysctl.c
173	netinet/sctp_timer.c
174	netinet/sctp_userspace.c
175	netinet/sctp_usrreq.c
176	netinet/sctputil.c
177	netinet6/sctp6_usrreq.c
178	user_environment.c
179	user_mbuf.c
180	user_recv_thread.c
181	user_socket.c
182)
183
184add_library(usrsctp SHARED ${usrsctp_sources} ${usrsctp_headers})
185add_library(usrsctp-static STATIC ${usrsctp_sources} ${usrsctp_headers})
186
187target_include_directories(usrsctp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
188target_include_directories(usrsctp-static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
189
190if (WIN32)
191	message(STATUS "link library: ws2_32")
192	target_link_libraries(usrsctp ws2_32 iphlpapi.lib)
193	target_link_libraries(usrsctp-static ws2_32 iphlpapi.lib)
194endif ()
195
196set_target_properties(usrsctp-static PROPERTIES OUTPUT_NAME "usrsctp")
197set_target_properties(usrsctp PROPERTIES IMPORT_SUFFIX "_import.lib")
198set_target_properties(usrsctp PROPERTIES SOVERSION 1 VERSION 1.0.0)
199
200if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
201	SET(CMAKE_INSTALL_LIBDIR lib)
202endif ()
203
204
205#################################################
206# INSTALL LIBRARY AND HEADER
207#################################################
208
209install(TARGETS usrsctp usrsctp-static DESTINATION ${CMAKE_INSTALL_LIBDIR})
210install(FILES usrsctp.h DESTINATION include)
211