Stats: Include stat_segment.h in packages.
[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_BINARY_DIR}/include/vpp/app/version.h
19   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
20   COMMAND mkdir
21   ARGS -p ${CMAKE_BINARY_DIR}/include/vpp/app
22   COMMAND scripts/generate_version_h
23   ARGS ${CMAKE_BINARY_DIR}/include/vpp/app/version.h
24   COMMENT "Generating VPP version.h"
25 )
26
27 add_custom_target(vpp_version_h
28   DEPENDS ${CMAKE_BINARY_DIR}/include/vpp/app/version.h
29 )
30
31 ##############################################################################
32 # vpp binary
33 ##############################################################################
34 option(VPP_API_TEST_BUILTIN "Use builtin VPP API test." ON)
35
36 set(VPP_API_FILES
37   api/vpe.api
38   stats/stats.api
39   oam/oam.api
40 )
41
42 vpp_add_api_files(vpp ${VPP_API_FILES})
43
44 foreach(file ${VPP_API_FILES})
45   get_filename_component(dir ${file} DIRECTORY)
46   install(
47     FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}.h
48     DESTINATION include/vpp/${dir}
49     COMPONENT vpp-dev
50   )
51 endforeach()
52
53 set(VPP_SOURCES
54   vnet/main.c
55   app/vpe_cli.c
56   app/version.c
57   oam/oam.c
58   oam/oam_api.c
59   stats/stats_to_be_deprecated.c
60   stats/stat_segment.c
61   api/api.c
62   api/json_format.c
63   api/custom_dump.c
64 )
65
66 if(VPP_API_TEST_BUILTIN)
67   list(APPEND VPP_SOURCES
68     api/api_format.c
69     api/api_main.c
70     api/plugin.c
71   )
72   add_definitions(-DVPP_API_TEST_BUILTIN=1)
73 endif()
74
75 add_vpp_executable(vpp
76   ENABLE_EXPORTS
77   SOURCES ${VPP_SOURCES}
78   LINK_LIBRARIES svm vlib vppinfra vlibmemory vnet Threads::Threads ${CMAKE_DL_LIBS}
79   DEPENDS vpp_version_h api_headers
80 )
81
82 add_vpp_headers(vpp
83   api/vpe_msg_enum.h
84   api/vpe_all_api_h.h
85   stats/stat_segment.h
86 )
87
88 ##############################################################################
89 # vppctl binary
90 ##############################################################################
91 add_vpp_executable(vppctl
92   SOURCES app/vppctl.c
93   LINK_LIBRARIES vppinfra
94 )
95
96 ##############################################################################
97 # vpp_get_metrics binary
98 ##############################################################################
99 add_vpp_executable(vpp_get_metrics
100   SOURCES api/vpp_get_metrics.c
101   LINK_LIBRARIES vppinfra svm svmdb
102   DEPENDS api_headers
103 )
104
105 ##############################################################################
106 # stats binaries
107 ##############################################################################
108 add_vpp_executable(summary_stats_client
109   SOURCES api/summary_stats_client.c
110   LINK_LIBRARIES vppinfra svm vlibmemoryclient
111   DEPENDS api_headers
112   NO_INSTALL
113 )
114
115 add_vpp_executable(vpp_get_stats
116   SOURCES app/vpp_get_stats.c
117   LINK_LIBRARIES vppapiclient vppinfra
118   DEPENDS api_headers
119 )
120
121 add_vpp_executable(vpp_prometheus_export
122   SOURCES app/vpp_prometheus_export.c
123   LINK_LIBRARIES vppapiclient vppinfra svm vlibmemoryclient
124   DEPENDS api_headers
125 )