build: add missing fib headers 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_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 install(
42   FILES ${CMAKE_CURRENT_BINARY_DIR}/vnet/config.h
43   DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/vpp/vnet
44   COMPONENT vpp-dev
45 )
46
47 set(VPP_API_FILES
48   api/vpe_types.api
49   api/vpe.api
50 )
51
52 vpp_add_api_files(vpp core vpp ${VPP_API_FILES})
53
54 foreach(file ${VPP_API_FILES})
55   get_filename_component(dir ${file} DIRECTORY)
56   install(
57     FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}.h
58     ${CMAKE_CURRENT_BINARY_DIR}/${file}_enum.h
59     ${CMAKE_CURRENT_BINARY_DIR}/${file}_types.h
60     DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/vpp/${dir}
61     COMPONENT vpp-dev
62   )
63 endforeach()
64
65 set(VPP_SOURCES
66   vnet/main.c
67   app/vpe_cli.c
68   app/version.c
69   stats/stat_segment.c
70   stats/stat_segment_provider.c
71   api/api.c
72   api/json_format.c
73   api/types.c
74 )
75
76 if(VPP_API_TEST_BUILTIN)
77   list(APPEND VPP_SOURCES
78     api/api_format.c
79     api/api_main.c
80     api/plugin.c
81     api/types.c
82   )
83   add_definitions(-DVPP_API_TEST_BUILTIN=1)
84 endif()
85
86 add_vpp_executable(vpp
87   ENABLE_EXPORTS
88   SOURCES ${VPP_SOURCES}
89   LINK_LIBRARIES svm vlib vppinfra vlibmemory vnet Threads::Threads ${CMAKE_DL_LIBS}
90   DEPENDS vpp_version_h api_headers
91 )
92
93 add_vpp_headers(vpp
94   stats/stat_segment.h
95   stats/stat_segment_shared.h
96 )
97
98 ##############################################################################
99 # vppctl binary
100 ##############################################################################
101 add_vpp_executable(vppctl
102   SOURCES app/vppctl.c
103   LINK_LIBRARIES vppinfra
104 )
105
106 ##############################################################################
107 # vpp_get_metrics binary
108 ##############################################################################
109 add_vpp_executable(vpp_get_metrics
110   SOURCES api/vpp_get_metrics.c
111   LINK_LIBRARIES vppinfra svm svmdb
112   DEPENDS api_headers
113 )
114
115 ##############################################################################
116 # stats binaries
117 ##############################################################################
118 add_vpp_executable(vpp_get_stats
119   SOURCES app/vpp_get_stats.c
120   LINK_LIBRARIES vppapiclient vppinfra
121   DEPENDS api_headers
122 )
123
124 add_vpp_executable(vpp_prometheus_export
125   SOURCES app/vpp_prometheus_export.c
126   LINK_LIBRARIES vppapiclient vppinfra svm vlibmemoryclient
127   DEPENDS api_headers
128 )
129
130 ##############################################################################
131 # vppmem_preload library
132 ##############################################################################
133 add_vpp_library(vppmem_preload
134   SOURCES mem/mem.c
135   LINK_LIBRARIES vppinfra
136 )
137
138 install(FILES conf/startup.conf DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/vpp COMPONENT vpp)
139 install(FILES conf/80-vpp.conf DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/sysctl.d COMPONENT vpp)
140
141 ##############################################################################
142 # VAT2 plugins
143 ##############################################################################
144 add_vpp_test_library(vpp
145   ${VPP_API_FILES}
146 )
147
148 add_vat_test_library(vpp
149   api/api_test.c
150 )
151
152 ##############################################################################
153 # minimal interactive startup.conf  - only if not present
154 ##############################################################################
155 if(NOT EXISTS ${CMAKE_BINARY_DIR}/startup.conf)
156   configure_file(
157     ${CMAKE_CURRENT_SOURCE_DIR}/conf/startup.conf.in
158     ${CMAKE_BINARY_DIR}/startup.conf
159   )
160 endif()