vppinfra: remove linux/syscall.h
[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   bitmap.c
52   bihash_all_vector.c
53   cpu.c
54   dlmalloc.c
55   elf.c
56   elog.c
57   error.c
58   fifo.c
59   format.c
60   graph.c
61   hash.c
62   heap.c
63   interrupt.c
64   longjmp.S
65   macros.c
66   maplog.c
67   mem.c
68   mem_bulk.c
69   mem_dlmalloc.c
70   mhash.c
71   mpcap.c
72   pcap.c
73   pmalloc.c
74   pool.c
75   ptclosure.c
76   random_buffer.c
77   random.c
78   random_isaac.c
79   rbtree.c
80   serialize.c
81   socket.c
82   std-formats.c
83   string.c
84   time.c
85   time_range.c
86   timing_wheel.c
87   tw_timer_2t_2w_512sl.c
88   tw_timer_16t_1w_2048sl.c
89   tw_timer_16t_2w_512sl.c
90   tw_timer_1t_3w_1024sl_ov.c
91   tw_timer_2t_1w_2048sl.c
92   tw_timer_4t_3w_256sl.c
93   unformat.c
94   unix-formats.c
95   unix-misc.c
96   valloc.c
97   vec.c
98   vector.c
99   cJSON.c
100 )
101
102 set(VPPINFRA_HEADERS
103   sanitizer.h
104   bihash_16_8.h
105   bihash_24_8.h
106   bihash_32_8.h
107   bihash_40_8.h
108   bihash_48_8.h
109   bihash_8_8.h
110   bihash_8_16.h
111   bihash_24_16.h
112   bihash_template.c
113   bihash_template.h
114   bihash_vec8_8.h
115   bitmap.h
116   bitops.h
117   byte_order.h
118   cache.h
119   callback.h
120   callback_data.h
121   cJSON.h
122   clib_error.h
123   clib.h
124   cpu.h
125   crc32.h
126   dlist.h
127   dlmalloc.h
128   elf_clib.h
129   elf.h
130   elog.h
131   error_bootstrap.h
132   error.h
133   fifo.h
134   file.h
135   format.h
136   graph.h
137   hash.h
138   heap.h
139   interrupt.h
140   lb_hash_hash.h
141   llist.h
142   lock.h
143   longjmp.h
144   macros.h
145   maplog.h
146   math.h
147   memcpy_avx2.h
148   memcpy_avx512.h
149   memcpy_sse3.h
150   mem.h
151   mhash.h
152   mpcap.h
153   os.h
154   pcap.h
155   pcap_funcs.h
156   pmalloc.h
157   pool.h
158   ptclosure.h
159   random_buffer.h
160   random.h
161   random_isaac.h
162   rbtree.h
163   serialize.h
164   sha2.h
165   smp.h
166   socket.h
167   sparse_vec.h
168   string.h
169   time.h
170   time_range.h
171   timing_wheel.h
172   tw_timer_2t_2w_512sl.h
173   tw_timer_16t_1w_2048sl.h
174   tw_timer_16t_2w_512sl.h
175   tw_timer_1t_3w_1024sl_ov.h
176   tw_timer_2t_1w_2048sl.h
177   tw_timer_4t_3w_256sl.h
178   tw_timer_template.c
179   tw_timer_template.h
180   types.h
181   atomics.h
182   unix.h
183   valloc.h
184   vec_bootstrap.h
185   vec.h
186   vector_altivec.h
187   vector_avx2.h
188   vector_avx512.h
189   vector_funcs.h
190   vector.h
191   vector_neon.h
192   vector_sse42.h
193   warnings.h
194   xxhash.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)