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