vppinfra: introduce clib_mem_main
[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 ##############################################################################
40 # vppinfra sources
41 ##############################################################################
42 set(VPPINFRA_SRCS
43   backtrace.c
44   bihash_all_vector.c
45   cpu.c
46   dlmalloc.c
47   elf.c
48   elog.c
49   error.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   mem.c
59   mem_dlmalloc.c
60   mhash.c
61   mpcap.c
62   pcap.c
63   pmalloc.c
64   pool.c
65   ptclosure.c
66   random_buffer.c
67   random.c
68   random_isaac.c
69   rbtree.c
70   serialize.c
71   socket.c
72   std-formats.c
73   string.c
74   time.c
75   time_range.c
76   timing_wheel.c
77   tw_timer_2t_2w_512sl.c
78   tw_timer_16t_1w_2048sl.c
79   tw_timer_16t_2w_512sl.c
80   tw_timer_1t_3w_1024sl_ov.c
81   tw_timer_2t_1w_2048sl.c
82   tw_timer_4t_3w_256sl.c
83   unformat.c
84   unix-formats.c
85   unix-misc.c
86   valloc.c
87   vec.c
88   vector.c
89 )
90
91 set(VPPINFRA_HEADERS
92   sanitizer.h
93   bihash_16_8.h
94   bihash_24_8.h
95   bihash_40_8.h
96   bihash_48_8.h
97   bihash_8_8.h
98   bihash_template.c
99   bihash_template.h
100   bihash_vec8_8.h
101   bitmap.h
102   bitops.h
103   byte_order.h
104   cache.h
105   callback.h
106   callback_data.h
107   clib_error.h
108   clib.h
109   cpu.h
110   crc32.h
111   dlist.h
112   dlmalloc.h
113   elf_clib.h
114   elf.h
115   elog.h
116   error_bootstrap.h
117   error.h
118   fifo.h
119   file.h
120   format.h
121   graph.h
122   hash.h
123   heap.h
124   lb_hash_hash.h
125   llist.h
126   lock.h
127   longjmp.h
128   macros.h
129   maplog.h
130   math.h
131   memcpy_avx2.h
132   memcpy_avx512.h
133   memcpy_sse3.h
134   mem.h
135   mhash.h
136   mheap.h
137   mpcap.h
138   os.h
139   pcap.h
140   pcap_funcs.h
141   pmalloc.h
142   pool.h
143   pmc.h
144   ptclosure.h
145   random_buffer.h
146   random.h
147   random_isaac.h
148   rbtree.h
149   serialize.h
150   sha2.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_2t_2w_512sl.h
159   tw_timer_16t_1w_2048sl.h
160   tw_timer_16t_2w_512sl.h
161   tw_timer_1t_3w_1024sl_ov.h
162   tw_timer_2t_1w_2048sl.h
163   tw_timer_4t_3w_256sl.h
164   tw_timer_template.c
165   tw_timer_template.h
166   types.h
167   atomics.h
168   unix.h
169   valloc.h
170   vec_bootstrap.h
171   vec.h
172   vector_altivec.h
173   vector_avx2.h
174   vector_avx512.h
175   vector_funcs.h
176   vector.h
177   vector_neon.h
178   vector_sse42.h
179   warnings.h
180   xxhash.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     dlist
208     elf
209     elog
210     fifo
211     format
212     fpool
213     hash
214     heap
215     longjmp
216     macros
217     maplog
218     pmalloc
219     pool_iterate
220     ptclosure
221     random
222     random_isaac
223     rwlock
224     serialize
225     socket
226     spinlock
227     time
228     time_range
229     tw_timer
230     valloc
231     vec
232   )
233     add_vpp_executable(test_${test}
234       SOURCES test_${test}.c
235       LINK_LIBRARIES vppinfra pthread
236       )
237   endforeach()
238
239   foreach(test bihash_template)
240     add_vpp_executable(test_${test}
241       SOURCES test_${test}.c
242       LINK_LIBRARIES vppinfra Threads::Threads
243       )
244   endforeach()
245 endif(VPP_BUILD_VPPINFRA_TESTS)