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:
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 ${CMAKE_CURRENT_SOURCE_DIR}/..
16 ${CMAKE_CURRENT_BINARY_DIR}/..
17 ${CMAKE_CURRENT_BINARY_DIR}
20 add_vpp_library(vapiclient
25 LINK_LIBRARIES vppinfra vlibmemoryclient svm pthread m rt
37 ${CMAKE_INSTALL_INCLUDEDIR}/vapi
59 DESTINATION ${VPP_RUNTIME_DIR}
63 vpp_find_path(SUBUNIT_INCLUDE_DIR NAMES subunit/child.h)
64 vpp_find_library(SUBUNIT_LIB NAMES subunit)
66 if(SUBUNIT_INCLUDE_DIR AND SUBUNIT_LIB)
67 message (STATUS "Found subunit in ${SUBUNIT_INCLUDE_DIR} and ${SUBUNIT_LIB}")
70 OUTPUT fake.api.vapi.h
71 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
72 COMMAND ${PYENV} ${CMAKE_CURRENT_SOURCE_DIR}/vapi_c_gen.py
73 ARGS --remove-path ${CMAKE_CURRENT_SOURCE_DIR}/fake.api.json
75 COMMENT "Generating fake VAPI C header ${output_name}"
79 OUTPUT fake.api.vapi.hpp
80 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
81 COMMAND ${PYENV} ${CMAKE_CURRENT_SOURCE_DIR}/vapi_cpp_gen.py
82 ARGS --remove-path ${CMAKE_CURRENT_SOURCE_DIR}/fake.api.json
84 COMMENT "Generating fake VAPI C++ header ${output_name}"
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)
90 set(libs vppinfra vlibmemoryclient svm pthread check rt m vapiclient ${SUBUNIT_LIB})
92 add_vpp_executable(vapi_c_test
95 DEPENDS fake_api_vapi_h
96 LINK_LIBRARIES ${libs}
101 add_vpp_executable(vapi_cpp_test
104 DEPENDS fake_api_vapi_hpp
105 LINK_LIBRARIES ${libs}
110 message (WARNING "subunit library not found - vapi tests disabled")