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