vppinfra: native poly1305 implementation
[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   perfmon/bundle_default.c
75   perfmon/bundle_core_power.c
76   perfmon/perfmon.c
77   pmalloc.c
78   pool.c
79   ptclosure.c
80   random_buffer.c
81   random.c
82   random_isaac.c
83   rbtree.c
84   serialize.c
85   socket.c
86   std-formats.c
87   string.c
88   time.c
89   time_range.c
90   timing_wheel.c
91   tw_timer_2t_2w_512sl.c
92   tw_timer_16t_1w_2048sl.c
93   tw_timer_16t_2w_512sl.c
94   tw_timer_1t_3w_1024sl_ov.c
95   tw_timer_2t_1w_2048sl.c
96   tw_timer_4t_3w_256sl.c
97   unformat.c
98   unix-formats.c
99   unix-misc.c
100   valloc.c
101   vec.c
102   vector.c
103   vector/toeplitz.c
104   cJSON.c
105 )
106
107 set(VPPINFRA_HEADERS
108   bihash_12_4.h
109   bihash_16_8.h
110   bihash_24_8.h
111   bihash_32_8.h
112   bihash_40_8.h
113   bihash_48_8.h
114   bihash_8_8.h
115   bihash_8_16.h
116   bihash_24_16.h
117   bihash_template.c
118   bihash_template.h
119   bihash_vec8_8.h
120   bitmap.h
121   bitops.h
122   byte_order.h
123   cache.h
124   callback.h
125   callback_data.h
126   cJSON.h
127   clib_error.h
128   clib.h
129   cpu.h
130   crc32.h
131   crypto/sha2.h
132   crypto/ghash.h
133   crypto/aes.h
134   crypto/aes_cbc.h
135   crypto/aes_gcm.h
136   crypto/poly1305.h
137   dlist.h
138   dlmalloc.h
139   elf_clib.h
140   elf.h
141   elog.h
142   error_bootstrap.h
143   error.h
144   fifo.h
145   file.h
146   format.h
147   format_table.h
148   hash.h
149   heap.h
150   interrupt.h
151   jsonformat.h
152   lb_hash_hash.h
153   llist.h
154   lock.h
155   longjmp.h
156   macros.h
157   maplog.h
158   math.h
159   memcpy.h
160   memcpy_x86_64.h
161   mem.h
162   mhash.h
163   mpcap.h
164   os.h
165   pcap.h
166   pcap_funcs.h
167   pcg.h
168   perfmon/perfmon.h
169   pmalloc.h
170   pool.h
171   ptclosure.h
172   random_buffer.h
173   random.h
174   random_isaac.h
175   rbtree.h
176   serialize.h
177   smp.h
178   socket.h
179   sparse_vec.h
180   string.h
181   time.h
182   time_range.h
183   timing_wheel.h
184   tw_timer_2t_2w_512sl.h
185   tw_timer_16t_1w_2048sl.h
186   tw_timer_16t_2w_512sl.h
187   tw_timer_1t_3w_1024sl_ov.h
188   tw_timer_2t_1w_2048sl.h
189   tw_timer_4t_3w_256sl.h
190   tw_timer_template.c
191   tw_timer_template.h
192   types.h
193   atomics.h
194   unix.h
195   valloc.h
196   vec_bootstrap.h
197   vec.h
198   vector_altivec.h
199   vector_avx2.h
200   vector_avx512.h
201   vector/array_mask.h
202   vector/compress.h
203   vector/count_equal.h
204   vector/index_to_ptr.h
205   vector/ip_csum.h
206   vector/mask_compare.h
207   vector/toeplitz.h
208   vector.h
209   vector_neon.h
210   vector_sse42.h
211   warnings.h
212   xxhash.h
213   linux/sysfs.h
214 )
215
216 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
217   list(APPEND VPPINFRA_SRCS
218     elf_clib.c
219     linux/mem.c
220     linux/sysfs.c
221     linux/netns.c
222    )
223 endif()
224
225 option(VPP_USE_EXTERNAL_LIBEXECINFO "Use external libexecinfo (useful for non-glibc targets)." OFF)
226 if(VPP_USE_EXTERNAL_LIBEXECINFO)
227   set(EXECINFO_LIB execinfo)
228 endif()
229 add_vpp_library(vppinfra
230   SOURCES ${VPPINFRA_SRCS}
231   LINK_LIBRARIES m ${EXECINFO_LIB}
232   INSTALL_HEADERS ${VPPINFRA_HEADERS}
233   COMPONENT libvppinfra
234   LTO
235 )
236
237 ##############################################################################
238 # vppinfra headers
239 ##############################################################################
240 option(VPP_BUILD_VPPINFRA_TESTS "Build vppinfra tests." OFF)
241 if(VPP_BUILD_VPPINFRA_TESTS)
242   foreach(test
243     bihash_vec88
244     dlist
245     elf
246     elog
247     fifo
248     format
249     fpool
250     hash
251     heap
252     longjmp
253     macros
254     maplog
255     pmalloc
256     pool_alloc
257     pool_iterate
258     ptclosure
259     random
260     random_isaac
261     rwlock
262     serialize
263     socket
264     spinlock
265     time
266     time_range
267     tw_timer
268     valloc
269     vec
270   )
271     add_vpp_executable(test_${test}
272       SOURCES test_${test}.c
273       LINK_LIBRARIES vppinfra pthread
274       )
275   endforeach()
276
277   foreach(test bihash_template)
278     add_vpp_executable(test_${test}
279       SOURCES test_${test}.c
280       LINK_LIBRARIES vppinfra Threads::Threads
281       )
282   endforeach()
283 endif(VPP_BUILD_VPPINFRA_TESTS)
284
285 set(test_files
286   test/aes_cbc.c
287   test/aes_gcm.c
288   test/poly1305.c
289   test/array_mask.c
290   test/compress.c
291   test/count_equal.c
292   test/crc32c.c
293   test/index_to_ptr.c
294   test/ip_csum.c
295   test/mask_compare.c
296   test/memcpy_x86_64.c
297   test/sha2.c
298   test/toeplitz.c
299 )
300
301 add_vpp_executable(test_infra
302   SOURCES
303   test/test.c
304   ${test_files}
305   LINK_LIBRARIES vppinfra
306   NO_INSTALL
307 )
308
309 vpp_library_set_multiarch_sources(test_infra
310   SOURCES
311   ${test_files}
312 )
313