cmake: add add_vpp_library and add_vpp_executable macros 86/14486/3
authorDamjan Marion <damarion@cisco.com>
Sun, 26 Aug 2018 09:04:40 +0000 (11:04 +0200)
committerDamjan Marion <damarion@cisco.com>
Sun, 26 Aug 2018 11:50:53 +0000 (13:50 +0200)
Change-Id: I1382021a6f616571b4b3243ba8c8999239d10815
Signed-off-by: Damjan Marion <damarion@cisco.com>
13 files changed:
src/CMakeLists.txt
src/cmake/exec.cmake [new file with mode: 0644]
src/cmake/library.cmake [new file with mode: 0644]
src/svm/CMakeLists.txt
src/vat/CMakeLists.txt
src/vcl/CMakeLists.txt
src/vlib/CMakeLists.txt
src/vlibapi/CMakeLists.txt
src/vlibmemory/CMakeLists.txt
src/vnet/CMakeLists.txt
src/vpp-api/CMakeLists.txt
src/vpp/CMakeLists.txt
src/vppinfra/CMakeLists.txt

index cd028cb..0f218cb 100644 (file)
@@ -53,19 +53,11 @@ find_package(OpenSSL REQUIRED)
 
 include(cmake/memfd.cmake)
 include(cmake/api.cmake)
+include(cmake/library.cmake)
+include(cmake/exec.cmake)
 include(cmake/plugin.cmake)
 include(cmake/deb.cmake)
 
-##############################################################################
-# header files
-##############################################################################
-function (vpp_add_header_files path)
-  foreach(file ${ARGN})
-    get_filename_component(dir ${file} DIRECTORY)
-    install(FILES ${file} DESTINATION include/${path}/${dir})
-  endforeach()
-endfunction()
-
 ##############################################################################
 # subdirs
 ##############################################################################
diff --git a/src/cmake/exec.cmake b/src/cmake/exec.cmake
new file mode 100644 (file)
index 0000000..b8277fa
--- /dev/null
@@ -0,0 +1,34 @@
+# Copyright (c) 2018 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+macro(add_vpp_executable exec)
+  cmake_parse_arguments(ARG
+    "ENABLE_EXPORTS"
+    ""
+    "SOURCES;LINK_LIBRARIES;DEPENDS"
+    ${ARGN}
+  )
+
+  add_executable(${exec} ${ARG_SOURCES})
+  if(ARG_LINK_LIBRARIES)
+    target_link_libraries(${exec} ${ARG_LINK_LIBRARIES})
+  endif()
+  if(ARG_ENABLE_EXPORTS)
+    set_target_properties(${exec} PROPERTIES ENABLE_EXPORTS 1)
+  endif()
+  if(ARG_DEPENDS)
+    add_dependencies(${exec} ${ARG_DEPENDS})
+  endif()
+  install(TARGETS ${exec} DESTINATION bin)
+endmacro()
+
diff --git a/src/cmake/library.cmake b/src/cmake/library.cmake
new file mode 100644 (file)
index 0000000..08831ed
--- /dev/null
@@ -0,0 +1,64 @@
+# Copyright (c) 2018 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+macro(add_vpp_library lib)
+  cmake_parse_arguments(ARG
+    ""
+    ""
+    "SOURCES;MULTIARCH_SOURCES;API_FILES;LINK_LIBRARIES;INSTALL_HEADERS;DEPENDS"
+    ${ARGN}
+  )
+
+  add_library(${lib} SHARED ${ARG_SOURCES})
+
+  # library deps
+  if(ARG_LINK_LIBRARIES)
+    target_link_libraries(${lib} ${ARG_LINK_LIBRARIES})
+  endif()
+  # install .so
+  install(TARGETS ${lib} DESTINATION lib)
+
+  if(ARG_MULTIARCH_SOURCES)
+    vpp_library_set_multiarch_sources(${lib} ${ARG_MULTIARCH_SOURCES})
+  endif()
+
+  if(ARG_API_FILES)
+    vpp_add_api_files(${lib}_api_headers ${ARG_API_FILES})
+    foreach(file ${ARG_API_FILES})
+      get_filename_component(dir ${file} DIRECTORY)
+      install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}.h DESTINATION include/${lib}/${dir})
+    endforeach()
+  endif()
+
+  if(ARG_DEPENDS)
+    add_dependencies(${lib} ${ARG_DEPENDS})
+  endif()
+
+  # install headers
+  if(ARG_INSTALL_HEADERS)
+    foreach(file ${ARG_INSTALL_HEADERS})
+      get_filename_component(dir ${file} DIRECTORY)
+      install(FILES ${file} DESTINATION include/${lib}/${dir})
+    endforeach()
+  endif()
+endmacro()
+
+##############################################################################
+# header files
+##############################################################################
+function (add_vpp_headers path)
+  foreach(file ${ARGN})
+    get_filename_component(dir ${file} DIRECTORY)
+    install(FILES ${file} DESTINATION include/${path}/${dir})
+  endforeach()
+endfunction()
index a3cca5a..203a9bb 100644 (file)
 ##############################################################################
 # svm shared library
 ##############################################################################
