stats: memory heap counters
[vpp.git] / src / vpp / 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 ##############################################################################
15 # Generate vpp/app/version.h
16 ##############################################################################
17 add_custom_command(
18   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/app/version.h
19   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
20   COMMAND mkdir
21   ARGS -p ${CMAKE_CURRENT_BINARY_DIR}/app
22   COMMAND scripts/generate_version_h
23   ARGS ${CMAKE_CURRENT_BINARY_DIR}/app/version.h
24   COMMENT "Generating VPP version.h"
25 )
26
27 add_custom_target(vpp_version_h
28   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/app/version.h
29 )
30
31 ##############################################################################
32 # vpp binary
33 ##############################################################################
34 option(VPP_API_TEST_BUILTIN "Use builtin VPP API test." ON)
35
36 configure_file(
37   ${CMAKE_SOURCE_DIR}/vpp/vnet/config.h.in
38   ${CMAKE_CURRENT_BINARY_DIR}/vnet/config.h
39 )
40
41 set(VPP_API_FILES
42   api/vpe_types.api
43   api/vpe.api
44 )
45
46 vpp_add_api_files(vpp core vpp ${VPP_API_FILES})
47
48 foreach(file ${VPP_API_FILES})
49   get_filename_component(dir ${file} DIRECTORY)
50   install(
51     FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}.h
52     ${CMAKE_CURRENT_BINARY_DIR}/${file}_enum.h
53     ${CMAKE_CURRENT_BINARY_DIR}/${file}_types.h
54     DESTINATION include/vpp/${dir}
55     COMPONENT vpp-dev
56   )
57 endforeach()
58
59 set(VPP_SOURCES
60   vnet/main.c
61   app/vpe_cli.c
62   app/version.c
63   stats/stat_segment.c
64   stats/stat_segment_provider.c
65   api/api.c
66   api/json_format.c
67   api/custom_dump.c
68   api/types.c
69 )
70
71 if(VPP_API_TEST_BUILTIN)
72   list(APPEND VPP_SOURCES
73     api/api_format.c
74     api/api_main.c
75     api/plugin.c
76     api/types.c
77     ../vnet/arp/arp_test.c
78   )
79   add_definitions(-DVPP_API_TEST_BUILTIN=1)
80 endif()
81
82 add_vpp_executable(vpp
83   ENABLE_EXPORTS
84   SOURCES ${VPP_SOURCES}
85   LINK_LIBRARIES svm vlib vppinfra vlibmemory vnet Threads::Threads ${CMAKE_DL_LIBS}
86   DEPENDS vpp_version_h api_headers
87 )
88
89 add_vpp_headers(vpp
90   api/vpe_msg_enum.h
91   api/vpe_all_api_h.h
92   stats/stat_segment.h
93   stats/stat_segment_shared.h
94 )
95
96 ##############################################################################
97 # vppctl binary
98 ##############################################################################
99 add_vpp_executable(vppctl
100   SOURCES app/vppctl.c
101   LINK_LIBRARIES vppinfra
102 )
103
104 ##############################################################################
105 # vpp_get_metrics binary
106 ##############################################################################
107 add_vpp_executable(vpp_get_metrics
108   SOURCES api/vpp_get_metrics.c
109   LINK_LIBRARIES vppinfra svm svmdb
110   DEPENDS api_headers
111 )
112
113 ##############################################################################
114 # stats binaries
115 ##############################################################################
116 add_vpp_executable(vpp_get_stats
117   SOURCES app/vpp_get_stats.c
118   LINK_LIBRARIES vppapiclient vppinfra
119   DEPENDS api_headers
120 )
121
122 add_vpp_executable(vpp_prometheus_export
123   SOURCES app/vpp_prometheus_export.c
124   LINK_LIBRARIES vppapiclient vppinfra svm vlibmemoryclient
125   DEPENDS api_headers
126 )
127
128 ##############################################################################
129 # vppmem_preload library
130 ##############################################################################
131 add_vpp_library(vppmem_preload
132   SOURCES mem/mem.c
133   LINK_LIBRARIES vppinfra
134 )
135
136 install(FILES conf/startup.conf DESTINATION etc/vpp COMPONENT vpp)
137 install(FILES conf/80-vpp.conf DESTINATION etc/sysctl.d COMPONENT vpp)
138
139 ##############################################################################
140 # VAT2 plugins
141 ##############################################################################
142 add_vpp_test_library(vpp
143   ${VPP_API_FILES}
144 )
145
146 ##############################################################################
147 # minimal interactive startup.conf  - only if not present
148 ##############################################################################
149 if(NOT EXISTS ${CMAKE_BINARY_DIR}/startup.conf)
150   configure_file(
151     ${CMAKE_CURRENT_SOURCE_DIR}/conf/startup.conf.in
152     ${CMAKE_BINARY_DIR}/startup.conf
153   )
154 endif()