Damjan Marion | 4c64b6e | 2018-08-26 18:14:46 +0200 | [diff] [blame] | 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 | include_directories ( |
| 15 | ${CMAKE_CURRENT_SOURCE_DIR}/.. |
| 16 | ${CMAKE_CURRENT_BINARY_DIR}/.. |
Damjan Marion | a2d6d35 | 2021-05-25 18:29:24 +0200 | [diff] [blame] | 17 | ${CMAKE_CURRENT_BINARY_DIR} |
Damjan Marion | 4c64b6e | 2018-08-26 18:14:46 +0200 | [diff] [blame] | 18 | ) |
| 19 | |
Damjan Marion | 4c64b6e | 2018-08-26 18:14:46 +0200 | [diff] [blame] | 20 | add_vpp_library(vapiclient |
| 21 | SOURCES |
| 22 | vapi.c |
| 23 | libvapiclient.map |
| 24 | |
| 25 | LINK_LIBRARIES vppinfra vlibmemoryclient svm pthread m rt |
Oliver Giles | dc20371 | 2019-12-05 23:37:36 +0200 | [diff] [blame] | 26 | DEPENDS api_headers |
Damjan Marion | 4c64b6e | 2018-08-26 18:14:46 +0200 | [diff] [blame] | 27 | ) |
| 28 | |
| 29 | install( |
| 30 | FILES |
Vratko Polak | 7f37a94 | 2019-07-24 13:42:36 +0200 | [diff] [blame] | 31 | vapi.h |
| 32 | vapi_common.h |
| 33 | vapi_dbg.h |
| 34 | vapi.hpp |
| 35 | vapi_internal.h |
| 36 | DESTINATION |
Nick Brown | e3cf4d0 | 2021-09-15 14:25:40 +0100 | [diff] [blame^] | 37 | ${CMAKE_INSTALL_INCLUDEDIR}/vapi |
Vratko Polak | 7f37a94 | 2019-07-24 13:42:36 +0200 | [diff] [blame] | 38 | COMPONENT |
| 39 | vpp-dev |
| 40 | ) |
Damjan Marion | 4c64b6e | 2018-08-26 18:14:46 +0200 | [diff] [blame] | 41 | |
Vratko Polak | 7f37a94 | 2019-07-24 13:42:36 +0200 | [diff] [blame] | 42 | install( |
| 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 Marion | 4c64b6e | 2018-08-26 18:14:46 +0200 | [diff] [blame] | 51 | ) |
Oliver Giles | dc20371 | 2019-12-05 23:37:36 +0200 | [diff] [blame] | 52 | |
| 53 | install( |
| 54 | PROGRAMS |
| 55 | vapi_c_gen.py |
| 56 | vapi_cpp_gen.py |
| 57 | vapi_json_parser.py |
| 58 | |
Damjan Marion | 599efc6 | 2020-05-07 16:49:45 +0200 | [diff] [blame] | 59 | DESTINATION ${VPP_RUNTIME_DIR} |
Oliver Giles | dc20371 | 2019-12-05 23:37:36 +0200 | [diff] [blame] | 60 | COMPONENT vpp-dev |
| 61 | ) |
Damjan Marion | a2d6d35 | 2021-05-25 18:29:24 +0200 | [diff] [blame] | 62 | |
| 63 | vpp_find_path(SUBUNIT_INCLUDE_DIR NAMES subunit/child.h) |
| 64 | vpp_find_library(SUBUNIT_LIB NAMES subunit) |
| 65 | |
| 66 | if(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 Marion | 7cf80af | 2021-05-25 19:28:21 +0200 | [diff] [blame] | 72 | COMMAND ${PYENV} ${CMAKE_CURRENT_SOURCE_DIR}/vapi_c_gen.py |
Damjan Marion | a2d6d35 | 2021-05-25 18:29:24 +0200 | [diff] [blame] | 73 | 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 Marion | 7cf80af | 2021-05-25 19:28:21 +0200 | [diff] [blame] | 81 | COMMAND ${PYENV} ${CMAKE_CURRENT_SOURCE_DIR}/vapi_cpp_gen.py |
Damjan Marion | a2d6d35 | 2021-05-25 18:29:24 +0200 | [diff] [blame] | 82 | 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 | |
| 107 | else() |
| 108 | message (WARNING "subunit library not found - vapi tests disabled") |
| 109 | endif() |