build: Add support to add_vpp_library for platform specific sources
[vpp.git] / src / vlib / 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 option(VPP_BUFFER_FAULT_INJECTOR "Include the buffer fault injector" OFF)
15
16 ##############################################################################
17 # Generate vlib/config.h
18 ##############################################################################
19 if(VPP_BUFFER_FAULT_INJECTOR)
20   set(BUFFER_ALLOC_FAULT_INJECTOR 1 CACHE STRING "fault injector on")
21 else()
22   set(BUFFER_ALLOC_FAULT_INJECTOR 0 CACHE STRING "fault injector off")
23 endif()
24
25 if(VPP_PLATFORM_BUFFER_ALIGN)
26   set(VLIB_BUFFER_ALIGN ${VPP_PLATFORM_BUFFER_ALIGN})
27 else()
28   set(VLIB_BUFFER_ALIGN ${VPP_CACHE_LINE_SIZE})
29 endif()
30
31 set(PRE_DATA_SIZE 128 CACHE STRING "Buffer headroom size.")
32
33 if (CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG")
34   set(_ss 16)
35 else()
36   set(_ss 15)
37 endif()
38 set(VLIB_PROCESS_LOG2_STACK_SIZE
39  ${_ss}
40  CACHE
41  STRING "Process node default stack size (log2)"
42 )
43
44 configure_file(
45   ${CMAKE_SOURCE_DIR}/vlib/config.h.in
46   ${CMAKE_CURRENT_BINARY_DIR}/config.h
47 )
48 install(
49   FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h
50   DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/vlib
51   COMPONENT vpp-dev
52 )
53
54 ##############################################################################
55 # vlib shared library
56 ##############################################################################
57
58 set(PLATFORM_SOURCES
59   linux/pci.c
60   linux/vfio.c
61   linux/vmbus.c
62 )
63
64 set(PLATFORM_HEADERS
65   linux/vfio.h
66 )
67
68 add_vpp_library(vlib
69   SOURCES
70   buffer.c
71   buffer_funcs.c
72   cli.c
73   counter.c
74   drop.c
75   error.c
76   format.c
77   handoff_trace.c
78   init.c
79   log.c
80   main.c
81   node.c
82   node_cli.c
83   node_format.c
84   node_init.c
85   pci/pci.c
86   pci/pci_types_api.c
87   physmem.c
88   punt.c
89   punt_node.c
90   stats/cli.c
91   stats/collector.c
92   stats/format.c
93   stats/init.c
94   stats/provider_mem.c
95   stats/stats.c
96   threads.c
97   threads_cli.c
98   time.c
99   trace.c
100   unix/cli.c
101   unix/input.c
102   unix/main.c
103   unix/plugin.c
104   unix/util.c
105   vmbus/vmbus.c
106   dma/dma.c
107   dma/cli.c
108   ${PLATFORM_SOURCES}
109
110   MULTIARCH_SOURCES
111   buffer_funcs.c
112   drop.c
113   punt_node.c
114   node_init.c
115
116   INSTALL_HEADERS
117   buffer_funcs.h
118   buffer.h
119   buffer_node.h
120   cli.h
121   counter.h
122   counter_types.h
123   defs.h
124   dma/dma.h
125   error_funcs.h
126   error.h
127   format_funcs.h
128   global_funcs.h
129   init.h
130   log.h
131   main.h
132   node_funcs.h
133   node.h
134   pci/pci_config.h
135   pci/pci.h
136   pci/pci_types_api.h
137   physmem_funcs.h
138   physmem.h
139   punt.h
140   stats/shared.h
141   stats/stats.h
142   threads.h
143   time.h
144   trace_funcs.h
145   trace.h
146   unix/mc_socket.h
147   unix/plugin.h
148   unix/unix.h
149   vlib.h
150   vmbus/vmbus.h
151   ${PLATFORM_HEADERS}
152
153   API_FILES
154   pci/pci_types.api
155
156   LINK_LIBRARIES vppinfra svm ${CMAKE_DL_LIBS}
157
158   DEPENDS api_headers
159 )