-add_library(svm SHARED
+add_vpp_library(svm
+  SOURCES
   svm.c
   ssvm.c
   svm_fifo.c
   svm_fifo_segment.c
   queue.c
   message_queue.c
-)
-target_link_libraries(svm vppinfra rt pthread)
-install(TARGETS svm DESTINATION lib)
-
-##############################################################################
-# svmdb shared library
-##############################################################################
-add_library(svmdb SHARED svmdb.c)
-target_link_libraries(svmdb svm vppinfra rt pthread)
-install(TARGETS svmdb DESTINATION lib)
 
-##############################################################################
-# svm headers
-##############################################################################
-vpp_add_header_files(svm
+  INSTALL_HEADERS
   ssvm.h
   svm_common.h
-  svmdb.h
   svm_fifo.h
   svm_fifo_segment.h
   queue.h
   message_queue.h
   svm.h
+  svmdb.h
+
+  LINK_LIBRARIES vppinfra rt pthread
 )
 
 ##############################################################################
-# svm tools
+# svmdb shared library
 ##############################################################################
+add_vpp_library(svmdb
+  SOURCES svmdb.c
+  LINK_LIBRARIES svm vppinfra rt pthread
+  )
 
-add_executable (svmtool svmtool.c)
-target_link_libraries (svmtool vppinfra svm)
-add_executable (svmdbtool svmdbtool.c)
-target_link_libraries (svmdbtool vppinfra svm svmdb)
+##############################################################################
+# svm tools
+##############################################################################
 
-install(
-  TARGETS svmtool svmdbtool
-  DESTINATION bin
+add_vpp_executable(svmtool
+  SOURCES svmtool.c
+  LINK_LIBRARIES vppinfra svm
 )
 
+add_vpp_executable (svmdbtool
+  SOURCES svmdbtool.c
+  LINK_LIBRARIES vppinfra svm svmdb
+)
index 9edfec7..feb335c 100644 (file)
 ##############################################################################
 # vat plugin shared library
 ##############################################################################
-add_library(vatplugin SHARED plugin_api.c)
-target_link_libraries(vatplugin vppinfra)
-add_dependencies (vatplugin vppinfra)
-install(TARGETS vatplugin DESTINATION lib)
+add_vpp_library(vatplugin
+  SOURCES plugin_api.c
+  LINK_LIBRARIES vppinfra
+)
 
 ##############################################################################
 # vpp_api_test
 ##############################################################################
-add_executable (vpp_api_test
+add_vpp_executable(vpp_api_test ENABLE_EXPORTS
+  SOURCES
   api_format.c
   main.c
   plugin.c
   json_format.c
-  vat.h
-  json_format.h
+
+  LINK_LIBRARIES
+  vlibmemoryclient
+  svm
+  vatplugin
+  vppinfra
+  Threads::Threads
+  rt m dl crypto
 )
-target_link_libraries (vpp_api_test vlibmemoryclient svm vatplugin vppinfra
-                       Threads::Threads rt m dl crypto)
-set_target_properties(vpp_api_test PROPERTIES ENABLE_EXPORTS 1)
-install(TARGETS vpp_api_test DESTINATION bin)
 
 ##############################################################################
 #  vpp_json_test
 ##############################################################################
-add_executable (vpp_json_test
-  json_format.h
-  json_format.c
-  json_test.c)
-target_link_libraries(vpp_json_test vppinfra m)
-set_target_properties(vpp_json_test PROPERTIES ENABLE_EXPORTS 1)
-install(TARGETS vpp_json_test DESTINATION bin)
+add_vpp_executable(vpp_json_test ENABLE_EXPORTS
+  SOURCES json_format.c json_test.c
+  LINK_LIBRARIES vppinfra m
+)
 
 ##############################################################################
 # vat headers
 ##############################################################################
-vpp_add_header_files(vat
-  vat.h
-  json_format.h
-)
+install(FILES vat.h json_format.h DESTINATION include/vat)
 
 ##############################################################################
 # restart
 ##############################################################################
-add_executable (vpp_restart restart.c)
-target_link_libraries (vpp_restart svmdb svm vppinfra pthread rt)
-install(TARGETS vpp_restart DESTINATION bin )
+add_vpp_executable(vpp_restart
+  SOURCES restart.c
+  LINK_LIBRARIES svm svmdb vppinfra Threads::Threads rt
+)
 
index e592ce5..840a62a 100644 (file)
 ##############################################################################
 # vppcom shared library
 ##############################################################################
-add_library(vppcom SHARED
+add_vpp_library(vppcom
+  SOURCES
   vppcom.c
   vcl_bapi.c
   vcl_cfg.c
   vcl_event.c
   vcl_private.c
+
+  LINK_LIBRARIES
+  vppinfra svm vlibmemoryclient rt pthread
 )
-target_link_libraries(vppcom vppinfra svm vlibmemoryclient rt pthread)
-install(TARGETS vppcom DESTINATION lib)
 
-##############################################################################
-# vcl headers
-##############################################################################
-vpp_add_header_files(vcl
+add_vpp_headers(vcl
   ldp.h
   vcl_event.h
   sock_test.h
@@ -43,7 +42,7 @@ vpp_add_header_files(vcl
 ##############################################################################
 option(VPP_BUILD_VCL_TESTS "Build vcl tests." ON)
 if(VPP_BUILD_VCL_TESTS)
-  set(VCL_TESTS
+  foreach(test
     vcl_test_server
     vcl_test_client
     sock_test_server
@@ -51,9 +50,7 @@ if(VPP_BUILD_VCL_TESTS)
     test_vcl_listener_server
     test_vcl_listener_client
   )
-  foreach(test ${VCL_TESTS})
-    add_executable(${test} ${test}.c)
-    target_link_libraries(${test} vppcom)
+    add_vpp_executable(${test} SOURCES ${test}.c LINK_LIBRARIES vppcom)
   endforeach()
 endif(VPP_BUILD_VCL_TESTS)
 
index dceb13e..59c725f 100644 (file)
@@ -24,7 +24,8 @@ install(FILES ${CMAKE_BINARY_DIR}/vlib/config.h DESTINATION include/vlib)
 ##############################################################################
 # vlib shared library
 ##############################################################################
-set(VLIB_SRCS
+add_vpp_library(vlib
+  SOURCES
   buffer.c
   buffer_serialize.c
   cli.c
@@ -53,16 +54,8 @@ set(VLIB_SRCS
   unix/mc_socket.c
   unix/plugin.c
   unix/util.c
-)
-
-add_library(vlib SHARED ${VLIB_SRCS})
-target_link_libraries(vlib vppinfra svm ${CMAKE_DL_LIBS})
-install(TARGETS vlib DESTINATION lib)
 
-##############################################################################
-# vlib headers
-##############################################################################
-vpp_add_header_files(vlib
+  INSTALL_HEADERS
   buffer_funcs.h
   buffer.h
   buffer_node.h
@@ -94,5 +87,6 @@ vpp_add_header_files(vlib
   unix/plugin.h
   unix/unix.h
   vlib.h
-)
 
+  LINK_LIBRARIES vppinfra svm ${CMAKE_DL_LIBS}
+)
index 27029bf..6c67008 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-vpp_add_header_files(vlibapi
+install(
+  FILES
   api_helper_macros.h
   api.h
   vat_helper_macros.h
   api_common.h
+
+  DESTINATION
+  include/vlibapi
 )
index 55c4767..ff0d25f 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-vpp_add_api_files(vlibmemory_api_headers
-  memclnt.api
-)
-
-add_library (vlibmemory SHARED
+add_vpp_library (vlibmemory
+  SOURCES
   memory_api.c
   memory_shared.c
   memory_client.c
@@ -24,12 +21,8 @@ add_library (vlibmemory SHARED
   vlib_api_cli.c
   ../vlibapi/api_shared.c
   ../vlibapi/node_serialize.c
-)
-target_link_libraries (vlibmemory vppinfra svm vlib)
-add_dependencies(vlibmemory vlibmemory_api_headers)
-install (TARGETS vlibmemory DESTINATION lib)
 
-vpp_add_header_files(vlibmemory
+  INSTALL_HEADERS
   vl_memory_msg_enum.h
   memory_shared.h
   vl_memory_api_h.h
@@ -38,16 +31,22 @@ vpp_add_header_files(vlibmemory
   api.h
   memory_client.h
   socket_api.h
+
+  API_FILES
+  memclnt.api
+
+  LINK_LIBRARIES vppinfra svm vlib
 )
+add_dependencies(vlibmemory vlibmemory_api_headers)
 
-add_library (vlibmemoryclient SHARED
+add_vpp_library (vlibmemoryclient
+  SOURCES
   memory_shared.c
   memory_client.c
   socket_client.c
   ../vlibapi/api_shared.c
   ../vlibapi/node_serialize.c
-)
 
-target_link_libraries (vlibmemoryclient vppinfra svm vlib)
+  LINK_LIBRARIES vppinfra svm vlib
+)
 add_dependencies(vlibmemoryclient vlibmemory_api_headers)
-install (TARGETS vlibmemoryclient DESTINATION lib)
index b24db20..491b8b9 100644 (file)
 add_definitions (-DWITH_LIBSSL=1)
 include_directories(${OPENSSL_INCLUDE_DIR})
 
-set(VNET_SRCS
-  adj/adj_bfd.c
-  adj/adj.c
-  adj/adj_delegate.c
-  adj/adj_glean.c
-  adj/adj_l2.c
-  adj/adj_mcast.c
-  adj/adj_midchain.c
-  adj/adj_nbr.c
-  adj/adj_nsh.c
-  adj/rewrite.c
-  bfd/bfd_api.c
-  bfd/bfd_cli.c
-  bfd/bfd_main.c
-  bfd/bfd_protocol.c
-  bfd/bfd_udp.c
-  bier/bier_api.c
-  bier/bier_bift_table.c
-  bier/bier_bit_string.c
-  bier/bier_disp_dispatch_node.c
-  bier/bier_disp_entry.c
-  bier/bier_disp_lookup_node.c
-  bier/bier_disp_table.c
-  bier/bier_drop.c
-  bier/bier_entry.c
-  bier/bier_fmask.c
-  bier/bier_fmask_db.c
-  bier/bier_imp.c
-  bier/bier_imp_node.c
-  bier/bier_input.c
-  bier/bier_lookup.c
-  bier/bier_output.c
-  bier/bier_table.c
-  bier/bier_test.c
-  bier/bier_types.c
-  bier/bier_update.c
-  bonding/bond_api.c
-  bonding/cli.c
-  bonding/device.c
-  bonding/node.c
+unset(VNET_SOURCES)
+unset(VNET_HEADERS)
+unset(VNET_API_FILES)
+unset(VNET_MULTIARCH_SOURCES)
+
+##############################################################################
+# Generic stuff
+##############################################################################
+list(APPEND VNET_SOURCES
   buffer.c
-  classify/classify_api.c
-  classify/flow_classify.c
-  classify/flow_classify_node.c
-  classify/in_out_acl.c
-  classify/ip_classify.c
-  classify/policer_classify.c
-  classify/vnet_classify.c
   config.c
-  cop/cop_api.c
+  devices/devices.c
+  devices/netlink.c
+  flow/flow.c
+  flow/flow_cli.c
+  handoff.c
+  interface.c
+  interface_api.c
+  interface_cli.c
+  interface_format.c
+  interface_output.c
+  interface_stats.c
+  misc.c
+  replication.c
+)
+
+list(APPEND VNET_HEADERS
+  api_errno.h
+  buffer.h
+  config.h
+  devices/devices.h
+  devices/netlink.h
+  flow/flow.h
+  global_funcs.h
+  handoff.h
+  interface.h
+  interface_funcs.h
+  ip/ip4_to_ip6.h
+  ip/ip6_to_ip4.h
+  l3_types.h
+  plugin/plugin.h
+  pipeline.h
+  replication.h
+  vnet.h
+  vnet_all_api_h.h
+  vnet_msg_enum.h
+  util/radix.h
+  util/refcount.h
+)
+
+list(APPEND VNET_API_FILES interface.api)
+
+##############################################################################
+# Policer infra
+##############################################################################
+list(APPEND VNET_SOURCES
+  policer/node_funcs.c
+  policer/policer.c
+  policer/xlate.c
+  policer/policer_api.c
+)
+
+list(APPEND VNET_HEADERS
+  policer/police.h
+  policer/policer.h
+  policer/xlate.h
+)
+
+list(APPEND VNET_API_FILES policer/policer.api)
+
+##############################################################################
+# Cop - junk filter
+##############################################################################
+list(APPEND VNET_SOURCES
   cop/cop.c
+  cop/node1.c
   cop/ip4_whitelist.c
   cop/ip6_whitelist.c
-  cop/node1.c
-  devices/af_packet/af_packet_api.c
-  devices/af_packet/af_packet.c
-  devices/af_packet/cli.c
-  devices/af_packet/device.c
-  devices/af_packet/node.c
-  devices/devices.c
-  devices/netlink.c
-  devices/netmap/cli.c
-  devices/netmap/device.c
-  devices/netmap/netmap_api.c
-  devices/netmap/netmap.c
-  devices/netmap/node.c
-  devices/pipe/pipe_api.c
-  devices/pipe/pipe.c
-  devices/tap/cli.c
-  devices/tap/tap.c
-  devices/tap/tapv2_api.c
-  devices/virtio/device.c
-  devices/virtio/node.c
-  devices/virtio/vhost_user_api.c
-  devices/virtio/vhost_user.c
-  devices/virtio/vhost_user_input.c
-  devices/virtio/vhost_user_output.c
-  devices/virtio/virtio.c
-  dhcp/client.c
-  dhcp/dhcp4_proxy_node.c
-  dhcp/dhcp6_client_common_dp.c
-  dhcp/dhcp6_ia_na_client_cp.c
-  dhcp/dhcp6_ia_na_client_dp.c
-  dhcp/dhcp6_pd_client_cp.c
-  dhcp/dhcp6_pd_client_dp.c
-  dhcp/dhcp6_proxy_node.c
-  dhcp/dhcp_api.c
-  dhcp/dhcp_client_detect.c
-  dhcp/dhcp_proxy.c
-  dns/dns.c
-  dns/reply_node.c
-  dns/request_node.c
-  dns/resolver_process.c
-  dpo/classify_dpo.c
-  dpo/dpo.c
-  dpo/drop_dpo.c
-  dpo/dvr_dpo.c
-  dpo/interface_rx_dpo.c
-  dpo/interface_tx_dpo.c
-  dpo/ip6_ll_dpo.c
-  dpo/ip_null_dpo.c
-  dpo/l3_proxy_dpo.c
-  dpo/load_balance.c
-  dpo/load_balance_map.c
-  dpo/lookup_dpo.c
-  dpo/mpls_disposition.c
-  dpo/mpls_label_dpo.c
-  dpo/punt_dpo.c
-  dpo/receive_dpo.c
-  dpo/replicate_dpo.c
-  ethernet/arp.c
+  cop/cop_api.c
+)
+
+list(APPEND VNET_HEADERS
+  cop/cop.h
+)
+
+list(APPEND VNET_API_FILES cop/cop.api)
+
+##############################################################################
+# Layer 2 protocols go here
+##############################################################################
+
+##############################################################################
+# Layer 2 protocol: Ethernet
+##############################################################################
+list(APPEND VNET_SOURCES
   ethernet/format.c
   ethernet/init.c
   ethernet/interface.c
   ethernet/node.c
-  ethernet/p2p_ethernet_api.c
-  ethernet/p2p_ethernet.c
-  ethernet/p2p_ethernet_input.c
   ethernet/pg.c
   ethernet/sfp.c
-  feature/feature_api.c
-  feature/feature.c
-  feature/registration.c
-  fib/fib_api.c
-  fib/fib_attached_export.c
-  fib/fib_bfd.c
-  fib/fib.c
-  fib/fib_entry.c
-  fib/fib_entry_cover.c
-  fib/fib_entry_delegate.c
-  fib/fib_entry_src_adj.c
-  fib/fib_entry_src_api.c
-  fib/fib_entry_src.c
-  fib/fib_entry_src_default_route.c
-  fib/fib_entry_src_interface.c
-  fib/fib_entry_src_interpose.c
-  fib/fib_entry_src_lisp.c
-  fib/fib_entry_src_mpls.c
-  fib/fib_entry_src_rr.c
-  fib/fib_entry_src_special.c
-  fib/fib_node.c
-  fib/fib_node_list.c
-  fib/fib_path.c
-  fib/fib_path_ext.c
-  fib/fib_path_list.c
-  fib/fib_table.c
-  fib/fib_test.c
-  fib/fib_types.c
-  fib/fib_urpf_list.c
-  fib/fib_walk.c
-  fib/ip4_fib.c
-  fib/ip6_fib.c
-  fib/mpls_fib.c
-  flow/flow.c
-  flow/flow_cli.c
-  geneve/decap.c
-  geneve/encap.c
-  geneve/geneve_api.c
-  geneve/geneve.c
-  gre/gre_api.c
-  gre/gre.c
-  gre/interface.c
-  gre/node.c
-  gre/pg.c
-  handoff.c
-  hdlc/hdlc.c
+  ethernet/p2p_ethernet.c
+  ethernet/p2p_ethernet_input.c
+  ethernet/p2p_ethernet_api.c
+)
+
+list(APPEND VNET_MULTIARCH_SOURCES l2/l2_output.c)
+
+list(APPEND VNET_HEADERS
+  ethernet/error.def
+  ethernet/ethernet.h
+  ethernet/packet.h
+  ethernet/types.def
+  ethernet/sfp.h
+  ethernet/p2p_ethernet.h
+)
+
+list(APPEND VNET_API_FILES ethernet/p2p_ethernet.api)
+
+##############################################################################
+# Layer 2 protocol: Ethernet bridging
+##############################################################################
+list(APPEND VNET_SOURCES
+  l2/feat_bitmap.c
+  l2/l2_api.c
+  l2/l2_bd.c
+  l2/l2_bvi.c
+  l2/l2_input_classify.c
+  l2/l2_output_classify.c
+  l2/l2_efp_filter.c
+  l2/l2_fib.c
+  l2/l2_flood.c
+  l2/l2_fwd.c
+  l2/l2_input.c
+  l2/l2_input_vtr.c
+  l2/l2_learn.c
+  l2/l2_output.c
+  l2/l2_in_out_acl.c
+  l2/l2_patch.c
+  l2/l2_rw.c
+  l2/l2_vtr.c
+  l2/l2_xcrw.c
+)
+
+list(APPEND VNET_HEADERS
+  l2/feat_bitmap.h
+  l2/l2_input.h
+  l2/l2_output.h
+  l2/l2_vtr.h
+  l2/l2_input_vtr.h
+  l2/l2_efp_filter.h
+  l2/l2_fwd.h
+  l2/l2_bd.h
+  l2/l2_bvi.h
+  l2/l2_flood.h
+  l2/l2_fib.h
+  l2/l2_rw.h
+  l2/l2_xcrw.h
+  l2/l2_classify.h
+)
+
+list(APPEND VNET_API_FILES l2/l2.api)
+
+##############################################################################
+# Layer 2 protocol: SRP
+##############################################################################
+list(APPEND VNET_SOURCES
+  srp/format.c
+  srp/interface.c
+  srp/node.c
+  srp/pg.c
+)
+
+list(APPEND VNET_HEADERS
+  srp/packet.h
+  srp/srp.h
+)
+
+##############################################################################
+# Layer 2 protocol: PPP
+##############################################################################
+list(APPEND VNET_SOURCES
+  ppp/node.c
+  ppp/pg.c
+  ppp/ppp.c
+)
+
+list(APPEND VNET_HEADERS
+  ppp/error.def
+  ppp/ppp.h
+  ppp/packet.h
+)
+
+##############################################################################
+# Layer 2 protocol: HDLC
+##############################################################################
+list(APPEND VNET_SOURCES
   hdlc/node.c
   hdlc/pg.c
-  interface_api.c
-  interface.c
-  interface_cli.c
-  interface_format.c
-  interface_output.c
-  interface_stats.c
-  ipfix-export/flow_api.c
-  ipfix-export/flow_report.c
-  ipfix-export/flow_report_classify.c
+  hdlc/hdlc.c
+)
+
+list(APPEND VNET_HEADERS
+  hdlc/error.def
+  hdlc/hdlc.h
+  hdlc/packet.h
+)
+
+##############################################################################
+# Layer 2 protocol: LLC
+##############################################################################
+list(APPEND VNET_SOURCES
+  llc/llc.c
+  llc/node.c
+  llc/pg.c
+)
+
+list(APPEND VNET_HEADERS
+  llc/llc.h
+)
+
+##############################################################################
+# Layer 2 protocol: SNAP
+##############################################################################
+list(APPEND VNET_SOURCES
+  snap/snap.c
+  snap/node.c
+  snap/pg.c
+)
+
+list(APPEND VNET_HEADERS
+  snap/snap.h
+)
+
+##############################################################################
+# Layer 2 / vxlan
+##############################################################################
+list(APPEND VNET_SOURCES
+  vxlan/vxlan.c
+  vxlan/encap.c
+  vxlan/decap.c
+  vxlan/vxlan_api.c
+)
+
+list(APPEND VNET_HEADERS
+  vxlan/vxlan.h
+  vxlan/vxlan_packet.h
+  vxlan/vxlan_error.def
+)
+
+list(APPEND VNET_API_FILES vxlan/vxlan.api)
+
+##############################################################################
+# Layer 2 / Geneve
+##############################################################################
+list(APPEND VNET_SOURCES
+  geneve/geneve.c
+  geneve/encap.c
+  geneve/decap.c
+  geneve/geneve_api.c
+)
+
+list(APPEND VNET_HEADERS
+  geneve/geneve.h
+  geneve/geneve_packet.h
+  geneve/geneve_error.def
+)
+
+list(APPEND VNET_API_FILES geneve/geneve.api)
+
+##############################################################################
+# Layer 2 / Bonding
+##############################################################################
+list(APPEND VNET_SOURCES
+  bonding/cli.c
+  bonding/node.c
+  bonding/device.c
+  bonding/bond_api.c
+)
+
+list(APPEND VNET_HEADERS
+  bonding/node.h
+)
+
+list(APPEND VNET_MULTIARCH_SOURCES bonding/node.c)
+list(APPEND VNET_API_FILES bonding/bond.api)
+
+##############################################################################
+# Layer 2 / LLDP
+##############################################################################
+list(APPEND VNET_SOURCES
+  lldp/lldp_input.c
+  lldp/lldp_node.c
+  lldp/lldp_output.c
+  lldp/lldp_cli.c
+  lldp/lldp_api.c
+)
+
+list(APPEND VNET_HEADERS
+  lldp/lldp_protocol.h
+  lldp/lldp.h
+)
+
+list(APPEND VNET_API_FILES lldp/lldp.api)
+
+##############################################################################
+# Layer 2/3 "classify"
+##############################################################################
+list(APPEND VNET_SOURCES
+  classify/vnet_classify.c
+  classify/ip_classify.c
+  classify/in_out_acl.c
+  classify/policer_classify.c
+  classify/flow_classify.c
+  classify/flow_classify_node.c
+  classify/vnet_classify.h
+  classify/classify_api.c
+)
+
+list(APPEND VNET_HEADERS
+  classify/vnet_classify.h
+  classify/in_out_acl.h
+  classify/policer_classify.h
+  classify/flow_classify.h
+)
+
+list(APPEND VNET_API_FILES classify/classify.api)
+
+##############################################################################
+# Layer 3 protocols go here
+##############################################################################
+
+##############################################################################
+# Layer 3 protocol: IP v4/v6
+##############################################################################
+list(APPEND VNET_SOURCES
   ip/format.c
   ip/icmp4.c
   ip/icmp6.c
   ip/ip46_cli.c
+  ip/ip_types_api.c
   ip/ip4_format.c
   ip/ip4_forward.c
+  ip/ip4_punt_drop.c
   ip/ip4_input.c
-  ip/ip4_mtrie.c
   ip/ip4_options.c
+  ip/ip4_mtrie.c
   ip/ip4_pg.c
-  ip/ip4_punt_drop.c
-  ip/ip4_reassembly.c
   ip/ip4_source_and_port_range_check.c
   ip/ip4_source_check.c
+  ip/ip4_reassembly.c
   ip/ip6_format.c
   ip/ip6_forward.c
-  ip/ip6_hop_by_hop.c
-  ip/ip6_input.c
   ip/ip6_ll_table.c
   ip/ip6_ll_types.c
+  ip/ip6_punt_drop.c
+  ip/ip6_hop_by_hop.c
+  ip/ip6_input.c
   ip/ip6_neighbor.c
   ip/ip6_pg.c
-  ip/ip6_punt_drop.c
   ip/ip6_reassembly.c
+  ip/rd_cp.c
+  ip/ip_neighbor.c
   ip/ip_api.c
-  ip/ip.c
   ip/ip_checksum.c
   ip/ip_frag.c
+  ip/ip.c
   ip/ip_init.c
   ip/ip_in_out_acl.c
-  ipip/ipip_api.c
-  ipip/ipip.c
-  ipip/ipip_cli.c
-  ip/ip_neighbor.c
-  ipip/node.c
-  ipip/sixrd.c
-  ip/ip_types_api.c
   ip/lookup.c
   ip/ping.c
   ip/punt_api.c
   ip/punt.c
-  ip/rd_cp.c
+)
+
+list(APPEND VNET_HEADERS
+  ip/format.h
+  ip/icmp46_packet.h
+  ip/icmp4.h
+  ip/icmp6.h
+  ip/igmp_packet.h
+  ip/ip4_error.h
+  ip/ip4.h
+  ip/ip4_mtrie.h
+  ip/ip4_packet.h
+  ip/ip6_error.h
+  ip/ip6.h
+  ip/ip6_hop_by_hop.h
+  ip/ip6_hop_by_hop_packet.h
+  ip/ip6_packet.h
+  ip/ip6_neighbor.h
+  ip/ip.h
+  ip/ip_packet.h
+  ip/ip_source_and_port_range_check.h
+  ip/ip_neighbor.h
+  ip/lookup.h
+  ip/ports.def
+  ip/protocols.def
+  ip/punt_error.def
+  ip/punt.h
+)
+
+list(APPEND VNET_API_FILES
+  ip/ip.api
+  ip/rd_cp.api
+  ip/punt.api
+)
+
+list(APPEND VNET_MULTIARCH_SOURCES ip/ip4_forward.c ip/ip4_input.c)
+
+##############################################################################
+# Layer 2/3 ARP
+##############################################################################
+list(APPEND VNET_SOURCES
+  ethernet/arp.c
+)
+
+list(APPEND VNET_HEADERS
+  ethernet/arp_packet.h
+  ethernet/arp.h
+)
+
+##############################################################################
+# Bidirectional Forwarding Detection
+##############################################################################
+
+list(APPEND VNET_HEADERS
+  bfd/bfd_protocol.h
+  bfd/bfd_main.h
+  bfd/bfd_api.h
+  bfd/bfd_udp.h
+)
+
+list(APPEND VNET_SOURCES
+  bfd/bfd_api.h
+  bfd/bfd_udp.c
+  bfd/bfd_main.c
+  bfd/bfd_protocol.c
+  bfd/bfd_cli.c
+  bfd/bfd_api.c
+)
+
+list(APPEND VNET_API_FILES bfd/bfd.api)
+
+##############################################################################
+# Layer 3 protocol: IPSec
+##############################################################################
+list(APPEND VNET_SOURCES
+  ipsec/ipsec.c
+  ipsec/ipsec_cli.c
+  ipsec/ipsec_format.c
+  ipsec/ipsec_input.c
+  ipsec/ipsec_if.c
+  ipsec/ipsec_if_in.c
+  ipsec/esp_format.c
+  ipsec/esp_encrypt.c
+  ipsec/esp_decrypt.c
   ipsec/ah_decrypt.c
   ipsec/ah_encrypt.c
-  ipsec/esp_decrypt.c
-  ipsec/esp_encrypt.c
-  ipsec/esp_format.c
-  ipsec-gre/interface.c
-  ipsec-gre/ipsec_gre_api.c
-  ipsec-gre/ipsec_gre.c
-  ipsec-gre/node.c
   ipsec/ikev2.c
-  ipsec/ikev2_cli.c
   ipsec/ikev2_crypto.c
-  ipsec/ikev2_format.c
+  ipsec/ikev2_cli.c
   ipsec/ikev2_payload.c
+  ipsec/ikev2_format.c
   ipsec/ipsec_api.c
-  ipsec/ipsec.c
-  ipsec/ipsec_cli.c
-  ipsec/ipsec_format.c
-  ipsec/ipsec_if.c
-  ipsec/ipsec_if_in.c
-  ipsec/ipsec_input.c
+)
+
+list(APPEND VNET_API_FILES ipsec/ipsec.api)
+
+list(APPEND VNET_SOURCES
   ipsec/ipsec_output.c
-  l2/feat_bitmap.c
-  l2/l2_api.c
-  l2/l2_bd.c
-  l2/l2_bvi.c
-  l2/l2_efp_filter.c
-  l2/l2_fib.c
-  l2/l2_flood.c
-  l2/l2_fwd.c
-  l2/l2_in_out_acl.c
-  l2/l2_input.c
-  l2/l2_input_classify.c
-  l2/l2_input_vtr.c
-  l2/l2_learn.c
-  l2/l2_output.c
-  l2/l2_output_classify.c
-  l2/l2_patch.c
-  l2/l2_rw.c
-  l2/l2_vtr.c
-  l2/l2_xcrw.c
-  l2tp/decap.c
-  l2tp/encap.c
-  l2tp/l2tp_api.c
+)
+
+list(APPEND VNET_HEADERS
+  ipsec/ipsec.h
+  ipsec/esp.h
+  ipsec/ah.h
+  ipsec/ikev2.h
+  ipsec/ikev2_priv.h
+)
+
+##############################################################################
+# Layer 3 protocol: osi
+##############################################################################
+list(APPEND VNET_SOURCES
+  osi/node.c
+  osi/osi.c
+  osi/pg.c
+)
+
+list(APPEND VNET_HEADERS
+  osi/osi.h
+)
+
+##############################################################################
+# Layer 4 protocol: tcp
+##############################################################################
+list(APPEND VNET_SOURCES
+  tcp/tcp_api.c
+  tcp/tcp_format.c
+  tcp/tcp_pg.c
+  tcp/tcp_syn_filter4.c
+  tcp/tcp_output.c
+  tcp/tcp_input.c
+  tcp/tcp_newreno.c
+  tcp/tcp.c
+)
+
+list(APPEND VNET_HEADERS
+  tcp/tcp_packet.h
+  tcp/tcp_timer.h
+  tcp/tcp_debug.h
+  tcp/tcp.h
+  tcp/tcp_error.def
+)
+
+list(APPEND VNET_API_FILES tcp/tcp.api)
+
+##############################################################################
+# Layer 4 protocol: udp
+##############################################################################
+list(APPEND VNET_SOURCES
+  udp/udp.c
+  udp/udp_input.c
+  udp/udp_format.c
+  udp/udp_local.c
+  udp/udp_pg.c
+  udp/udp_encap_node.c
+  udp/udp_encap.c
+  udp/udp_api.c
+)
+
+list(APPEND VNET_HEADERS
+  udp/udp_error.def
+  udp/udp.h
+  udp/udp_packet.h
+)
+
+list(APPEND VNET_API_FILES udp/udp.api)
+
+##############################################################################
+# Layer 4 protocol: sctp
+##############################################################################
+list(APPEND VNET_SOURCES
+  sctp/sctp_api.c
+  sctp/sctp.c
+  sctp/sctp_pg.c
+  sctp/sctp_input.c
+  sctp/sctp_output.c
+  sctp/sctp_format.c
+)
+
+list(APPEND VNET_HEADERS
+  sctp/sctp_error.def
+  sctp/sctp_packet.h
+  sctp/sctp_timer.h
+  sctp/sctp.h
+)
+
+list(APPEND VNET_API_FILES sctp/sctp.api)
+
+##############################################################################
+# Tunnel protocol: gre
+##############################################################################
+list(APPEND VNET_SOURCES
+  gre/gre.c
+  gre/node.c
+  gre/interface.c
+  gre/pg.c
+  gre/gre_api.c
+)
+
+list(APPEND VNET_HEADERS
+  gre/gre.h
+  gre/packet.h
+  gre/error.def
+)
+
+list(APPEND VNET_API_FILES gre/gre.api)
+
+##############################################################################
+# Tunnel protocol: ipip
+##############################################################################
+list(APPEND VNET_SOURCES
+  ipip/ipip.c
+  ipip/node.c
+  ipip/sixrd.c
+  ipip/ipip_api.c
+  ipip/ipip_cli.c
+)
+
+list(APPEND VNET_HEADERS
+  ipip/ipip.h
+)
+
+list(APPEND VNET_API_FILES ipip/ipip.api)
+
+##############################################################################
+# Tunnel protocol: l2tpv3
+##############################################################################
+list(APPEND VNET_SOURCES
   l2tp/l2tp.c
+  l2tp/encap.c
+  l2tp/decap.c
   l2tp/pg.c
-  lawful-intercept/lawful_intercept.c
-  lawful-intercept/node.c
+  l2tp/l2tp_api.c
+)
+
+list(APPEND VNET_HEADERS
+  l2tp/l2tp.h
+  l2tp/packet.h
+)
+
+list(APPEND VNET_API_FILES l2tp/l2tp.api)
+
+##############################################################################
+# Tunnel protocol: gre+mpls
+##############################################################################
+list(APPEND VNET_SOURCES
+  mpls/mpls.c
+  mpls/mpls_lookup.c
+  mpls/mpls_output.c
+  mpls/mpls_features.c
+  mpls/mpls_input.c
+  mpls/interface.c
+  mpls/mpls_tunnel.c
+  mpls/pg.c
+  mpls/mpls_api.c
+)
+
+list(APPEND VNET_HEADERS
+  mpls/mpls.h
+  mpls/mpls_types.h
+  mpls/mpls_tunnel.h
+  mpls/packet.h
+  mpls/error.def
+)
+
+list(APPEND VNET_API_FILES mpls/mpls.api)
+
+##############################################################################
+# Tunnel protocol: vxlan-gpe
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  vxlan-gpe/vxlan_gpe.c
+  vxlan-gpe/encap.c
+  vxlan-gpe/decap.c
+  vxlan-gpe/vxlan_gpe_api.c
+)
+
+list(APPEND VNET_HEADERS
+  vxlan-gpe/vxlan_gpe.h
+  vxlan-gpe/vxlan_gpe_packet.h
+  vxlan-gpe/vxlan_gpe_error.def
+)
+
+list(APPEND VNET_API_FILES vxlan-gpe/vxlan_gpe.api)
+
+##############################################################################
+# Tunnel protocol: ipsec+gre
+##############################################################################
+list(APPEND VNET_SOURCES
+  ipsec-gre/ipsec_gre.c
+  ipsec-gre/node.c
+  ipsec-gre/interface.c
+  ipsec-gre/ipsec_gre_api.c
+)
+
+list(APPEND VNET_HEADERS
+  ipsec-gre/ipsec_gre.h
+  ipsec-gre/error.def
+)
+
+list(APPEND VNET_API_FILES ipsec-gre/ipsec_gre.api)
+
+##############################################################################
+# LISP control plane: lisp-cp
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  lisp-cp/lisp_types.c
+  lisp-cp/lisp_cp_dpo.c
   lisp-cp/control.c
   lisp-cp/gid_dictionary.c
-  lisp-cp/lisp_api.c
-  lisp-cp/lisp_cli.c
-  lisp-cp/lisp_cp_dpo.c
   lisp-cp/lisp_msg_serdes.c
-  lisp-cp/lisp_types.c
-  lisp-cp/one_api.c
-  lisp-cp/one_cli.c
   lisp-cp/packets.c
-  lisp-gpe/decap.c
-  lisp-gpe/interface.c
-  lisp-gpe/lisp_gpe_adjacency.c
-  lisp-gpe/lisp_gpe_api.c
+  lisp-cp/one_cli.c
+  lisp-cp/lisp_cli.c
+  lisp-cp/one_api.c
+  lisp-cp/lisp_api.c
+)
+
+list(APPEND VNET_HEADERS
+  lisp-cp/lisp_types.h
+  lisp-cp/packets.h
+  lisp-cp/gid_dictionary.h
+  lisp-cp/lisp_cp_messages.h
+  lisp-cp/lisp_msg_serdes.h
+  lisp-cp/control.h
+)
+
+list(APPEND VNET_API_FILES lisp-cp/lisp.api)
+list(APPEND VNET_API_FILES lisp-cp/one.api)
+
+##############################################################################
+# Tunnel protocol: lisp-gpe
+##############################################################################
+
+list(APPEND VNET_SOURCES
   lisp-gpe/lisp_gpe.c
-  lisp-gpe/lisp_gpe_fwd_entry.c
   lisp-gpe/lisp_gpe_sub_interface.c
-  lisp-gpe/lisp_gpe_tenant.c
+  lisp-gpe/lisp_gpe_adjacency.c
   lisp-gpe/lisp_gpe_tunnel.c
-  llc/llc.c
-  llc/node.c
-  llc/pg.c
-  lldp/lldp_api.c
-  lldp/lldp_cli.c
-  lldp/lldp_input.c
-  lldp/lldp_node.c
-  lldp/lldp_output.c
-  mfib/ip4_mfib.c
-  mfib/ip6_mfib.c
-  mfib/mfib_entry.c
-  mfib/mfib_forward.c
-  mfib/mfib_itf.c
-  mfib/mfib_signal.c
-  mfib/mfib_table.c
-  mfib/mfib_test.c
-  mfib/mfib_types.c
-  misc.c
-  mpls/interface.c
-  mpls/mpls_api.c
-  mpls/mpls.c
-  mpls/mpls_features.c
-  mpls/mpls_input.c
-  mpls/mpls_lookup.c
-  mpls/mpls_output.c
-  mpls/mpls_tunnel.c
-  mpls/pg.c
-  osi/node.c
-  osi/osi.c
-  osi/pg.c
+  lisp-gpe/lisp_gpe_fwd_entry.c
+  lisp-gpe/lisp_gpe_tenant.c
+  lisp-gpe/interface.c
+  lisp-gpe/decap.c
+  lisp-gpe/lisp_gpe_api.c
+)
+
+list(APPEND VNET_HEADERS
+  lisp-gpe/lisp_gpe.h
+  lisp-gpe/lisp_gpe_fwd_entry.h
+  lisp-gpe/lisp_gpe_tenant.h
+  lisp-gpe/lisp_gpe_packet.h
+  lisp-gpe/lisp_gpe_error.def
+)
+
+list(APPEND VNET_API_FILES lisp-gpe/lisp_gpe.api)
+
+##############################################################################
+# DHCP client
+##############################################################################
+list(APPEND VNET_SOURCES
+  dhcp/client.c
+  dhcp/dhcp_client_detect.c
+  dhcp/dhcp6_client_common_dp.c
+  dhcp/dhcp6_pd_client_dp.c
+  dhcp/dhcp6_pd_client_cp.c
+  dhcp/dhcp6_ia_na_client_dp.c
+  dhcp/dhcp6_ia_na_client_cp.c
+  dhcp/dhcp_api.c
+)
+
+list(APPEND VNET_HEADERS
+  dhcp/client.h
+  dhcp/dhcp6_client_common_dp.h
+  dhcp/dhcp6_pd_client_dp.h
+  dhcp/dhcp6_ia_na_client_dp.h
+)
+
+list(APPEND VNET_API_FILES
+  dhcp/dhcp.api
+  dhcp/dhcp6_pd_client_cp.api
+  dhcp/dhcp6_ia_na_client_cp.api
+)
+
+##############################################################################
+# DHCP proxy
+##############################################################################
+list(APPEND VNET_SOURCES
+  dhcp/dhcp6_proxy_node.c
+  dhcp/dhcp4_proxy_node.c
+  dhcp/dhcp_proxy.c
+)
+
+list(APPEND VNET_HEADERS
+  dhcp/dhcp4_packet.h
+  dhcp/dhcp6_packet.h
+  dhcp/dhcp_proxy.h
+  dhcp/dhcp6_proxy_error.def
+  dhcp/dhcp4_proxy_error.def
+)
+
+##############################################################################
+# ipv6 segment routing
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  srv6/sr.c
+  srv6/sr_localsid.c
+  srv6/sr_policy_rewrite.c
+  srv6/sr_steering.c
+  srv6/sr_api.c
+)
+
+list(APPEND VNET_HEADERS
+  srv6/sr_packet.h
+  srv6/sr.h
+)
+
+list(APPEND VNET_API_FILES srv6/sr.api)
+
+##############################################################################
+# mpls segment routing
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  srmpls/sr_mpls_policy.c
+  srmpls/sr_mpls_steering.c
+  srmpls/sr_mpls_api.c
+)
+
+list(APPEND VNET_HEADERS
+  srmpls/sr_mpls.h
+)
+
+list(APPEND VNET_API_FILES srmpls/sr_mpls.api)
+
+##############################################################################
+# IPFIX / netflow v10
+##############################################################################
+list(APPEND VNET_SOURCES
+  ipfix-export/flow_report.c
+  ipfix-export/flow_api.c
+)
+
+list(APPEND VNET_HEADERS
+  ipfix-export/flow_report.h
+  ipfix-export/ipfix_info_elements.h
+  ipfix-export/ipfix_packet.h
+)
+
+list(APPEND VNET_API_FILES ipfix-export/ipfix_export.api)
+
+##############################################################################
+# IPFIX classify code
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  ipfix-export/flow_report_classify.c
+)
+
+list(APPEND VNET_HEADERS
+  ipfix-export/flow_report_classify.h
+)
+
+##############################################################################
+# lawful intercept
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  lawful-intercept/lawful_intercept.c
+  lawful-intercept/node.c
+)
+
+list(APPEND VNET_HEADERS
+  lawful-intercept/lawful_intercept.h
+)
+
+##############################################################################
+# SPAN (port mirroring)
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  span/span_api.c
+  span/span.c
+  span/node.c
+)
+
+list(APPEND VNET_HEADERS
+  span/span.h
+)
+
+list(APPEND VNET_API_FILES span/span.api)
+
+##############################################################################
+# DNS proxy, API
+##############################################################################
+list(APPEND VNET_SOURCES
+  dns/dns.c
+  dns/dns.h
+  dns/dns_packet.h
+  dns/reply_node.c
+  dns/request_node.c
+  dns/resolver_process.c
+)
+
+list(APPEND VNET_HEADERS
+  dns/dns.h
+)
+
+list(APPEND VNET_API_FILES dns/dns.api)
+
+##############################################################################
+# Packet generator
+##############################################################################
+
+list(APPEND VNET_SOURCES
   pg/cli.c
   pg/edit.c
   pg/init.c
   pg/input.c
   pg/output.c
-  pg/pg_api.c
   pg/stream.c
-  policer/node_funcs.c
-  policer/policer_api.c
-  policer/policer.c
-  policer/xlate.c
-  ppp/node.c
-  ppp/pg.c
-  ppp/ppp.c
-  qos/qos_api.c
-  qos/qos_egress_map.c
-  qos/qos_mark.c
-  qos/qos_record.c
-  qos/qos_types.c
-  replication.c
-  sctp/sctp_api.c
-  sctp/sctp.c
-  sctp/sctp_format.c
-  sctp/sctp_input.c
-  sctp/sctp_output.c
-  sctp/sctp_pg.c
+  pg/pg_api.c
+)
+
+list(APPEND VNET_HEADERS
+  pg/pg.h
+  pg/edit.h
+)
+
+list(APPEND VNET_API_FILES pg/pg.api)
+
+##############################################################################
+# virtio
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  devices/virtio/device.c
+  devices/virtio/node.c
+  devices/virtio/vhost_user.c
+  devices/virtio/vhost_user_input.c
+  devices/virtio/vhost_user_output.c
+  devices/virtio/vhost_user_api.c
+  devices/virtio/virtio.c
+)
+
+list(APPEND VNET_HEADERS
+  devices/virtio/virtio.h
+  devices/virtio/vhost_user.h
+)
+
+list(APPEND VNET_MULTIARCH_SOURCES
+  devices/virtio/vhost_user_input.c
+  devices/virtio/vhost_user_output.c
+)
+
+list(APPEND VNET_API_FILES devices/virtio/vhost_user.api)
+
+##############################################################################
+# tap interface (with virtio backend)
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  devices/tap/cli.c
+  devices/tap/tap.c
+  devices/tap/tapv2_api.c
+)
+
+list(APPEND VNET_HEADERS
+  devices/tap/tap.h
+)
+
+list(APPEND VNET_API_FILES devices/tap/tapv2.api)
+
+##############################################################################
+# tap interface (with virtio backend)
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  devices/pipe/pipe_api.c
+  devices/pipe/pipe.c
+)
+
+list(APPEND VNET_HEADERS
+  devices/pipe/pipe.h
+)
+
+list(APPEND VNET_API_FILES devices/pipe/pipe.api)
+
+##############################################################################
+# session managmeent
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  session/session.c
+  session/session_table.c
+  session/session_rules_table.c
+  session/session_lookup.c
+  session/session_node.c
+  session/transport.c
   session/application.c
+  session/session_cli.c
   session/application_interface.c
   session/application_namespace.c
+  session/segment_manager.c
+  session/session_test.c
+  session/session_api.c
+)
+
+list(APPEND VNET_HEADERS
+  session/session.h
+  session/session_table.h
+  session/session_rules_table.h
+  session/stream_session.h
+  session/session_lookup.h
+  session/application.h
+  session/transport.h
+  session/transport_interface.h
+  session/application_interface.h
+  session/application_namespace.h
+  session/session_debug.h
+  session/segment_manager.h
+  session/mma_template.h
+  session/mma_template.c
+  session/mma_16.h
+  session/mma_40.h
+)
+
+list(APPEND VNET_API_FILES session/session.api)
+
+##############################################################################
+# session layer applications
+##############################################################################
+
+list(APPEND VNET_SOURCES
   session-apps/echo_client.c
   session-apps/echo_server.c
   session-apps/http_server.c
   session-apps/proxy.c
-  session/segment_manager.c
-  session/session_api.c
-  session/session.c
-  session/session_cli.c
-  session/session_lookup.c
-  session/session_node.c
-  session/session_rules_table.c
-  session/session_table.c
-  session/session_test.c
-  session/transport.c
-  snap/node.c
-  snap/pg.c
-  snap/snap.c
-  span/node.c
-  span/span_api.c
-  span/span.c
-  srmpls/sr_mpls_api.c
-  srmpls/sr_mpls_policy.c
-  srmpls/sr_mpls_steering.c
-  srp/format.c
-  srp/interface.c
-  srp/node.c
-  srp/pg.c
-  srv6/sr_api.c
-  srv6/sr.c
-  srv6/sr_localsid.c
-  srv6/sr_policy_rewrite.c
-  srv6/sr_steering.c
-  tcp/tcp_api.c
-  tcp/tcp.c
-  tcp/tcp_format.c
-  tcp/tcp_input.c
-  tcp/tcp_newreno.c
-  tcp/tcp_output.c
-  tcp/tcp_pg.c
-  tcp/tcp_syn_filter4.c
+)
+
+list(APPEND VNET_HEADERS
+  session-apps/echo_client.h
+  session-apps/proxy.h
+)
+
+##############################################################################
+# TLS protocol
+##############################################################################
+
+list(APPEND VNET_SOURCES
   tls/tls.c
-  udp/udp_api.c
-  udp/udp.c
-  udp/udp_encap.c
-  udp/udp_encap_node.c
-  udp/udp_format.c
-  udp/udp_input.c
-  udp/udp_local.c
-  udp/udp_pg.c
+)
+
+list(APPEND VNET_HEADERS
+  tls/tls.h
+)
+
+##############################################################################
+# Linux packet interface
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  devices/af_packet/af_packet.c
+  devices/af_packet/device.c
+  devices/af_packet/node.c
+  devices/af_packet/cli.c
+  devices/af_packet/af_packet_api.c
+)
+
+list(APPEND VNET_HEADERS
+  devices/af_packet/af_packet.h
+)
+
+list(APPEND VNET_API_FILES devices/af_packet/af_packet.api)
+
+##############################################################################
+# NETMAP interface
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  devices/netmap/netmap.c
+  devices/netmap/device.c
+  devices/netmap/node.c
+  devices/netmap/cli.c
+  devices/netmap/netmap_api.c
+)
+
+list(APPEND VNET_HEADERS
+  devices/netmap/netmap.h
+)
+
+list(APPEND VNET_API_FILES devices/netmap/netmap.api)
+
+##############################################################################
+# Driver feature graph arc support
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  feature/feature.c
+  feature/feature_api.c
+  feature/registration.c
+)
+
+list(APPEND VNET_HEADERS
+  feature/feature.h
+)
+
+list(APPEND VNET_API_FILES feature/feature.api)
+
+##############################################################################
+# Unix kernel related
+##############################################################################
+
+# FIXME: unix/hgshm.c
+
+list(APPEND VNET_SOURCES
   unix/gdb_funcs.c
   unix/pcap.c
   unix/tap_api.c
   unix/tapcli.c
   unix/tuntap.c
-  util/radix.c
-  util/refcount.c
-  util/trajectory.c
-  vxlan/decap.c
-  vxlan/encap.c
-  vxlan-gpe/decap.c
-  vxlan-gpe/encap.c
-  vxlan-gpe/vxlan_gpe_api.c
-  vxlan-gpe/vxlan_gpe.c
-  vxlan/vxlan_api.c
-  vxlan/vxlan.c
 )
 
-vpp_add_api_files(vnet_api_headers
-  vxlan-gpe/vxlan_gpe.api
-  ip/ip.api
-  ip/rd_cp.api
-  ip/ip_types.api
-  ip/punt.api
-  fib/fib_types.api
-  devices/virtio/vhost_user.api
-  devices/af_packet/af_packet.api
-  devices/tap/tapv2.api
-  devices/netmap/netmap.api
-  devices/pipe/pipe.api
-  l2tp/l2tp.api
-  bier/bier.api
-  ipsec-gre/ipsec_gre.api
-  cop/cop.api
-  ipsec/ipsec.api
-  lisp-gpe/lisp_gpe.api
-  lldp/lldp.api
-  vxlan/vxlan.api
-  srmpls/sr_mpls.api
-  pg/pg.api
-  bonding/bond.api
-  dns/dns.api
-  feature/feature.api
-  dhcp/dhcp.api
-  dhcp/dhcp6_pd_client_cp.api
-  dhcp/dhcp6_ia_na_client_cp.api
-  sctp/sctp.api
-  ipip/ipip.api
-  qos/qos.api
-  interface.api
-  udp/udp.api
-  lisp-cp/one.api
-  lisp-cp/lisp.api
-  mpls/mpls.api
-  l2/l2.api
-  geneve/geneve.api
-  tcp/tcp.api
-  unix/tap.api
-  srv6/sr.api
-  gre/gre.api
-  span/span.api
-  policer/policer.api
-  session/session.api
-  ethernet/p2p_ethernet.api
-  ipfix-export/ipfix_export.api
-  classify/classify.api
-  bfd/bfd.api
-)
-
-vpp_add_header_files(vnet
-  l3_types.h
-  vxlan-gpe/vxlan_gpe.h
-  vxlan-gpe/vxlan_gpe_packet.h
-  vxlan-gpe/vxlan_gpe_error.def
-  ip/icmp6.h
-  ip/ip_source_and_port_range_check.h
-  ip/ports.def
-  ip/ip6_to_ip4.h
-  ip/ip4_error.h
-  ip/ip6_error.h
-  ip/ip4_packet.h
-  ip/lookup.h
-  ip/ip_neighbor.h
-  ip/ip6_hop_by_hop_packet.h
-  ip/format.h
-  ip/ip4_mtrie.h
-  ip/icmp4.h
-  ip/icmp46_packet.h
-  ip/igmp_packet.h
-  ip/protocols.def
-  ip/ip6_neighbor.h
-  ip/ip4.h
-  ip/ip6_hop_by_hop.h
-  ip/punt.h
-  ip/ip6.h
-  ip/ip6_packet.h
-  ip/punt_error.def
-  ip/ip.h
-  ip/ip_packet.h
-  ip/ip4_to_ip6.h
-  adj/adj_nbr.h
-  adj/adj_glean.h
-  adj/adj_nsh.h
-  adj/adj.h
-  adj/adj_types.h
-  adj/rewrite.h
-  fib/fib_table.h
-  fib/fib_entry.h
+list(APPEND VNET_HEADERS
+  unix/pcap.h
+  unix/tuntap.h
+  unix/tapcli.h
+)
+
+list(APPEND VNET_API_FILES unix/tap.api)
+
+##############################################################################
+# FIB
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  fib/fib.c
+  fib/fib_test.c
+  fib/ip4_fib.c
+  fib/ip6_fib.c
+  fib/mpls_fib.c
+  fib/fib_table.c
+  fib/fib_walk.c
+  fib/fib_types.c
+  fib/fib_node.c
+  fib/fib_node_list.c
+  fib/fib_entry.c
+  fib/fib_entry_src.c
+  fib/fib_entry_src_rr.c
+  fib/fib_entry_src_interface.c
+  fib/fib_entry_src_interpose.c
+  fib/fib_entry_src_default_route.c
+  fib/fib_entry_src_special.c
+  fib/fib_entry_src_api.c
+  fib/fib_entry_src_adj.c
+  fib/fib_entry_src_mpls.c
+  fib/fib_entry_src_lisp.c
+  fib/fib_entry_cover.c
+  fib/fib_entry_delegate.c
+  fib/fib_path_list.c
+  fib/fib_path.c
+  fib/fib_path_ext.c
+  fib/fib_urpf_list.c
+  fib/fib_attached_export.c
+  fib/fib_api.c
+  fib/fib_bfd.c
+)
+
+list(APPEND VNET_HEADERS
   fib/fib.h
+  fib/fib_api.h
   fib/ip4_fib.h
-  fib/fib_node.h
   fib/ip6_fib.h
   fib/fib_types.h
+  fib/fib_table.h
+  fib/fib_node.h
   fib/fib_node_list.h
+  fib/fib_entry.h
   fib/fib_entry_delegate.h
-  devices/virtio/virtio.h
-  devices/virtio/vhost_user.h
-  devices/af_packet/af_packet.h
-  devices/devices.h
-  devices/tap/tap.h
-  devices/netmap/netmap.h
-  devices/netlink.h
-  devices/pipe/pipe.h
-  vnet_msg_enum.h
+)
+
+##############################################################################
+# ADJ
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  adj/adj_nbr.c
+  adj/adj_glean.c
+  adj/adj_midchain.c
+  adj/adj_mcast.c
+  adj/adj_l2.c
+  adj/adj_nsh.c
+  adj/adj.c
+  adj/rewrite.c
+  adj/adj_bfd.c
+  adj/adj_delegate.c
+)
+
+list(APPEND VNET_HEADERS
+  adj/adj.h
+  adj/adj_types.h
+  adj/adj_glean.h
+  adj/adj_nsh.h
+  adj/adj_nbr.h
+  adj/rewrite.h
+)
+
+##############################################################################
+# Data-Plane Objects
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  dpo/dpo.c
+  dpo/drop_dpo.c
+  dpo/ip_null_dpo.c
+  dpo/ip6_ll_dpo.c
+  dpo/punt_dpo.c
+  dpo/receive_dpo.c
+  dpo/load_balance.c
+  dpo/load_balance_map.c
+  dpo/lookup_dpo.c
+  dpo/classify_dpo.c
+  dpo/replicate_dpo.c
+  dpo/interface_rx_dpo.c
+  dpo/interface_tx_dpo.c
+  dpo/mpls_disposition.c
+  dpo/mpls_label_dpo.c
+  dpo/l3_proxy_dpo.c
+  dpo/dvr_dpo.c
+)
+
+list(APPEND VNET_HEADERS
   dpo/load_balance.h
-  dpo/dpo.h
-  dpo/punt_dpo.h
-  dpo/lookup_dpo.h
   dpo/drop_dpo.h
+  dpo/lookup_dpo.h
+  dpo/punt_dpo.h
   dpo/classify_dpo.h
   dpo/receive_dpo.h
   dpo/ip_null_dpo.h
   dpo/replicate_dpo.h
-  l2tp/packet.h
-  l2tp/l2tp.h
-  global_funcs.h
-  bier/bier_types.h
-  bier/bier_entry.h
-  bier/bier_table.h
-  bier/bier_update.h
-  ipsec-gre/ipsec_gre.h
-  ipsec-gre/error.def
-  interface_funcs.h
-  lawful-intercept/lawful_intercept.h
-  util/radix.h
-  util/refcount.h
-  cop/cop.h
-  ipsec/ikev2.h
-  ipsec/ikev2_priv.h
-  ipsec/ah.h
-  ipsec/esp.h
-  ipsec/ipsec.h
-  flow/flow.h
-  lisp-gpe/lisp_gpe_packet.h
-  lisp-gpe/lisp_gpe_error.def
-  lisp-gpe/lisp_gpe_fwd_entry.h
-  lisp-gpe/lisp_gpe_tenant.h
-  lisp-gpe/lisp_gpe.h
-  lldp/lldp.h
-  lldp/lldp_protocol.h
-  pipeline.h
-  hdlc/packet.h
-  hdlc/hdlc.h
-  hdlc/error.def
-  vxlan/vxlan_packet.h
-  vxlan/vxlan.h
-  vxlan/vxlan_error.def
-  srmpls/sr_mpls.h
-  pg/edit.h
-  pg/pg.h
-  bonding/node.h
-  dns/dns.h
-  feature/feature.h
-  dhcp/dhcp6_pd_client_dp.h
-  dhcp/client.h
-  dhcp/dhcp4_proxy_error.def
-  dhcp/dhcp4_packet.h
-  dhcp/dhcp6_proxy_error.def
-  dhcp/dhcp6_client_common_dp.h
-  dhcp/dhcp_proxy.h
-  dhcp/dhcp6_ia_na_client_dp.h
-  dhcp/dhcp6_packet.h
-  tls/tls.h
-  sctp/sctp_error.def
-  sctp/sctp_packet.h
-  sctp/sctp_timer.h
-  sctp/sctp.h
-  ipip/ipip.h
-  handoff.h
-  api_errno.h
-  osi/osi.h
-  udp/udp_error.def
-  udp/udp_packet.h
-  udp/udp.h
-  ppp/packet.h
-  ppp/ppp.h
-  ppp/error.def
-  lisp-cp/lisp_types.h
-  lisp-cp/lisp_cp_messages.h
-  lisp-cp/packets.h
-  lisp-cp/gid_dictionary.h
-  lisp-cp/lisp_msg_serdes.h
-  lisp-cp/control.h
-  vnet.h
-  mpls/packet.h
-  mpls/mpls.h
-  mpls/mpls_tunnel.h
-  mpls/mpls_types.h
-  mpls/error.def
-  mfib/mfib_types.h
+  dpo/dpo.h
+)
+
+##############################################################################
+# Multicast FIB
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  mfib/mfib_test.c
+  mfib/mfib_forward.c
+  mfib/ip4_mfib.c
+  mfib/ip6_mfib.c
+  mfib/mfib_types.c
+  mfib/mfib_signal.c
+  mfib/mfib_itf.c
+  mfib/mfib_entry.c
+  mfib/mfib_table.c
+)
+
+list(APPEND VNET_HEADERS
   mfib/ip4_mfib.h
+  mfib/mfib_types.h
   mfib/mfib_table.h
-  interface.h
-  plugin/plugin.h
-  l2/l2_xcrw.h
-  l2/l2_output.h
-  l2/l2_rw.h
-  l2/l2_fib.h
-  l2/l2_vtr.h
-  l2/feat_bitmap.h
-  l2/l2_flood.h
-  l2/l2_classify.h
-  l2/l2_bd.h
-  l2/l2_efp_filter.h
-  l2/l2_fwd.h
-  l2/l2_input.h
-  l2/l2_input_vtr.h
-  l2/l2_bvi.h
-  geneve/geneve.h
-  geneve/geneve_error.def
-  geneve/geneve_packet.h
-  tcp/tcp_packet.h
-  tcp/tcp_debug.h
-  tcp/tcp_timer.h
-  tcp/tcp_error.def
-  tcp/tcp.h
-  session-apps/echo_client.h
-  session-apps/proxy.h
-  unix/pcap.h
-  unix/tuntap.h
-  unix/tapcli.h
-  srv6/sr.h
-  srv6/sr_packet.h
-  gre/packet.h
-  gre/gre.h
-  gre/error.def
-  span/span.h
-  policer/xlate.h
-  policer/policer.h
-  policer/police.h
-  config.h
-  buffer.h
-  llc/llc.h
-  session/session_lookup.h
-  session/mma_template.c
-  session/application.h
-  session/segment_manager.h
-  session/mma_template.h
-  session/session_rules_table.h
-  session/session.h
-  session/transport.h
-  session/session_debug.h
-  session/mma_16.h
-  session/mma_40.h
-  session/session_table.h
-  session/transport_interface.h
-  session/application_namespace.h
-  session/stream_session.h
-  session/application_interface.h
-  replication.h
-  ethernet/packet.h
-  ethernet/arp.h
-  ethernet/p2p_ethernet.h
-  ethernet/sfp.h
-  ethernet/types.def
-  ethernet/arp_packet.h
-  ethernet/ethernet.h
-  ethernet/error.def
-  ipfix-export/ipfix_info_elements.h
-  ipfix-export/flow_report.h
-  ipfix-export/flow_report_classify.h
-  ipfix-export/ipfix_packet.h
-  snap/snap.h
-  classify/flow_classify.h
-  classify/in_out_acl.h
-  classify/vnet_classify.h
-  classify/policer_classify.h
-  bfd/bfd_udp.h
-  bfd/bfd_protocol.h
-  bfd/bfd_main.h
-  srp/packet.h
-  srp/srp.h
 )
 
