cmake: Fix plugins .h includes

Change-Id: I90600d000afb02e8969f3c01bcf9e4b5c10a7d39
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
diff --git a/src/cmake/plugin.cmake b/src/cmake/plugin.cmake
index a5b4bf5..6cae5e0 100644
--- a/src/cmake/plugin.cmake
+++ b/src/cmake/plugin.cmake
@@ -15,16 +15,19 @@
   cmake_parse_arguments(PLUGIN
     ""
     "LINK_FLAGS"
-    "SOURCES;API_FILES;MULTIARCH_SOURCES;LINK_LIBRARIES;API_TEST_SOURCES"
+    "SOURCES;API_FILES;MULTIARCH_SOURCES;LINK_LIBRARIES;INSTALL_HEADERS;API_TEST_SOURCES"
     ${ARGN}
   )
   set(plugin_name ${name}_plugin)
   set(api_headers)
   file(RELATIVE_PATH rpath ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
   foreach(f ${PLUGIN_API_FILES})
+    get_filename_component(dir ${f} DIRECTORY)
     vpp_generate_api_header(${f} plugins)
     list(APPEND api_headers ${f}.h ${f}.json)
     set_property(GLOBAL APPEND PROPERTY VPP_API_FILES ${rpath}/${f})
+    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${f}.h DESTINATION
+      include/vpp_plugins/${name}/${dir})
   endforeach()
   add_library(${plugin_name} SHARED ${PLUGIN_SOURCES} ${api_headers})
   add_dependencies(${plugin_name} vpp_version_h api_headers)
@@ -40,6 +43,12 @@
   if(PLUGIN_LINK_FLAGS)
     set_target_properties(${plugin_name} PROPERTIES LINK_FLAGS "${PLUGIN_LINK_FLAGS}")
   endif()
+  if(PLUGIN_INSTALL_HEADERS)
+    foreach(file ${PLUGIN_INSTALL_HEADERS})
+      get_filename_component(dir ${file} DIRECTORY)
+      install(FILES ${file} DESTINATION include/vpp_plugins/${name}/${dir})
+    endforeach()
+  endif()
   if(PLUGIN_API_TEST_SOURCES)
     set(test_plugin_name ${name}_test_plugin)
     add_library(${test_plugin_name} SHARED ${PLUGIN_API_TEST_SOURCES} ${api_headers})
diff --git a/src/plugins/abf/CMakeLists.txt b/src/plugins/abf/CMakeLists.txt
index 5db9757..54eeecf 100644
--- a/src/plugins/abf/CMakeLists.txt
+++ b/src/plugins/abf/CMakeLists.txt
@@ -19,4 +19,8 @@
 
   API_FILES
   abf.api
+
+  INSTALL_HEADERS
+  abf_all_api_h.h
+  abf_msg_enum.h
 )
diff --git a/src/plugins/acl/CMakeLists.txt b/src/plugins/acl/CMakeLists.txt
index c6ccb3b..75a1221 100644
--- a/src/plugins/acl/CMakeLists.txt
+++ b/src/plugins/acl/CMakeLists.txt
@@ -24,4 +24,9 @@
 
   API_TEST_SOURCES
   acl_test.c
+
+  INSTALL_HEADERS
+  acl_all_api_h.h
+  acl_msg_enum.h
+  manual_fns.h
 )
diff --git a/src/plugins/avf/CMakeLists.txt b/src/plugins/avf/CMakeLists.txt
index 8547fb7..66e6904 100644
--- a/src/plugins/avf/CMakeLists.txt
+++ b/src/plugins/avf/CMakeLists.txt
@@ -30,4 +30,8 @@
 
   API_TEST_SOURCES
   avf_test.c
+
+  INSTALL_HEADERS
+  avf_all_api_h.h
+  avf_msg_enum.h
 )
diff --git a/src/plugins/cdp/CMakeLists.txt b/src/plugins/cdp/CMakeLists.txt
index 0f3ade8..53542f0 100644
--- a/src/plugins/cdp/CMakeLists.txt
+++ b/src/plugins/cdp/CMakeLists.txt
@@ -23,5 +23,11 @@
 
   API_TEST_SOURCES
   cdp_test.c
