8a31af68742e920d77d4440d44751008ff7c7557
[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 set(PRE_DATA_SIZE 128 CACHE STRING "Buffer headroom size.")
26
27 if (CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG")
28   set(_ss 16)
29 else()
30   set(_ss 15)
31 endif()
32 set(VLIB_PROCESS_LOG2_STACK_SIZE
33  ${_ss}
34  CACHE
35  STRING "Process node default stack size (log2)"
36 )
37
38 configure_file(
39   ${CMAKE_SOURCE_DIR}/vlib/config.h.in
40   ${CMAKE_BINARY_DIR}/vlib/config.h
41 )
42 install(
43   FILES ${CMAKE_BINARY_DIR}/vlib/config.h
44   DESTINATION include/vlib
45   COMPONENT vpp-dev
46 )
47
48 ##############################################################################
49 # Find lib and include files
50 ##############################################################################
51 message(STATUS "Looking for libuuid")
52 find_path(UUID_INCLUDE_DIR NAMES uuid/uuid.h)
53 find_library(UUID_LIB NAMES uuid)
54
55 if(UUID_INCLUDE_DIR AND UUID_LIB)
56   include_directories(${UUID_INCLUDE_DIR})
57   set(VMBUS_SOURCE linux/vmbus.c)
58   set(VMBUS_LIBS uuid)
59   message(STATUS "Found uuid in ${UUID_INCLUDE_DIR}")
60 else()
61   message(WARNING "-- libuuid not found - vmbus support disabled")
62 endif()
63
64 ##############################################################################
65 # vlib shared library
66 ##############################################################################
67 add_vpp_library(vlib
68   SOURCES
69   buffer.c
70   cli.c
71   counter.c
72   drop.c
73   error.c
74   format.c
75   handoff_trace.c
76   init.c
77   linux/pci.c
78   linux/vfio.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   threads.c
91   threads_cli.c
92   trace.c
93   unix/cli.c
94   unix/input.c
95   unix/main.c
96   unix/plugin.c
97   unix/util.c
98   vmbus/vmbus.c
99   ${VMBUS_SOURCE}
100
101   MULTIARCH_SOURCES
102   drop.c
103   punt_node.c
104   node_init.c
105
106   INSTALL_HEADERS
107   buffer_funcs.h
108   buffer.h
109   buffer_node.h
110   cli.h
111   counter.h
112   counter_types.h
113   defs.h
114   error_funcs.h
115   error.h
116   format_funcs.h
117   global_funcs.h
118   init.h
119   linux/vfio.h
120   log.h
121   main.h
122   node_funcs.h
123   node.h
124   pci/pci_config.h
125   pci/pci.h
126   pci/pci_types_api.h
127   physmem_funcs.h
128   physmem.h
129   punt.h
130   threads.h
131   trace_funcs.h
132   trace.h
133   unix/mc_socket.h
134   unix/plugin.h
135   unix/unix.h
136   vlib.h
137   vmbus/vmbus.h
138
139   API_FILES
140   pci/pci_types.api
141
142   LINK_LIBRARIES vppinfra svm ${VMBUS_LIBS} ${CMAKE_DL_LIBS}
143
144   DEPENDS api_headers
145 )