CMake as an alternative to autotools (experimental)
[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 6)
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 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   dlmalloc.c
47   elf.c
48   elf_clib.c
49   elog.c
50   error.c
51   fheap.c
52   fifo.c
53   format.c
54   graph.c
55   hash.c
56   heap.c
57   longjmp.S
58   macros.c
59   maplog.c
60   mem_dlmalloc.c
61   mhash.c
62   pool.c
63   ptclosure.c
64   qsort.c
65   random.c
66   random_buffer.c
67   random_isaac.c
68   serialize.c
69   slist.c
70   socket.c
71   std-formats.c
72   string.c
73   time.c
74   time_range.c
75   timer.c
76   timing_wheel.c
77   tw_timer_2t_1w_2048sl.c
78   tw_timer_16t_2w_512sl.c
79   tw_timer_16t_1w_2048sl.c
80   tw_timer_4t_3w_256sl.c
81   tw_timer_1t_3w_1024sl_ov.c
82   unformat.c
83   unix-formats.c
84   unix-misc.c
85   valloc.c
86   vec.c
87   vector.c
88   zvec.c
89   linux/mem.c
90   linux/sysfs.c
91 )
92
93 add_library(vppinfra SHARED ${VPPINFRA_SRCS})
94 target_link_libraries(vppinfra m)
95 install(TARGETS vppinfra DESTINATION lib)
96
97 ##############################################################################
98 # vppinfra headers
99 ##############################################################################
100 vpp_add_header_files(vppinfra
101   asm_mips.h
102   asm_x86.h
103   bihash_16_8.h
104   bihash_24_8.h
105   bihash_40_8.h
106   bihash_48_8.h
107   bihash_8_8.h
108   bihash_template.c
109   bihash_template.h
110   bihash_vec8_8.h
111   bitmap.h
112   bitops.h
113   byte_order.h
114   cache.h
115   clib_error.h
116   clib.h
117   cpu.h
118   crc32.h
119   dlist.h
120   dlmalloc.h
121   elf_clib.h
122   elf.h
123   elog.h
124   error_bootstrap.h
125   error.h
126   fheap.h
127   fifo.h
128   file.h
129   flowhash_24_16.h
130   flowhash_8_8.h
131   flowhash_template.h
132   format.h
133   graph.h
134   hash.h
135   heap.h
136   lb_hash_hash.h
137   lock.h
138   longjmp.h
139   macros.h
140   maplog.h
141   math.h
142   memcpy_avx2.h
143   memcpy_avx512.h
144   memcpy_sse3.h
145   mem.h
146   mhash.h
147   mheap_bootstrap.h
148   mheap.h
149   os.h
150   pipeline.h
151   pool.h
152   ptclosure.h
153   random_buffer.h
154   random.h
155   random_isaac.h
156   serialize.h
157   slist.h
158   smp.h
159   socket.h
160   sparse_vec.h
161   string.h
162   time.h
163   time_range.h
164   timer.h
165   timing_wheel.h
166   tw_timer_16t_1w_2048sl.h
167   tw_timer_16t_2w_512sl.h
168   tw_timer_1t_3w_1024sl_ov.h
169   tw_timer_2t_1w_2048sl.h
170   tw_timer_4t_3w_256sl.h
171   tw_timer_template.c
172   tw_timer_template.h
173   types.h
174   unix.h
175   valgrind.h
176   valloc.h
177   vec_bootstrap.h
178   vec.h
179   vector_altivec.h
180   vector_avx2.h
181   vector_avx512.h
182   vector_funcs.h
183   vector.h
184   vector_neon.h
185   vector_sse42.h
186   xxhash.h
187   xy.h
188   zvec.h
189   linux/syscall.h
190   linux/sysfs.h
191 )
192
193 option(VPP_BUILD_VPPINFRA_TESTS "Build vppinfra tests." OFF)
194 if(VPP_BUILD_VPPINFRA_TESTS)
195   set(VPPINFRA_TESTS
196     bihash_template
197     bihash_vec88
198     cuckoo_bihash
199     cuckoo_template
200     dlist
201     elf
202     elog
203     fifo
204     flowhash_template
205     format
206     fpool
207     hash
208     heap
209     longjmp
210     macros
211     maplog
212     pool_iterate
213     ptclosure
214     random
215     random_isaac
216     serialize
217     slist
218     socket
219     time
220     time_range
221     timing_wheel
222     tw_timer
223     valloc
224     vec
225     vhash
226     zvec
227   )
228   foreach(test ${VPPINFRA_TESTS})
229     add_executable(test_${test} test_${test}.c)
230     target_link_libraries(test_${test} vppinfra)
231   endforeach()
232
233   target_link_libraries(test_bihash_template Threads::Threads)
234   target_link_libraries(test_cuckoo_bihash Threads::Threads)
235 endif(VPP_BUILD_VPPINFRA_TESTS)