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