vppinfra: add bihash 12_4 template
[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   graph.c
62   hash.c
63   heap.c
64   interrupt.c
65   jsonformat.c
66   longjmp.S
67   macros.c
68   maplog.c
69   mem.c
70   mem_bulk.c
71   mem_dlmalloc.c
72   mhash.c
73   mpcap.c
74   pcap.c
75   pmalloc.c
76   pool.c
77   ptclosure.c
78   random_buffer.c
79   random.c
80   random_isaac.c
81   rbtree.c
82   sanitizer.c
83   serialize.c
84   socket.c
85   std-formats.c
86   string.c
87   time.c
88   time_range.c
89   timing_wheel.c
90   tw_timer_2t_2w_512sl.c
91   tw_timer_16t_1w_2048sl.c
92   tw_timer_16t_2w_512sl.c
93   tw_timer_1t_3w_1024sl_ov.c
94   tw_timer_2t_1w_2048sl.c
95   tw_timer_4t_3w_256sl.c
96   unformat.c
97   unix-formats.c
98   unix-misc.c
99   valloc.c
100   vec.c
101   vector.c
102   vector/toeplitz.c
103   cJSON.c
104 )
105
106 set(VPPINFRA_HEADERS
107   sanitizer.h
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   dlist.h
132   dlmalloc.h
133   elf_clib.h
134   elf.h
135   elog.h
136   error_bootstrap.h
137   error.h
138   fifo.h
139   file.h
140   format.h
141   format_table.h
142   graph.h
143   hash.h
144   heap.h
145   interrupt.h
146   jsonformat.h
147   lb_hash_hash.h
148   llist.h
149   lock.h
150   longjmp.h
151   macros.h
152   maplog.h
153   math.h
154   memcpy.h
155   memcpy_x86_64.h
156   mem.h
157   mhash.h
158   mpcap.h
159   os.h
160   pcap.h
161   pcap_funcs.h
162   pmalloc.h
163   pool.h
164   ptclosure.h
165   random_buffer.h
166   random.h
167   random_isaac.h
168   rbtree.h
169   serialize.h
170   sha2.h
171   smp.h
172   socket.h
173   sparse_vec.h
174   string.h
175   time.h
176   time_range.h
177   timing_wheel.h
178   tw_timer_2t_2w_512sl.h
179   tw_timer_16t_1w_2048sl.h
180   tw_timer_16t_2w_512sl.h
181   tw_timer_1t_3w_1024sl_ov.h
182   tw_timer_2t_1w_2048sl.h
183   tw_timer_4t_3w_256sl.h
184   tw_timer_template.c
185   tw_timer_template.h
186   types.h
187   atomics.h
188   unix.h
189   valloc.h
190   vec_bootstrap.h
191   vec.h
192   vector_altivec.h
193   vector_avx2.h
194   vector_avx512.h
195   vector/array_mask.h
196   vector/compress.h
197   vector/count_equal.h
198   vector/index_to_ptr.h
199   vector/ip_csum.h
200   vector/mask_compare.h
201   vector/toeplitz.h
202   vector.h
203   vector_neon.h
204   vector_sse42.h
205   warnings.h
206   xxhash.h
207   linux/sysfs.h
208 )
209
210 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
211   list(APPEND VPPINFRA_SRCS
212     elf_clib.c
213     linux/mem.c
214     linux/sysfs.c
215     linux/netns.c
216    )
217 endif()
218
219 option(VPP_USE_EXTERNAL_LIBEXECINFO "Use external libexecinfo (useful for non-glibc targets)." OFF)
220 if(VPP_USE_EXTERNAL_LIBEXECINFO)
221   set(EXECINFO_LIB execinfo)
222 endif()
223 add_vpp_library(vppinfra
224   SOURCES ${VPPINFRA_SRCS}
225   LINK_LIBRARIES m ${EXECINFO_LIB}
226   INSTALL_HEADERS ${VPPINFRA_HEADERS}
227   COMPONENT libvppinfra
228   LTO
229 )
230
231 ##############################################################################
232 # vppinfra headers
233 ##############################################################################
234 option(VPP_BUILD_VPPINFRA_TESTS "Build vppinfra tests." OFF)
235 if(VPP_BUILD_VPPINFRA_TESTS)
236   foreach(test
237     bihash_vec88
238     dlist
239     elf
240     elog
241     fifo
242     format
243     fpool
244     hash
245     heap
246     longjmp
247     macros
248     maplog
249     pmalloc
250     pool_iterate
251     ptclosure
252     random
253     random_isaac
254     rwlock
255     serialize
256     socket
257     spinlock
258     time
259     time_range
260     tw_timer
261     valloc
262     vec
263   )
264     add_vpp_executable(test_${test}
265       SOURCES test_${test}.c
266       LINK_LIBRARIES vppinfra pthread
267       )
268   endforeach()
269
270   foreach(test bihash_template)
271     add_vpp_executable(test_${test}
272       SOURCES test_${test}.c
273       LINK_LIBRARIES vppinfra Threads::Threads
274       )
275   endforeach()
276
277 set(test_files
278   vector/test/array_mask.c
279   vector/test/compress.c
280   vector/test/count_equal.c
281   vector/test/index_to_ptr.c
282   vector/test/ip_csum.c
283   vector/test/mask_compare.c
284   vector/test/memcpy_x86_64.c
285   vector/test/sha2.c
286   vector/test/toeplitz.c
287 )
288
289 add_vpp_executable(test_vector_funcs
290   SOURCES
291   vector/test/test.c
292   ${test_files}
293   LINK_LIBRARIES vppinfra
294 )
295
296 vpp_library_set_multiarch_sources(test_vector_funcs
297   SOURCES
298   ${test_files}
299 )
300
301 endif(VPP_BUILD_VPPINFRA_TESTS)