summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/vapi/CMakeLists.txt
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2021-05-25 18:29:24 +0200
committerDamjan Marion <dmarion@me.com>2021-05-26 06:32:43 +0000
commita2d6d352c6926d2f8d4e50aeb1ec59802f32b37b (patch)
tree9ad70d1cd520fd11e18928793f8ed14f24c50985 /src/vpp-api/vapi/CMakeLists.txt
parent6621abf49aec6d764e654316ff75274c75d4c1a1 (diff)
tests: move vapi C/C++ test files into src/
Type: improvement Change-Id: Iaad004661db1e9076e6c27227878f1612fa7289f Signed-off-by: Damjan Marion <damarion@cisco.com> Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'src/vpp-api/vapi/CMakeLists.txt')
-rw-r--r--src/vpp-api/vapi/CMakeLists.txt49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/vpp-api/vapi/CMakeLists.txt b/src/vpp-api/vapi/CMakeLists.txt
index 04e7edd5f2a..626971f9108 100644
--- a/src/vpp-api/vapi/CMakeLists.txt
+++ b/src/vpp-api/vapi/CMakeLists.txt
@@ -14,6 +14,7 @@
include_directories (
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_BINARY_DIR}/..
+ ${CMAKE_CURRENT_BINARY_DIR}
)
add_vpp_library(vapiclient
@@ -58,3 +59,51 @@ install(
DESTINATION ${VPP_RUNTIME_DIR}
COMPONENT vpp-dev
)
+
+vpp_find_path(SUBUNIT_INCLUDE_DIR NAMES subunit/child.h)
+vpp_find_library(SUBUNIT_LIB NAMES subunit)
+
+if(SUBUNIT_INCLUDE_DIR AND SUBUNIT_LIB)
+ message (STATUS "Found subunit in ${SUBUNIT_INCLUDE_DIR} and ${SUBUNIT_LIB}")
+
+ add_custom_command(
+ OUTPUT fake.api.vapi.h
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/vapi_c_gen.py
+ ARGS --remove-path ${CMAKE_CURRENT_SOURCE_DIR}/fake.api.json
+ DEPENDS fake.api.json
+ COMMENT "Generating fake VAPI C header ${output_name}"
+ )
+
+ add_custom_command(
+ OUTPUT fake.api.vapi.hpp
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/vapi_cpp_gen.py
+ ARGS --remove-path ${CMAKE_CURRENT_SOURCE_DIR}/fake.api.json
+ DEPENDS fake.api.json
+ COMMENT "Generating fake VAPI C++ header ${output_name}"
+ )
+
+ add_custom_target(fake_api_vapi_h DEPENDS fake.api.vapi.h)
+ add_custom_target(fake_api_vapi_hpp DEPENDS fake.api.vapi.hpp)
+
+ set(libs vppinfra vlibmemoryclient svm pthread check rt m vapiclient ${SUBUNIT_LIB})
+
+ add_vpp_executable(vapi_c_test
+ SOURCES
+ vapi_c_test.c
+ DEPENDS fake_api_vapi_h
+ LINK_LIBRARIES ${libs}
+ )
+
+ enable_language(CXX)
+ add_vpp_executable(vapi_cpp_test
+ SOURCES
+ vapi_cpp_test.cpp
+ DEPENDS fake_api_vapi_hpp
+ LINK_LIBRARIES ${libs}
+ )
+
+else()
+ message (WARNING "subunit library not found - vapi tests disabled")
+endif()