vppinfra: add bihash with 32 byte key
[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_BINARY_DIR}/vppinfra/config.h
31 )
32
33 install(
34   FILES ${CMAKE_BINARY_DIR}/vppinfra/config.h
35   DESTINATION include/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 PROPERTIES
43   COMPILE_DEFINITIONS " CJSON_API_VISIBILITY " )
44
45
46 ##############################################################################
47 # vppinfra sources
48 ##############################################################################
49 set(VPPINFRA_SRCS
50   backtrace.c
51   bihash_all_vector.c
52   cpu.c
53   dlmalloc.c
54   elf.c
55   elog.c
56   error.c
57   fifo.c
58   format.c
59   graph.c
60   hash.c
61   heap.c
62   longjmp.S
63   macros.c
64   maplog.c
65   mem.c
66   mem_bulk.c
67   mem_dlmalloc.c
68   mhash.c
69   mpcap.c
70   pcap.c
71   pmalloc.c
72   pool.c
73   ptclosure.c
74   random_buffer.c
75   random.c
76   random_isaac.c
77   rbtree.c
78   serialize.c
79   socket.c
80   std-formats.c
81   string.c
82   time.c
83   time_range.c
84   timing_wheel.c
85   tw_timer_2t_2w_512sl.c
86   tw_timer_16t_1w_2048sl.c
87   tw_timer_16t_2w_512sl.c
88   tw_timer_1t_3w_1024sl_ov.c
89   tw_timer_2t_1w_2048sl.c
90   tw_timer_4t_3w_256sl.c
91   unformat.c
92   unix-formats.c
93   unix-misc.c
94   valloc.c
95   vec.c
96   vector.c
97   cJSON.c
98 )
99
100 set(VPPINFRA_HEADERS
101   sanitizer.h
102   bihash_16_8.h
103   bihash_24_8.h
104   bihash_32_8.h
105   bihash_40_8.h
106   bihash_48_8.h
107   bihash_8_8.h
108   bihash_8_16.h
109   bihash_24_16.h
110   bihash_template.c
111   bihash_template.h
112   bihash_vec8_8.h
113   bitmap.h
114   bitops.h
115   byte_order.h
116   cache.h
117   callback.h
118   callback_data.h
119   cJSON.h
120   clib_error.h
121   clib.h
122   cpu.h
123   crc32.h
124   dlist.h
125   dlmalloc.h
126   elf_clib.h
127   elf.h
128   elog.h
129   error_bootstrap.h
130   error.h
131   fifo.h
132   file.h
133   format.h
134   graph.h
135   hash.h
136   heap.h
137   lb_hash_hash.h
138   llist.h
139   lock.h
140   longjmp.h
141   macros.h
142   maplog.h
143   math.h
144   memcpy_avx2.h
145   memcpy_avx512.h
146   memcpy_sse3.h
147   mem.h
148   mhash.h
149   mpcap.h
150   os.h
151   pcap.h
152   pcap_funcs.h
153   pmalloc.h
154   pool.h
155   ptclosure.h
156   random_buffer.h
157   random.h
158   random_isaac.h
159   rbtree.h
160   serialize.h
161   sha2.h
162   smp.h
163   socket.h
164   sparse_vec.h
165   string.h
166   time.h
167   time_range.h
168   timing_wheel.h
169   tw_timer_2t_2w_512sl.h
170   tw_timer_16t_1w_2048sl.h
171   tw_timer_16t_2w_512sl.h
172   tw_timer_1t_3w_1024sl_ov.h
173   tw_timer_2t_1w_2048sl.h
174   tw_timer_4t_3w_256sl.h
175   tw_timer_template.c
176   tw_timer_template.h
177   types.h
178   atomics.h
179   unix.h
180   valloc.h
181   vec_bootstrap.h
182   vec.h
183   vector_altivec.h
184   vector_avx2.h
185   vector_avx512.h
186   vector_funcs.h
187   vector.h
188   vector_neon.h
189   vector_sse42.h
190   warnings.h
191   xxhash.h
192   linux/syscall.h
193   linux/sysfs.h
194 )
195
196 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
197   list(APPEND VPPINFRA_SRCS
198     elf_clib.c
199     linux/mem.c
200     linux/sysfs.c
201    )
202 endif()
203
204 option(VPP_USE_EXTERNAL_LIBEXECINFO "Use external libexecinfo (useful for non-glibc targets)." OFF)
205 if(VPP_USE_EXTERNAL_LIBEXECINFO)
206   set(EXECINFO_LIB execinfo)
207 endif()
208 add_vpp_library(vppinfra
209   SOURCES ${VPPINFRA_SRCS}
210   LINK_LIBRARIES m ${EXECINFO_LIB}
211   INSTALL_HEADERS ${VPPINFRA_HEADERS}
212   COMPONENT libvppinfra
213   LTO
214 )
215
216 ##############################################################################
217 # vppinfra headers
218 ##############################################################################
219 option(VPP_BUILD_VPPINFRA_TESTS "Build vppinfra tests." OFF)
220 if(VPP_BUILD_VPPINFRA_TESTS)
221   foreach(test
222     bihash_vec88
223     dlist
224     elf
225     elog
226     fifo
227     format
228     fpool
229     hash
230     heap
231     longjmp
232     macros
233     maplog
234     pmalloc
235     pool_iterate
236     ptclosure
237     random
238     random_isaac
239     rwlock
240     serialize
241     socket
242     spinlock
243     time
244     time_range
245     tw_timer
246     valloc
247     vec
248   )
249     add_vpp_executable(test_${test}
250       SOURCES test_${test}.c
251       LINK_LIBRARIES vppinfra pthread
252       )
253   endforeach()
254
255   foreach(test bihash_template)
256     add_vpp_executable(test_${test}
257       SOURCES test_${test}.c
258       LINK_LIBRARIES vppinfra Threads::Threads
259       )
260   endforeach()
261 endif(VPP_BUILD_VPPINFRA_TESTS)