blob: 26368493382cbb412ed7df048629cbfd554ee4bb [file] [log] [blame]
Damjan Marion612dd6a2018-07-30 12:45:07 +02001# 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
14enable_language(ASM)
15
16##############################################################################
17# Generate vppinfra/config.h
18##############################################################################
Damjan Marionedc43872018-09-02 11:16:00 +020019set(LOG2_CACHE_LINE_BYTES ${VPP_LOG2_CACHE_LINE_SIZE})
Damjan Marion612dd6a2018-07-30 12:45:07 +020020option(VPP_USE_DLMALLOC "Use dlmalloc memory allocator." ON)
21if(VPP_USE_DLMALLOC)
22 set(DLMALLOC 1)
23else(VPP_USE_DLMALLOC)
24 set(DLMALLOC 0)
25endif(VPP_USE_DLMALLOC)
26
27configure_file(
28 ${CMAKE_SOURCE_DIR}/vppinfra/config.h.in
29 ${CMAKE_BINARY_DIR}/vppinfra/config.h
30)
31
32install(
33 FILES ${CMAKE_BINARY_DIR}/vppinfra/config.h
34 DESTINATION include/vppinfra
Damjan Marion43b06062018-08-29 22:20:45 +020035 COMPONENT vpp-dev
Damjan Marion612dd6a2018-07-30 12:45:07 +020036)
37
38##############################################################################
39# vppinfra sources
40##############################################################################
41set(VPPINFRA_SRCS
42 asm_x86.c
43 backtrace.c
44 cpu.c
45 cuckoo_template.c
Damjan Marion612dd6a2018-07-30 12:45:07 +020046 elf.c
Damjan Marion612dd6a2018-07-30 12:45:07 +020047 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
Damjan Marion612dd6a2018-07-30 12:45:07 +020058 mhash.c
59 pool.c
60 ptclosure.c
Damjan Marion612dd6a2018-07-30 12:45:07 +020061 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
Damjan Marion612dd6a2018-07-30 12:45:07 +020085)
86
Damjan Marion4553c952018-08-26 11:04:40 +020087set(VPPINFRA_HEADERS
Damjan Marion612dd6a2018-07-30 12:45:07 +020088 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
Dave Barach4d1a8662018-09-10 12:31:15 -0400139 pmc.h
Damjan Marion612dd6a2018-07-30 12:45:07 +0200140 ptclosure.h
141 random_buffer.h
142 random.h
143 random_isaac.h
144 serialize.h
145 slist.h
146 smp.h
147 socket.h
148 sparse_vec.h
149 string.h
150 time.h
151 time_range.h
152 timer.h
153 timing_wheel.h
154 tw_timer_16t_1w_2048sl.h
155 tw_timer_16t_2w_512sl.h
156 tw_timer_1t_3w_1024sl_ov.h
157 tw_timer_2t_1w_2048sl.h
158 tw_timer_4t_3w_256sl.h
159 tw_timer_template.c
160 tw_timer_template.h
161 types.h
Sirshak Das2f6d7bb2018-10-03 22:53:51 +0000162 atomics.h
Damjan Marion612dd6a2018-07-30 12:45:07 +0200163 unix.h
164 valgrind.h
165 valloc.h
166 vec_bootstrap.h
167 vec.h
168 vector_altivec.h
169 vector_avx2.h
170 vector_avx512.h
171 vector_funcs.h
172 vector.h
173 vector_neon.h
174 vector_sse42.h
175 xxhash.h
176 xy.h
177 zvec.h
178 linux/syscall.h
179 linux/sysfs.h
180)
181
Damjan Marion4dffd1c2018-09-03 12:30:36 +0200182if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
183 list(APPEND VPPINFRA_SRCS
184 elf_clib.c
185 linux/mem.c
186 linux/sysfs.c
187 )
188endif()
189
Damjan Marion4553c952018-08-26 11:04:40 +0200190
191if(VPP_USE_DLMALLOC)
192 list(APPEND VPPINFRA_SRCS
193 dlmalloc.c
194 mem_dlmalloc.c
195 )
196else(VPP_USE_DLMALLOC)
197 list(APPEND VPPINFRA_SRCS
198 mheap.c
199 mem_mheap.c
200 )
201endif(VPP_USE_DLMALLOC)
202
203add_vpp_library(vppinfra
204 SOURCES ${VPPINFRA_SRCS}
205 LINK_LIBRARIES m
206 INSTALL_HEADERS ${VPPINFRA_HEADERS}
Damjan Marion43b06062018-08-29 22:20:45 +0200207 COMPONENT libvppinfra
Damjan Marion4553c952018-08-26 11:04:40 +0200208)
209
210##############################################################################
211# vppinfra headers
212##############################################################################
Damjan Marion612dd6a2018-07-30 12:45:07 +0200213option(VPP_BUILD_VPPINFRA_TESTS "Build vppinfra tests." OFF)
214if(VPP_BUILD_VPPINFRA_TESTS)
Damjan Marion4553c952018-08-26 11:04:40 +0200215 foreach(test
Damjan Marion612dd6a2018-07-30 12:45:07 +0200216 bihash_vec88
Damjan Marion612dd6a2018-07-30 12:45:07 +0200217 cuckoo_template
218 dlist
219 elf
220 elog
221 fifo
222 flowhash_template
223 format
224 fpool
225 hash
226 heap
227 longjmp
228 macros
229 maplog
230 pool_iterate
231 ptclosure
232 random
233 random_isaac
234 serialize
235 slist
236 socket
237 time
238 time_range
239 timing_wheel
240 tw_timer
241 valloc
242 vec
Damjan Marion612dd6a2018-07-30 12:45:07 +0200243 zvec
244 )
Damjan Marion4553c952018-08-26 11:04:40 +0200245 add_vpp_executable(test_${test}
246 SOURCES test_${test}.c
247 LINK_LIBRARIES vppinfra
248 )
Damjan Marion612dd6a2018-07-30 12:45:07 +0200249 endforeach()
250
Damjan Marion4553c952018-08-26 11:04:40 +0200251 foreach(test bihash_template cuckoo_bihash)
252 add_vpp_executable(test_${test}
253 SOURCES test_${test}.c
254 LINK_LIBRARIES vppinfra Threads::Threads
255 )
256 endforeach()
Damjan Marion612dd6a2018-07-30 12:45:07 +0200257endif(VPP_BUILD_VPPINFRA_TESTS)