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