+
+  INSTALL_HEADERS
+  cdp_all_api_h.h
+  cdp.h
+  cdp_msg_enum.h
+  cdp_protocol.h
 )
 
diff --git a/src/plugins/dpdk/CMakeLists.txt b/src/plugins/dpdk/CMakeLists.txt
index ce07f45..72b85c1 100644
--- a/src/plugins/dpdk/CMakeLists.txt
+++ b/src/plugins/dpdk/CMakeLists.txt
@@ -122,6 +122,11 @@
     API_TEST_SOURCES
     api/dpdk_test.c
 
+    INSTALL_HEADERS
+    device/dpdk.h
+    api/dpdk_all_api_h.h
+    ipsec/ipsec.h
+
     LINK_FLAGS
     ${DPDK_LINK_FLAGS}
   )
diff --git a/src/plugins/flowprobe/CMakeLists.txt b/src/plugins/flowprobe/CMakeLists.txt
index 4c1d4f3..b6e4996 100644
--- a/src/plugins/flowprobe/CMakeLists.txt
+++ b/src/plugins/flowprobe/CMakeLists.txt
@@ -19,6 +19,10 @@
   API_FILES
   flowprobe.api
 
+  INSTALL_HEADERS
+  flowprobe_all_api_h.h
+  flowprobe_msg_enum.h
+
   API_TEST_SOURCES
   flowprobe_test.c
 )
diff --git a/src/plugins/gbp/CMakeLists.txt b/src/plugins/gbp/CMakeLists.txt
index 738154a..c099060 100644
--- a/src/plugins/gbp/CMakeLists.txt
+++ b/src/plugins/gbp/CMakeLists.txt
@@ -27,4 +27,9 @@
 
   API_FILES
   gbp.api
+
+  INSTALL_HEADERS
+  gbp.h
+  gbp_all_api_h.h
+  gbp_msg_enum.h
 )
diff --git a/src/plugins/gtpu/CMakeLists.txt b/src/plugins/gtpu/CMakeLists.txt
index 2ad38eb..0a599bb 100644
--- a/src/plugins/gtpu/CMakeLists.txt
+++ b/src/plugins/gtpu/CMakeLists.txt
@@ -21,6 +21,10 @@
   API_FILES
   gtpu.api
 
+  INSTALL_HEADERS
+  gtpu_all_api_h.h
+  gtpu_msg_enum.h
+
   API_TEST_SOURCES
   gtpu_test.c
 )
diff --git a/src/plugins/igmp/CMakeLists.txt b/src/plugins/igmp/CMakeLists.txt
index 8ed8c48..089046e 100644
--- a/src/plugins/igmp/CMakeLists.txt
+++ b/src/plugins/igmp/CMakeLists.txt
@@ -29,4 +29,8 @@
 
   API_FILES
   igmp.api
+
+  INSTALL_HEADERS
+  igmp_all_api_h.h
+  igmp_msg_enum.h
 )
diff --git a/src/plugins/ila/CMakeLists.txt b/src/plugins/ila/CMakeLists.txt
index f03655b..cf5f34c 100644
--- a/src/plugins/ila/CMakeLists.txt
+++ b/src/plugins/ila/CMakeLists.txt
@@ -11,5 +11,11 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(ila SOURCES ila.c)
+add_vpp_plugin(ila
+  SOURCES
+  ila.c
+
+  INSTALL_HEADERS
+  ila.h
+)
 
diff --git a/src/plugins/ioam/CMakeLists.txt b/src/plugins/ioam/CMakeLists.txt
index 97381c5..3f46559 100644
--- a/src/plugins/ioam/CMakeLists.txt
+++ b/src/plugins/ioam/CMakeLists.txt
@@ -74,6 +74,37 @@
   ip6/ioam_cache.api
   udp-ping/udp_ping.api
 
