blob: abf9ffb14fa7615c78e9243e50e4f708f70fd951 [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}/..
17)
18
19unset(VAPICLIENT_API_C_HEADERS)
20unset(VAPICLIENT_API_CPP_HEADERS)
21
22get_property(VPP_API_FILES GLOBAL PROPERTY VPP_API_FILES)
23foreach(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 Mariond1318252018-08-30 20:27:32 +020033 DEPENDS ${input} vapi_c_gen.py vapi_json_parser.py api_headers
Damjan Marion4c64b6e2018-08-26 18:14:46 +020034 COMMENT "Generating VAPI C header ${output}"
35 )
36 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${output} DESTINATION include/vapi)
37 list(APPEND VAPICLIENT_API_CPP_HEADERS ${output})
38
39 # C++ VAPI Headers
40 get_filename_component(output ${f}.vapi.hpp NAME)
41 add_custom_command(
42 OUTPUT ${output}
43 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
44 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/vapi_cpp_gen.py
Mohsin Kazmib3abec72018-08-27 13:17:09 +020045 ARGS --gen-h-prefix=vapi --remove-path ${input}
Damjan Mariond1318252018-08-30 20:27:32 +020046 DEPENDS ${input} vapi_cpp_gen.py vapi_json_parser.py api_headers
Damjan Marion4c64b6e2018-08-26 18:14:46 +020047 COMMENT "Generating VAPI C++ header ${output}"
48 )
49 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${output} DESTINATION include/vapi)
50 list(APPEND VAPICLIENT_API_CPP_HEADERS ${output})
51endforeach ()
52
Damjan Marion33ed3e42018-08-27 15:59:30 +020053add_custom_target(all-vapi-headers DEPENDS
Damjan Marion4c64b6e2018-08-26 18:14:46 +020054 ${VAPICLIENT_API_C_HEADERS}
55 ${VAPICLIENT_API_CPP_HEADERS}
56)
57
58add_vpp_library(vapiclient
59 SOURCES
60 vapi.c
61 libvapiclient.map
62
63 LINK_LIBRARIES vppinfra vlibmemoryclient svm pthread m rt
Damjan Marion33ed3e42018-08-27 15:59:30 +020064 DEPENDS all-vapi-headers
Damjan Marion4c64b6e2018-08-26 18:14:46 +020065)
66
67install(
68 FILES
69 vapi.h
70 vapi_common.h
71 vapi_dbg.h
72 vapi.hpp
73 vapi_internal.h
74
75 DESTINATION include/vapi
76)