blob: 53034bd27b84060638c68a917fbc2ec2ff38d573 [file] [log] [blame]
Damjan Marion4c64b6e2018-08-26 18:14:46 +02001# 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
14include_directories (
15 ${CMAKE_CURRENT_SOURCE_DIR}/..
16 ${CMAKE_CURRENT_BINARY_DIR}/..
Damjan Mariona2d6d352021-05-25 18:29:24 +020017 ${CMAKE_CURRENT_BINARY_DIR}
Damjan Marion4c64b6e2018-08-26 18:14:46 +020018)
19
Damjan Marion4c64b6e2018-08-26 18:14:46 +020020add_vpp_library(vapiclient
21 SOURCES
22 vapi.c
23 libvapiclient.map
24
25 LINK_LIBRARIES vppinfra vlibmemoryclient svm pthread m rt
Oliver Gilesdc203712019-12-05 23:37:36 +020026 DEPENDS api_headers
Damjan Marion4c64b6e2018-08-26 18:14:46 +020027)
28
29install(
30 FILES
Vratko Polak7f37a942019-07-24 13:42:36 +020031 vapi.h
32 vapi_common.h
33 vapi_dbg.h
34 vapi.hpp
35 vapi_internal.h
36 DESTINATION
37 include/vapi
38 COMPONENT
39 vpp-dev
40)
Damjan Marion4c64b6e2018-08-26 18:14:46 +020041
Vratko Polak7f37a942019-07-24 13:42:36 +020042install(
43 FILES
44 vapi_c_gen.py
45 vapi_json_parser.py
46 vapi_cpp_gen.py
47 DESTINATION
48 share/vpp
49 COMPONENT
50 vpp-dev
Damjan Marion4c64b6e2018-08-26 18:14:46 +020051)
Oliver Gilesdc203712019-12-05 23:37:36 +020052
53install(
54 PROGRAMS
55 vapi_c_gen.py
56 vapi_cpp_gen.py
57 vapi_json_parser.py
58
Damjan Marion599efc62020-05-07 16:49:45 +020059 DESTINATION ${VPP_RUNTIME_DIR}
Oliver Gilesdc203712019-12-05 23:37:36 +020060 COMPONENT vpp-dev
61)
Damjan Mariona2d6d352021-05-25 18:29:24 +020062
63vpp_find_path(SUBUNIT_INCLUDE_DIR NAMES subunit/child.h)
64vpp_find_library(SUBUNIT_LIB NAMES subunit)
65
66if(SUBUNIT_INCLUDE_DIR AND SUBUNIT_LIB)
67 message (STATUS "Found subunit in ${SUBUNIT_INCLUDE_DIR} and ${SUBUNIT_LIB}")
68
69 add_custom_command(
70 OUTPUT fake.api.vapi.h
71 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
Damjan Marion7cf80af2021-05-25 19:28:21 +020072 COMMAND ${PYENV} ${CMAKE_CURRENT_SOURCE_DIR}/vapi_c_gen.py
Damjan Mariona2d6d352021-05-25 18:29:24 +020073 ARGS --remove-path ${CMAKE_CURRENT_SOURCE_DIR}/fake.api.json
74 DEPENDS fake.api.json
75 COMMENT "Generating fake VAPI C header ${output_name}"
76 )
77
78 add_custom_command(
79 OUTPUT fake.api.vapi.hpp
80 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
Damjan Marion7cf80af2021-05-25 19:28:21 +020081 COMMAND ${PYENV} ${CMAKE_CURRENT_SOURCE_DIR}/vapi_cpp_gen.py
Damjan Mariona2d6d352021-05-25 18:29:24 +020082 ARGS --remove-path ${CMAKE_CURRENT_SOURCE_DIR}/fake.api.json
83 DEPENDS fake.api.json
84 COMMENT "Generating fake VAPI C++ header ${output_name}"
85 )
86
87 add_custom_target(fake_api_vapi_h DEPENDS fake.api.vapi.h)
88 add_custom_target(fake_api_vapi_hpp DEPENDS fake.api.vapi.hpp)
89
90 set(libs vppinfra vlibmemoryclient svm pthread check rt m vapiclient ${SUBUNIT_LIB})
91
92 add_vpp_executable(vapi_c_test
93 SOURCES
94 vapi_c_test.c
95 DEPENDS fake_api_vapi_h
96 LINK_LIBRARIES ${libs}
97 )
98
99 enable_language(CXX)
100 add_vpp_executable(vapi_cpp_test
101 SOURCES
102 vapi_cpp_test.cpp
103 DEPENDS fake_api_vapi_hpp
104 LINK_LIBRARIES ${libs}
105 )
106
107else()
108 message (WARNING "subunit library not found - vapi tests disabled")
109endif()