+  INSTALL_HEADERS
+  lib-pot/pot_all_api_h.h
+  lib-pot/pot_msg_enum.h
+  lib-pot/pot_util.h
+  lib-pot/math64.h
+  export/ioam_export_all_api_h.h
+  export/ioam_export_msg_enum.h
+  lib-trace/trace_all_api_h.h
+  lib-trace/trace_msg_enum.h
+  lib-trace/trace_util.h
+  encap/ip6_ioam_trace.h
+  lib-trace/trace_config.h
+  export-common/ioam_export.h
+  lib-vxlan-gpe/vxlan_gpe_all_api_h.h
+  lib-vxlan-gpe/vxlan_gpe_msg_enum.h
+  lib-vxlan-gpe/vxlan_gpe_ioam_util.h
+  lib-vxlan-gpe/vxlan_gpe_ioam_packet.h
+  lib-vxlan-gpe/vxlan_gpe_ioam.h
+  export-vxlan-gpe/vxlan_gpe_ioam_export_all_api_h.h
+  export-vxlan-gpe/vxlan_gpe_ioam_export_msg_enum.h
+  encap/ip6_ioam_e2e.h
+  encap/ip6_ioam_seqno.h
+  lib-e2e/ioam_seqno_lib.h
+  ip6/ioam_cache_all_api_h.h
+  ip6/ioam_cache_msg_enum.h
+  udp-ping/udp_ping_packet.h
+  udp-ping/udp_ping.h
+  udp-ping/udp_ping_util.h
+  udp-ping/udp_ping_all_api_h.h
+  udp-ping/udp_ping_msg_enum.h
+
   API_TEST_SOURCES
   ioam_test.c
   lib-pot/pot_test.c
diff --git a/src/plugins/ixge/CMakeLists.txt b/src/plugins/ixge/CMakeLists.txt
index 14d101e..226652c 100644
--- a/src/plugins/ixge/CMakeLists.txt
+++ b/src/plugins/ixge/CMakeLists.txt
@@ -11,4 +11,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(ixge SOURCES ixge.c)
+add_vpp_plugin(ixge
+  SOURCES
+  ixge.c
+
+  INSTALL_HEADERS
+  ixge.h
+)
diff --git a/src/plugins/l2e/CMakeLists.txt b/src/plugins/l2e/CMakeLists.txt
index 27d5659..e063f7d 100644
--- a/src/plugins/l2e/CMakeLists.txt
+++ b/src/plugins/l2e/CMakeLists.txt
@@ -18,4 +18,9 @@
 
   API_FILES
   l2e.api
+
+  INSTALL_HEADERS
+  l2e.h
+  l2e_all_api_h.h
+  l2e_msg_enum.h
 )
diff --git a/src/plugins/lacp/CMakeLists.txt b/src/plugins/lacp/CMakeLists.txt
index 253786e..fd0413c 100644
--- a/src/plugins/lacp/CMakeLists.txt
+++ b/src/plugins/lacp/CMakeLists.txt
@@ -27,6 +27,16 @@
   API_FILES
   lacp.api
 
+  INSTALL_HEADERS
+  machine.h
+  rx_machine.h
+  tx_machine.h
+  mux_machine.h
+  ptx_machine.h
+  node.h
+  lacp_all_api_h.h
+  lacp_msg_enum.h
+
   API_TEST_SOURCES
   lacp_test.c
 )
diff --git a/src/plugins/lb/CMakeLists.txt b/src/plugins/lb/CMakeLists.txt
index 85acb62..406b16a 100644
--- a/src/plugins/lb/CMakeLists.txt
+++ b/src/plugins/lb/CMakeLists.txt
@@ -22,6 +22,11 @@
   API_FILES
   lb.api
 
+  INSTALL_HEADERS
+  lb.h
+  util.h
+  lbhash.h
+
   API_TEST_SOURCES
   lb_test.c
 )
diff --git a/src/plugins/mactime/CMakeLists.txt b/src/plugins/mactime/CMakeLists.txt
index ac5077d..9f5d431 100644
--- a/src/plugins/mactime/CMakeLists.txt
+++ b/src/plugins/mactime/CMakeLists.txt
@@ -19,6 +19,10 @@
   API_FILES
   mactime.api
 
