da43b0f7a34d4734b5e2b9536cea6ec17c890b3a
[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_types.api
38   api/vpe.api
39 )
40
41 vpp_add_api_files(vpp ${VPP_API_FILES})
42
43 foreach(file ${VPP_API_FILES})
44   get_filename_component(dir ${file} DIRECTORY)
45   install(
46     FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}.h
47     DESTINATION include/vpp/${dir}
48     COMPONENT vpp-dev
49   )
50 endforeach()
51
52 set(VPP_SOURCES
53   vnet/main.c
54   app/vpe_cli.c
55   app/version.c
56   stats/stat_segment.c
57   api/api.c
58   api/json_format.c
59   api/custom_dump.c
60   api/types.c
61 )
62
63 if(VPP_API_TEST_BUILTIN)
64   list(APPEND VPP_SOURCES
65     api/api_format.c
66     api/api_main.c
67     api/plugin.c
68     api/types.c
69   )
70   add_definitions(-DVPP_API_TEST_BUILTIN=1)
71 endif()
72
73 add_vpp_executable(vpp
74   ENABLE_EXPORTS
75   SOURCES ${VPP_SOURCES}
76   LINK_LIBRARIES svm vlib vppinfra vlibmemory vnet Threads::Threads ${CMAKE_DL_LIBS}
77   DEPENDS vpp_version_h api_headers
78 )
79
80 add_vpp_headers(vpp
81   api/vpe_msg_enum.h
82   api/vpe_all_api_h.h
83   stats/stat_segment.h
84   stats/stat_segment_shared.h
85 )
86
87 ##############################################################################
88 # vppctl binary
89 ##############################################################################
90 add_vpp_executable(vppctl
91   SOURCES app/vppctl.c
92   LINK_LIBRARIES vppinfra
93 )
94
95 ##############################################################################
96 # vpp_get_metrics binary
97 ##############################################################################
98 add_vpp_executable(vpp_get_metrics
99   SOURCES api/vpp_get_metrics.c
100   LINK_LIBRARIES vppinfra svm svmdb
101   DEPENDS api_headers
102 )
103
104 ##############################################################################
105 # stats binaries
106 ##############################################################################
107 add_vpp_executable(vpp_get_stats
108   SOURCES app/vpp_get_stats.c
109   LINK_LIBRARIES vppapiclient vppinfra
110   DEPENDS api_headers
111 )
112
113 add_vpp_executable(vpp_prometheus_export
114   SOURCES app/vpp_prometheus_export.c
115   LINK_LIBRARIES vppapiclient vppinfra svm vlibmemoryclient
116   DEPENDS api_headers
117 )
118
119 install(FILES conf/startup.conf DESTINATION etc/vpp COMPONENT vpp)
120 install(FILES conf/80-vpp.conf DESTINATION etc/sysctl.d COMPONENT vpp)