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}/.. |
| 17 | ) |
| 18 | |
| 19 | unset(VAPICLIENT_API_C_HEADERS) |
| 20 | unset(VAPICLIENT_API_CPP_HEADERS) |
| 21 | |
| 22 | get_property(VPP_API_FILES GLOBAL PROPERTY VPP_API_FILES) |
| 23 | foreach(f ${VPP_API_FILES}) |
| 24 | get_filename_component(output ${f}.vapi.h NAME) |
| 25 | set(input ${CMAKE_BINARY_DIR}/${f}.json) |
| 26 | |
| 27 | # C VAPI Headers |
| 28 | add_custom_command( |
| 29 | OUTPUT ${output} |
| 30 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 31 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/vapi_c_gen.py |
| 32 | ARGS --remove-path ${input} |
Damjan Marion | d131825 | 2018-08-30 20:27:32 +0200 | [diff] [blame] | 33 | DEPENDS ${input} vapi_c_gen.py vapi_json_parser.py api_headers |
Damjan Marion | 4c64b6e | 2018-08-26 18:14:46 +0200 | [diff] [blame] | 34 | COMMENT "Generating VAPI C header ${output}" |
| 35 | ) |
Damjan Marion | 833de8c | 2018-09-07 12:39:02 +0200 | [diff] [blame] | 36 | install( |
| 37 | FILES ${CMAKE_CURRENT_BINARY_DIR}/${output} |
| 38 | DESTINATION include/vapi |
| 39 | COMPONENT vpp-dev |
| 40 | ) |
Damjan Marion | 4c64b6e | 2018-08-26 18:14:46 +0200 | [diff] [blame] | 41 | list(APPEND VAPICLIENT_API_CPP_HEADERS ${output}) |
| 42 | |
| 43 | # C++ VAPI Headers |
| 44 | get_filename_component(output ${f}.vapi.hpp NAME) |
| 45 | add_custom_command( |
| 46 | OUTPUT ${output} |
| 47 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 48 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/vapi_cpp_gen.py |
Mohsin Kazmi | b3abec7 | 2018-08-27 13:17:09 +0200 | [diff] [blame] | 49 | ARGS --gen-h-prefix=vapi --remove-path ${input} |
Damjan Marion | d131825 | 2018-08-30 20:27:32 +0200 | [diff] [blame] | 50 | DEPENDS ${input} vapi_cpp_gen.py vapi_json_parser.py api_headers |
Damjan Marion | 4c64b6e | 2018-08-26 18:14:46 +0200 | [diff] [blame] | 51 | COMMENT "Generating VAPI C++ header ${output}" |
| 52 | ) |
Damjan Marion | 833de8c | 2018-09-07 12:39:02 +0200 | [diff] [blame] | 53 | install( |
| 54 | FILES ${CMAKE_CURRENT_BINARY_DIR}/${output} |
| 55 | DESTINATION include/vapi |
| 56 | COMPONENT vpp-dev |
| 57 | ) |
Damjan Marion | 4c64b6e | 2018-08-26 18:14:46 +0200 | [diff] [blame] | 58 | list(APPEND VAPICLIENT_API_CPP_HEADERS ${output}) |
| 59 | endforeach () |
| 60 | |
Damjan Marion | 33ed3e4 | 2018-08-27 15:59:30 +0200 | [diff] [blame] | 61 | add_custom_target(all-vapi-headers DEPENDS |
Damjan Marion | 4c64b6e | 2018-08-26 18:14:46 +0200 | [diff] [blame] | 62 | ${VAPICLIENT_API_C_HEADERS} |
| 63 | ${VAPICLIENT_API_CPP_HEADERS} |
| 64 | ) |
| 65 | |
| 66 | add_vpp_library(vapiclient |
| 67 | SOURCES |
| 68 | vapi.c |
| 69 | libvapiclient.map |
| 70 | |
| 71 | LINK_LIBRARIES vppinfra vlibmemoryclient svm pthread m rt |
Damjan Marion | 33ed3e4 | 2018-08-27 15:59:30 +0200 | [diff] [blame] | 72 | DEPENDS all-vapi-headers |
Damjan Marion | 4c64b6e | 2018-08-26 18:14:46 +0200 | [diff] [blame] | 73 | ) |
| 74 | |
| 75 | install( |
| 76 | FILES |
| 77 | vapi.h |
| 78 | vapi_common.h |
| 79 | vapi_dbg.h |
| 80 | vapi.hpp |
| 81 | vapi_internal.h |
| 82 | |
| 83 | DESTINATION include/vapi |
Damjan Marion | 833de8c | 2018-09-07 12:39:02 +0200 | [diff] [blame] | 84 | COMPONENT vpp-dev |
Damjan Marion | 4c64b6e | 2018-08-26 18:14:46 +0200 | [diff] [blame] | 85 | ) |