udp: fix csum computation when offload disabled
[vpp.git] / src / vppinfra / CMakeLists.txt
1 # Copyright (c) 2018 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 enable_language(ASM)
15
16 ##############################################################################
17 # Generate vppinfra/config.h
18 ##############################################################################
19 set(LOG2_CACHE_LINE_BYTES ${VPP_LOG2_CACHE_LINE_SIZE})
20
21 option(VPP_VECTOR_GROW_BY_ONE "Vectors grow by one, instead of 3/2" OFF)
22 if(VPP_VECTOR_GROW_BY_ONE)
23   set(VECTOR_GROW_BY_ONE 1)
24 else(VPP_VECTOR_GROW_BY_ONE)
25   set(VECTOR_GROW_BY_ONE 0)
26 endif(VPP_VECTOR_GROW_BY_ONE)
27
28 configure_file(
29   ${CMAKE_SOURCE_DIR}/vppinfra/config.h.in
30   ${CMAKE_CURRENT_BINARY_DIR}/config.h
31 )
32
33 install(
34   FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h
35   DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/vppinfra
36   COMPONENT vpp-dev
37 )
38
39 add_definitions(-fvisibility=hidden)
40
41 # Ensure symbols from cJSON are exported
42 set_source_files_properties( cJSON.c jsonformat.c PROPERTIES
43   COMPILE_DEFINITIONS " CJSON_API_VISIBILITY " )
44
45
46 ##############################################################################
47 # vppinfra sources
48 ##############################################################################
49 set(VPPINFRA_SRCS
50   backtrace.c
51   bitmap.c
52   bihash_all_vector.c
53   cpu.c
54   dlmalloc.c
55   elf.c
56   elog.c
57   error.c
58   fifo.c
59   format.c
60   format_table.c
61   hash.c
62   heap.c
63   interrupt.c
64   jsonformat.c
65   longjmp.S
66   macros.c
67   maplog.c
68   mem.c
69   mem_bulk.c
70   mem_dlmalloc.c
71   mhash.c
72   mpcap.c
73   pcap.c
74   pmalloc.c
75   pool.c
76   ptclosure.c
77   random_buffer.c
78   random.c
79   random_isaac.c
80   rbtree.c
81   serialize.c
82   socket.c
83   std-formats.c
84   string.c
85   time.c
86   time_range.c
87   timing_wheel.c
88   tw_timer_2t_2w_512sl.c
89   tw_timer_16t_1w_2048sl.c
90   tw_timer_16t_2w_512sl.c
91   tw_timer_1t_3w_1024sl_ov.c
92   tw_timer_2t_1w_2048sl.c
93   tw_timer_4t_3w_256sl.c
94   unformat.c
95   unix-formats.c
96   unix-misc.c
97   valloc.c
98   vec.c
99   vector.c
100   vector/toeplitz.c
101   cJSON.c
102 )
103
104 set(VPPINFRA_HEADERS
105   bihash_12_4.h
106   bihash_16_8.h
107   bihash_24_8.h
108   bihash_32_8.h
109   bihash_40_8.h
110   bihash_48_8.h
111   bihash_8_8.h
112   bihash_8_16.h
113   bihash_24_16.h
114   bihash_template.c
115   bihash_template.h
116   bihash_vec8_8.h
117   bitmap.h
118   bitops.h
119   byte_order.h
120   cache.h
121   callback.h
122   callback_data.h
123   cJSON.h
124   clib_error.h
125   clib.h
126   cpu.h
127   crc32.h
128   crypto/sha2.h
129   crypto/ghash.h
130   crypto/aes.h
131   crypto/aes_cbc.h
132   crypto/aes_ctr.h
133   crypto/aes_gcm.h
134   crypto/poly1305.h
135   dlist.h
136   dlmalloc.h
137   elf_clib.h
138   elf.h
139   elog.h
140   error_bootstrap.h
141   error.h
142   fifo.h
143   file.h
144   format.h
145   format_table.h
146   hash.h
147   heap.h
148   interrupt.h
149   jsonformat.h
150   lb_hash_hash.h
151   llist.h
152   lock.h
153   longjmp.h
154   macros.h
155   maplog.h
156   math.h
157   memcpy.h
158   memcpy_x86_64.h
159   mem.h
160   mhash.h
161   mpcap.h
162   os.h
163   pcap.h
164   pcap_funcs.h
165   pcg.h
166   perfmon/perfmon.h
167   pmalloc.h
168   pool.h
169   ptclosure.h
170   random_buffer.h
171   random.h
172   random_isaac.h
173   rbtree.h
174   serialize.h
175   smp.h
176   socket.h
177   sparse_vec.h
178   string.h
179   time.h
180   time_range.h
181   timing_wheel.h
182   tw_timer_2t_2w_512sl.h
183   tw_timer_16t_1w_2048sl.h
184   tw_timer_16t_2w_512sl.h
185   tw_timer_1t_3w_1024sl_ov.h
186   tw_timer_2t_1w_2048sl.h
187   tw_timer_4t_3w_256sl.h
188   tw_timer_template.c
189   tw_timer_template.h
190   types.h
191   atomics.h
192   unix.h
193   valloc.h
194   vec_bootstrap.h
195   vec.h
196   vector_altivec.h
197   vector_avx2.h
198   vector_avx512.h
199   vector/array_mask.h
200   vector/compress.h
201   vector/count_equal.h
202   vector/index_to_ptr.h
203   vector/ip_csum.h
204   vector/mask_compare.h
205   vector/toeplitz.h
206   vector.h
207   vector_neon.h
208   vector_sse42.h
209   warnings.h
210   xxhash.h
211   linux/sysfs.h
212 )
213
214 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
215   list(APPEND VPPINFRA_SRCS
216     elf_clib.c
217     linux/mem.c
218     linux/sysfs.c
219     linux/netns.c
220 # TODO: Temporarily don't build perfmon on non-Linux
221     perfmon/bundle_default.c
222     perfmon/bundle_core_power.c
223     perfmon/perfmon.c
224    )
225 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
226   list(APPEND VPPINFRA_SRCS
227     elf_clib.c
228     freebsd/mem.c
229    )
230 endif()
231
232 if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
233   option(VPP_USE_EXTERNAL_LIBEXECINFO "Use external libexecinfo (useful for non-glibc targets)." ON)
234 else()
235   option(VPP_USE_EXTERNAL_LIBEXECINFO "Use external libexecinfo (useful for non-glibc targets)." OFF)
236 endif()
237 option(VPP_USE_LIBUNWIND "Use libunwind for backtrace." OFF)
238
239 if(VPP_USE_EXTERNAL_LIBEXECINFO)
240   set(EXECINFO_LIB execinfo)
241 elseif(VPP_USE_LIBUNWIND)
242   set(EXECINFO_LIB unwind)
243   add_compile_definitions(USE_LIBUNWIND)
244 endif()
245 add_vpp_library(vppinfra
246   SOURCES ${VPPINFRA_SRCS}
247   LINK_LIBRARIES m ${EXECINFO_LIB}
248   INSTALL_HEADERS ${VPPINFRA_HEADERS}
249   COMPONENT libvppinfra
250   LTO
251 )
252
253 ##############################################################################
254 # vppinfra headers
255 ##############################################################################
256 option(VPP_BUILD_VPPINFRA_TESTS "Build vppinfra tests." OFF)
257 if(VPP_BUILD_VPPINFRA_TESTS)
258   foreach(test
259     bihash_vec88
260     dlist
261     elf
262     elog
263     fifo
264     format
265     fpool
266     hash
267     heap
268     interrupt
269     longjmp
270     macros
271     maplog
272     mhash
273     pmalloc
274     pool_alloc
275     pool_iterate
276     ptclosure
277     random
278     random_isaac
279     rwlock
280     serialize
281     socket
282     spinlock
283     time
284     time_range
285     tw_timer
286     valloc
287     vec
288   )
289     add_vpp_executable(test_${test}
290       SOURCES test_${test}.c
291       LINK_LIBRARIES vppinfra pthread
292       )
293   endforeach()
294
295   foreach(test bihash_template)
296     add_vpp_executable(test_${test}
297       SOURCES test_${test}.c
298       LINK_LIBRARIES vppinfra Threads::Threads
299       )
300   endforeach()
301 endif(VPP_BUILD_VPPINFRA_TESTS)
302
303 set(test_files
304   test/aes_cbc.c
305   test/aes_ctr.c
306   test/aes_gcm.c
307   test/poly1305.c
308   test/array_mask.c
309   test/compress.c
310   test/count_equal.c
311   test/crc32c.c
312   test/index_to_ptr.c
313   test/ip_csum.c
314   test/mask_compare.c
315   test/memcpy_x86_64.c
316   test/sha2.c
317   test/toeplitz.c
318 )
319
320 add_vpp_executable(test_infra
321   SOURCES
322   test/test.c
323   ${test_files}
324   LINK_LIBRARIES vppinfra
325   NO_INSTALL
326 )
327
328 vpp_library_set_multiarch_sources(test_infra
329   SOURCES
330   ${test_files}
331 )
332