-add_library(vnet SHARED ${VNET_SRCS})
+##############################################################################
+# Utilities
+##############################################################################
 
-vpp_library_set_multiarch_sources(vnet
-  bonding/node.c
-  ip/ip4_forward.c
-  ip/ip4_input.c
-  l2/l2_output.c
-  devices/virtio/vhost_user_input.c
-  devices/virtio/vhost_user_output.c
+list(APPEND VNET_SOURCES
+  util/radix.c
+  util/refcount.c
+  util/trajectory.c
 )
-target_link_libraries(vnet vlib ${OPENSSL_LIBRARIES})
-add_dependencies(vnet api_headers)
 
-#
-# Install
-#
-install(TARGETS vnet DESTINATION lib)
+##############################################################################
+# QoS
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  qos/qos_types.c
+  qos/qos_api.c
+  qos/qos_egress_map.c
+  qos/qos_record.c
+  qos/qos_mark.c
+)
+
+list(APPEND VNET_API_FILES qos/qos.api)
+
+##############################################################################
+# BIER
+##############################################################################
+
+list(APPEND VNET_SOURCES
+  bier/bier_bit_string.c
+  bier/bier_entry.c
+  bier/bier_fmask.c
+  bier/bier_fmask_db.c
+  bier/bier_input.c
+  bier/bier_lookup.c
+  bier/bier_output.c
+  bier/bier_table.c
+  bier/bier_types.c
+  bier/bier_test.c
+  bier/bier_api.c
+  bier/bier_drop.c
+  bier/bier_update.c
+  bier/bier_imp_node.c
+  bier/bier_imp.c
+  bier/bier_disp_entry.c
+  bier/bier_disp_lookup_node.c
+  bier/bier_disp_dispatch_node.c
+  bier/bier_disp_table.c
+  bier/bier_bift_table.c
+)
+
+list(APPEND VNET_HEADERS
+  bier/bier_types.h
+  bier/bier_entry.h
+  bier/bier_update.h
+  bier/bier_table.h
+)
+
+list(APPEND VNET_API_FILES bier/bier.api)
+
+add_vpp_library(vnet
+  SOURCES ${VNET_SOURCES}
+  MULTIARCH_SOURCES ${VNET_MULTIARCH_SOURCES}
+  INSTALL_HEADERS ${VNET_HEADERS}
+  API_FILES ${VNET_API_FILES}
+  LINK_LIBRARIES vppinfra svm vlib ${OPENSSL_LIBRARIES}
+  DEPENDS api_headers
+)
index 9a71957..cfabc71 100644 (file)
 # vpp api client library
 ##############################################################################
 
