vppinfra: native AES-CTR 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_ctr.h
136   crypto/aes_gcm.h
137   crypto/poly1305.h
138   dlist.h
139   dlmalloc.h
140   elf_clib.h
141   elf.h
142   elog.h
143   error_bootstrap.h
144   error.h
145   fifo.h
146   file.h
147   format.h
148   format_table.h
149   hash.h
150   heap.h
151   interrupt.h
152   jsonformat.h
153   lb_hash_hash.h
154   llist.h
155   lock.h
156   longjmp.h
157   macros.h
158   maplog.h
159   math.h
160   memcpy.h
161   memcpy_x86_64.h
162   mem.h
163   mhash.h
164   mpcap.h
165   os.h
166   pcap.h
167   pcap_funcs.h
168   pcg.h
169   perfmon/perfmon.h
170   pmalloc.h
171   pool.h
172   ptclosure.h
173   random_buffer.h
174   random.h
175   random_isaac.h
176   rbtree.h
177   serialize.h
178   smp.h
179   socket.h
180   sparse_vec.h
181   string.h
182   time.h
183   time_range.h
184   timing_wheel.h
185   tw_timer_2t_2w_512sl.h
186   tw_timer_16t_1w_2048sl.h
187   tw_timer_16t_2w_512sl.h
188   tw_timer_1t_3w_1024sl_ov.h
189   tw_timer_2t_1w_2048sl.h
190   tw_timer_4t_3w_256sl.h
191   tw_timer_template.c
192   tw_timer_template.h
193   types.h
194   atomics.h
195   unix.h
196   valloc.h
197   vec_bootstrap.h
198   vec.h
199   vector_altivec.h
200   vector_avx2.h
201   vector_avx512.h
202   vector/array_mask.h
203   vector/compress.h
204   vector/count_equal.h
205   vector/index_to_ptr.h
206   vector/ip_csum.h
207   vector/mask_compare.h
208   vector/toeplitz.h
209   vector.h
210   vector_neon.h
211   vector_sse42.h
212   warnings.h
213   xxhash.h
214   linux/sysfs.h
215 )
216
217 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
218   list(APPEND VPPINFRA_SRCS
219     elf_clib.c
220     linux/mem.c
221     linux/sysfs.c
222     linux/netns.c
223    )
224 endif()
225
226 option(VPP_USE_EXTERNAL_LIBEXECINFO "Use external libexecinfo (useful for non-glibc targets)." OFF)
227 if(VPP_USE_EXTERNAL_LIBEXECINFO)
228   set(EXECINFO_LIB execinfo)
229 endif()
230 add_vpp_library(vppinfra
231   SOURCES ${VPPINFRA_SRCS}
232   LINK_LIBRARIES m ${EXECINFO_LIB}
233   INSTALL_HEADERS ${VPPINFRA_HEADERS}
234   COMPONENT libvppinfra
235   LTO
236 )
237
238 ##############################################################################
239 # vppinfra headers
240 ##############################################################################
241 option(VPP_BUILD_VPPINFRA_TESTS "Build vppinfra tests." OFF)
242 if(VPP_BUILD_VPPINFRA_TESTS)
243   foreach(test
244     bihash_vec88
245     dlist
246     elf
247     elog
248     fifo
249     format
250     fpool
251     hash
252     heap
253     interrupt
254     longjmp
255     macros
256     maplog
257     pmalloc
258     pool_alloc
259     pool_iterate
260     ptclosure
261     random
262     random_isaac
263     rwlock
264     serialize
265     socket
266     spinlock
267     time
268     time_range
269     tw_timer
270     valloc
271     vec
272   )
273     add_vpp_executable(test_${test}
274       SOURCES test_${test}.c
275       LINK_LIBRARIES vppinfra pthread
276       )
277   endforeach()
278
279   foreach(test bihash_template)
280     add_vpp_executable(test_${test}
281       SOURCES test_${test}.c
282       LINK_LIBRARIES vppinfra Threads::Threads
283       )
284   endforeach()
285 endif(VPP_BUILD_VPPINFRA_TESTS)
286
287 set(test_files
288   test/aes_cbc.c
289   test/aes_ctr.c
290   test/aes_gcm.c
291   test/poly1305.c
292   test/array_mask.c
293   test/compress.c
294   test/count_equal.c
295   test/crc32c.c
296   test/index_to_ptr.c
297   test/ip_csum.c
298   test/mask_compare.c
299   test/memcpy_x86_64.c
300   test/sha2.c
301   test/toeplitz.c
302 )
303
304 add_vpp_executable(test_infra
305   SOURCES
306   test/test.c
307   ${test_files}
308   LINK_LIBRARIES vppinfra
309   NO_INSTALL
310 )
311
312 vpp_library_set_multiarch_sources(test_infra
313   SOURCES
314   ${test_files}
315 )
316