CMake: Add Cmake support for Vat
[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 vpp_add_api_files(vpp_api_headers
37   api/vpe.api
38   stats/stats.api
39   oam/oam.api
40 )
41
42 set(VPP_SOURCES
43   vnet/main.c
44   app/vpe_cli.c
45   app/version.c
46   oam/oam.c
47   oam/oam_api.c
48   stats/stats.c
49   stats/stat_segment.c
50   api/api.c
51   api/json_format.c
52   api/custom_dump.c
53 )
54
55 if(VPP_API_TEST_BUILTIN)
56   list(APPEND VPP_SOURCES
57     api/api_format.c
58     api/api_main.c
59     api/plugin.c
60   )
61   add_definitions(-DVPP_API_TEST_BUILTIN=1)
62 endif()
63
64 add_executable (vpp ${VPP_SOURCES})
65
66 target_link_libraries(vpp svm vlib vppinfra vlibmemory vnet Threads::Threads
67                       ${CMAKE_DL_LIBS})
68 add_dependencies(vpp vpp_version_h api_headers)
69 set_target_properties(vpp PROPERTIES ENABLE_EXPORTS 1)
70 install(TARGETS vpp DESTINATION bin)
71
72 ##############################################################################
73 # vppctl binary
74 ##############################################################################
75 add_executable(vppctl app/vppctl.c)
76 target_link_libraries(vppctl vppinfra)
77 install(TARGETS vppctl DESTINATION bin)
78
79 ##############################################################################
80 # vpp_get_metrics binary
81 ##############################################################################
82 add_executable (vpp_get_metrics api/vpp_get_metrics.c ${VPP_API_HDRS})
83 target_link_libraries (vpp_get_metrics vppinfra svm svmdb)
84 install(TARGETS vpp_get_metrics DESTINATION bin)
85
86 ##############################################################################
87 # stats binaries
88 ##############################################################################
89 add_executable(summary_stats_client api/summary_stats_client.c)
90 add_executable(stat_client app/stat_client.c)
91 add_dependencies(summary_stats_client api_headers)
92 add_dependencies(stat_client api_headers)
93 target_link_libraries(summary_stats_client vppinfra svm vlibmemoryclient)
94 target_link_libraries(stat_client vppinfra svm vlibmemoryclient)
95
96 ##############################################################################
97 # install
98 ##############################################################################
99