-add_library (vppapiclient SHARED
+add_vpp_library (vppapiclient
+  SOURCES
   client/client.c
   client/libvppapiclient.map
+
+  LINK_LIBRARIES vppinfra vlibmemoryclient svm pthread m rt
 )
-target_link_libraries(vppapiclient vppinfra vlibmemoryclient svm pthread m rt)
 add_dependencies(vppapiclient vpp_version_h api_headers)
-install(TARGETS vppapiclient DESTINATION lib)
 
-vpp_add_header_files(vpp-api
+add_vpp_headers(vpp-api
   client/vppapiclient.h
 )
index 8799d26..80114bd 100644 (file)
@@ -33,12 +33,22 @@ add_custom_target(vpp_version_h
 ##############################################################################
 option(VPP_API_TEST_BUILTIN "Use builtin VPP API test." ON)
 
-vpp_add_api_files(vpp_api_headers
+set(VPP_API_FILES
   api/vpe.api
   stats/stats.api
   oam/oam.api
 )
 
+vpp_add_api_files(vpp_api_headers ${VPP_API_FILES})
+
+foreach(file ${VPP_API_FILES})
+  get_filename_component(dir ${file} DIRECTORY)
+  install(
+    FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}.h
+    DESTINATION include/vpp/${dir}
+  )
+endforeach()
+
 set(VPP_SOURCES
   vnet/main.c
   app/vpe_cli.c
@@ -61,15 +71,14 @@ if(VPP_API_TEST_BUILTIN)
   add_definitions(-DVPP_API_TEST_BUILTIN=1)
 endif()
 
-add_executable (vpp ${VPP_SOURCES})
-
-target_link_libraries(vpp svm vlib vppinfra vlibmemory vnet Threads::Threads
-                     ${CMAKE_DL_LIBS})
-add_dependencies(vpp vpp_version_h api_headers)
-set_target_properties(vpp PROPERTIES ENABLE_EXPORTS 1)
-install(TARGETS vpp DESTINATION bin)
+add_vpp_executable(vpp
+  ENABLE_EXPORTS
+  SOURCES ${VPP_SOURCES}
+  LINK_LIBRARIES svm vlib vppinfra vlibmemory vnet Threads::Threads ${CMAKE_DL_LIBS}
+  DEPENDS vpp_version_h api_headers
+)
 
-vpp_add_header_files(vpp
+add_vpp_headers(vpp
   api/vpe_msg_enum.h
   api/vpe_all_api_h.h
 )
@@ -77,28 +86,32 @@ vpp_add_header_files(vpp
 ##############################################################################
 # vppctl binary
 ##############################################################################
-add_executable(vppctl app/vppctl.c)
-target_link_libraries(vppctl vppinfra)
-install(TARGETS vppctl DESTINATION bin)
+add_vpp_executable(vppctl
+  SOURCES app/vppctl.c
+  LINK_LIBRARIES vppinfra
+)
 
 ##############################################################################
 # vpp_get_metrics binary
 ##############################################################################
-add_executable (vpp_get_metrics api/vpp_get_metrics.c ${VPP_API_HDRS})
-target_link_libraries (vpp_get_metrics vppinfra svm svmdb)
-install(TARGETS vpp_get_metrics DESTINATION bin)
+add_vpp_executable(vpp_get_metrics
+  SOURCES api/vpp_get_metrics.c
+  LINK_LIBRARIES vppinfra svm svmdb
+  DEPENDS api_headers
+)
 
 ##############################################################################
 # stats binaries
 ##############################################################################
-add_executable(summary_stats_client api/summary_stats_client.c)
-add_executable(stat_client app/stat_client.c)
-add_dependencies(summary_stats_client api_headers)
-add_dependencies(stat_client api_headers)
-target_link_libraries(summary_stats_client vppinfra svm vlibmemoryclient)
-target_link_libraries(stat_client vppinfra svm vlibmemoryclient)
+add_vpp_executable(summary_stats_client
+  SOURCES api/summary_stats_client.c
+  LINK_LIBRARIES vppinfra svm vlibmemoryclient
+  DEPENDS api_headers
+)
 
-##############################################################################
-# install
-##############################################################################
+add_vpp_executable(stat_client
+  SOURCES app/stat_client.c
+  LINK_LIBRARIES vppinfra svm vlibmemoryclient
+  DEPENDS api_headers
+)
 
index ecd1528..f358339 100644 (file)
@@ -88,26 +88,7 @@ set(VPPINFRA_SRCS
   linux/sysfs.c
 )
 
-if(VPP_USE_DLMALLOC)
-  list(APPEND VPPINFRA_SRCS
-    dlmalloc.c
-    mem_dlmalloc.c
-  )
-else(VPP_USE_DLMALLOC)
-  list(APPEND VPPINFRA_SRCS
-    mheap.c
-    mem_mheap.c
-  )
-endif(VPP_USE_DLMALLOC)
-
-add_library(vppinfra SHARED ${VPPINFRA_SRCS})
-target_link_libraries(vppinfra m)
-install(TARGETS vppinfra DESTINATION lib)
-
-##############################################################################
-# vppinfra headers
-##############################################################################
-vpp_add_header_files(vppinfra
+set(VPPINFRA_HEADERS
   asm_mips.h
   asm_x86.h
   bihash_16_8.h
@@ -200,12 +181,32 @@ vpp_add_header_files(vppinfra
   linux/sysfs.h
 )
 
+
+if(VPP_USE_DLMALLOC)
+  list(APPEND VPPINFRA_SRCS
+    dlmalloc.c
+    mem_dlmalloc.c
+  )
+else(VPP_USE_DLMALLOC)
+  list(APPEND VPPINFRA_SRCS
+    mheap.c
+    mem_mheap.c
+  )
+endif(VPP_USE_DLMALLOC)
+
+add_vpp_library(vppinfra
+  SOURCES ${VPPINFRA_SRCS}
+  LINK_LIBRARIES m
+  INSTALL_HEADERS ${VPPINFRA_HEADERS}
+)
+
+##############################################################################
+# vppinfra headers
+##############################################################################
 option(VPP_BUILD_VPPINFRA_TESTS "Build vppinfra tests." OFF)
 if(VPP_BUILD_VPPINFRA_TESTS)
-  set(VPPINFRA_TESTS
-    bihash_template
+  foreach(test
     bihash_vec88
-    cuckoo_bihash
     cuckoo_template
     dlist
     elf
@@ -232,14 +233,18 @@ if(VPP_BUILD_VPPINFRA_TESTS)
     tw_timer
     valloc
     vec
-    vhash
     zvec
   )
-  foreach(test ${VPPINFRA_TESTS})
-    add_executable(test_${test} test_${test}.c)
-    target_link_libraries(test_${test} vppinfra)
+    add_vpp_executable(test_${test}
+      SOURCES test_${test}.c
+      LINK_LIBRARIES vppinfra
+      )
   endforeach()
 
-  target_link_libraries(test_bihash_template Threads::Threads)
-  target_link_libraries(test_cuckoo_bihash Threads::Threads)
+  foreach(test bihash_template cuckoo_bihash)
+    add_vpp_executable(test_${test}
+      SOURCES test_${test}.c
+      LINK_LIBRARIES vppinfra Threads::Threads
+      )
+  endforeach()
 endif(VPP_BUILD_VPPINFRA_TESTS)