+  INSTALL_HEADERS
+  mactime_all_api_h.h
+  mactime_msg_enum.h
+
   API_TEST_SOURCES
   mactime_test.c
 )
diff --git a/src/plugins/map/CMakeLists.txt b/src/plugins/map/CMakeLists.txt
index 9db0987..5bce036 100644
--- a/src/plugins/map/CMakeLists.txt
+++ b/src/plugins/map/CMakeLists.txt
@@ -26,4 +26,10 @@
 
   API_TEST_SOURCES
   map_test.c
+
+  INSTALL_HEADERS
+  map_all_api_h.h
+  map_msg_enum.h
+  map_dpo.h
+  map.h
 )
diff --git a/src/plugins/memif/CMakeLists.txt b/src/plugins/memif/CMakeLists.txt
index e704fd1..c0d6f0d 100644
--- a/src/plugins/memif/CMakeLists.txt
+++ b/src/plugins/memif/CMakeLists.txt
@@ -29,4 +29,9 @@
   MULTIARCH_SOURCES
   device.c
   node.c
+
+  INSTALL_HEADERS
+  memif.h
+  memif_all_api_h.h
+  memif_msg_enum.h
 )
diff --git a/src/plugins/nat/CMakeLists.txt b/src/plugins/nat/CMakeLists.txt
index ef59961..ef82213 100644
--- a/src/plugins/nat/CMakeLists.txt
+++ b/src/plugins/nat/CMakeLists.txt
@@ -44,4 +44,8 @@
 
   API_TEST_SOURCES
   nat_test.c
+
+  INSTALL_HEADERS
+  nat_all_api_h.h
+  nat_msg_enum.h
 )
diff --git a/src/plugins/pppoe/CMakeLists.txt b/src/plugins/pppoe/CMakeLists.txt
index 13b6b54..61ed7a4 100644
--- a/src/plugins/pppoe/CMakeLists.txt
+++ b/src/plugins/pppoe/CMakeLists.txt
@@ -22,6 +22,10 @@
   API_FILES
   pppoe.api
 
+  INSTALL_HEADERS
+  pppoe_all_api_h.h
+  pppoe_msg_enum.h
+
   API_TEST_SOURCES
   pppoe_test.c
 )
diff --git a/src/plugins/srv6-ad/CMakeLists.txt b/src/plugins/srv6-ad/CMakeLists.txt
index dc222bf..98662e2 100644
--- a/src/plugins/srv6-ad/CMakeLists.txt
+++ b/src/plugins/srv6-ad/CMakeLists.txt
@@ -15,4 +15,7 @@
   SOURCES
   ad.c
   node.c
+
+  INSTALL_HEADERS
+  ad.h
 )
diff --git a/src/plugins/srv6-am/CMakeLists.txt b/src/plugins/srv6-am/CMakeLists.txt
index 650142f..821c232 100644
--- a/src/plugins/srv6-am/CMakeLists.txt
+++ b/src/plugins/srv6-am/CMakeLists.txt
@@ -15,4 +15,7 @@
   SOURCES
   am.c
   node.c
+
+  INSTALL_HEADERS
+  am.h
 )
diff --git a/src/plugins/srv6-as/CMakeLists.txt b/src/plugins/srv6-as/CMakeLists.txt
index 3140c9d..036b86f 100644
--- a/src/plugins/srv6-as/CMakeLists.txt
+++ b/src/plugins/srv6-as/CMakeLists.txt
@@ -15,4 +15,7 @@
   SOURCES
   as.c
   node.c
+
+  INSTALL_HEADERS
+  as.h
 )
diff --git a/src/plugins/stn/CMakeLists.txt b/src/plugins/stn/CMakeLists.txt
index 38eda9b..8d6279c 100644
--- a/src/plugins/stn/CMakeLists.txt
+++ b/src/plugins/stn/CMakeLists.txt
@@ -19,6 +19,11 @@
   API_FILES
   stn.api
 
+  INSTALL_HEADERS
+  stn.h
+  stn_all_api_h.h
+  stn_msg_enum.h
+
   API_TEST_SOURCES
   stn_test.c
 )