CMake as an alternative to autotools (experimental)
[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
35 vpp_add_api_files(vpp_api_headers
36   api/vpe.api
37   stats/stats.api
38   oam/oam.api
39 )
40
41 add_executable (vpp
42   vnet/main.c
43   app/vpe_cli.c
44   app/version.c
45   oam/oam.c
46   oam/oam_api.c
47   stats/stats.c
48   stats/stat_segment.c
49   api/api.c
50   api/api_main.c
51   api/api_format.c
52   api/json_format.c
53   api/custom_dump.c
54   api/plugin.c
55 )
56 target_link_libraries(vpp svm vlib vppinfra vlibmemory vnet Threads::Threads
57                       ${CMAKE_DL_LIBS})
58 add_dependencies(vpp vpp_version_h api_headers)
59 set_target_properties(vpp PROPERTIES ENABLE_EXPORTS 1)
60 install(TARGETS vpp DESTINATION bin)
61
62 ##############################################################################
63 # vppctl binary
64 ##############################################################################
65 add_executable(vppctl app/vppctl.c)
66 target_link_libraries(vppctl vppinfra)
67 install(TARGETS vppctl DESTINATION bin)
68
69 ##############################################################################
70 # vpp_get_metrics binary
71 ##############################################################################
72 add_executable (vpp_get_metrics api/vpp_get_metrics.c ${VPP_API_HDRS})
73 target_link_libraries (vpp_get_metrics vppinfra svm svmdb)
74 install(TARGETS vpp_get_metrics DESTINATION bin)
75
76 ##############################################################################
77 # stats binaries
78 ##############################################################################
79 add_executable(summary_stats_client api/summary_stats_client.c)
80 add_executable(stat_client app/stat_client.c)
81 target_link_libraries(summary_stats_client vppinfra svm vlibmemoryclient)
82 target_link_libraries(stat_client vppinfra svm vlibmemoryclient)
83
84 ##############################################################################
85 # install
86 ##############################################################################
87