cmake: improve add_vpp_plugin macro 82/14482/1
authorDamjan Marion <damarion@cisco.com>
Sat, 25 Aug 2018 09:33:29 +0000 (11:33 +0200)
committerDamjan Marion <damarion@cisco.com>
Sat, 25 Aug 2018 09:56:03 +0000 (11:56 +0200)
Change-Id: Iffd5c45ab242a919592a1f686f7f880936b68a1a
Signed-off-by: Damjan Marion <damarion@cisco.com>
29 files changed:
src/plugins/CMakeLists.txt
src/plugins/abf/CMakeLists.txt
src/plugins/acl/CMakeLists.txt
src/plugins/avf/CMakeLists.txt
src/plugins/cdp/CMakeLists.txt
src/plugins/dpdk/CMakeLists.txt
src/plugins/flowprobe/CMakeLists.txt
src/plugins/gbp/CMakeLists.txt
src/plugins/gtpu/CMakeLists.txt
src/plugins/igmp/CMakeLists.txt
src/plugins/ila/CMakeLists.txt
src/plugins/ioam/CMakeLists.txt
src/plugins/ixge/CMakeLists.txt
src/plugins/l2e/CMakeLists.txt
src/plugins/lacp/CMakeLists.txt
src/plugins/lb/CMakeLists.txt
src/plugins/mactime/CMakeLists.txt
src/plugins/map/CMakeLists.txt
src/plugins/marvell/CMakeLists.txt
src/plugins/memif/CMakeLists.txt
src/plugins/nat/CMakeLists.txt
src/plugins/pppoe/CMakeLists.txt
src/plugins/srv6-ad/CMakeLists.txt
src/plugins/srv6-am/CMakeLists.txt
src/plugins/srv6-as/CMakeLists.txt
src/plugins/stn/CMakeLists.txt
src/plugins/tlsmbedtls/CMakeLists.txt
src/plugins/tlsopenssl/CMakeLists.txt
src/plugins/unittest/CMakeLists.txt

index 56cb6ef..8ea99c7 100644 (file)
@@ -16,19 +16,33 @@ include_directories (
   ${CMAKE_CURRENT_BINARY_DIR}
 )
 
-macro(add_vpp_plugin plugin_name)
+macro(add_vpp_plugin name)
+  cmake_parse_arguments(PLUGIN
+    ""
+    "LINK_FLAGS"
+    "SOURCES;API_FILES;MULTIARCH_SOURCES;LINK_LIBRARIES"
+    ${ARGN}
+  )
+  set(plugin_name ${name}_plugin)
   set(api_headers)
-  foreach(f ${ARGN})
-     if(${f} MATCHES ".*\.api$")
-       vpp_generate_api_header(${f} plugins)
-       list(APPEND api_headers ${f}.h ${f}.json)
-     endif()
+  foreach(f ${PLUGIN_API_FILES})
+     vpp_generate_api_header(${f} plugins)
+     list(APPEND api_headers ${f}.h ${f}.json)
   endforeach()
-  add_library(${plugin_name} SHARED ${ARGN} ${api_headers})
+  add_library(${plugin_name} SHARED ${PLUGIN_SOURCES} ${api_headers})
   add_dependencies(${plugin_name} vpp_version_h api_headers)
   set_target_properties(${plugin_name} PROPERTIES
     PREFIX ""
     LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/vpp_plugins)
+  if(PLUGIN_MULTIARCH_SOURCES)
+    vpp_library_set_multiarch_sources(${plugin_name} ${PLUGIN_MULTIARCH_SOURCES})
+  endif()
+  if(PLUGIN_LINK_LIBRARIES)
+    target_link_libraries(${plugin_name} ${PLUGIN_LINK_LIBRARIES})
+  endif()
+  if(PLUGIN_LINK_FLAGS)
+    set_target_properties(${plugin_name} PROPERTIES LINK_FLAGS "${PLUGIN_LINK_FLAGS}")
+  endif()
   install(TARGETS ${plugin_name} DESTINATION lib/vpp_plugins COMPONENT plugins)
 endmacro()
 
index 2bb90e2..5db9757 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(abf_plugin
-  abf.api
+add_vpp_plugin(abf
+  SOURCES
   abf_api.c
   abf_itf_attach.c
   abf_policy.c
+
+  API_FILES
+  abf.api
 )
index 2040522..1779c49 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(acl_plugin
-  acl.api
+add_vpp_plugin(acl
+  SOURCES
   acl.c
   hash_lookup.c
   lookup_context.c
   sess_mgmt_node.c
   dataplane_node.c
+
+  API_FILES
+  acl.api
 )
index 8f8798b..80f3b53 100644 (file)
@@ -11,7 +11,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(avf_plugin
+add_vpp_plugin(avf
+  SOURCES
   cli.c
   device.c
   format.c
@@ -19,10 +20,11 @@ add_vpp_plugin(avf_plugin
   output.c
   plugin.c
   avf_api.c
-  avf.api
-)
 
-vpp_library_set_multiarch_sources(avf_plugin
+  MULTIARCH_SOURCES
   input.c
   output.c
+
+  API_FILES
+  avf.api
 )
index 036833f..9f0b07e 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(cdp_plugin
-  cdp.api
+add_vpp_plugin(cdp
+  SOURCES
   cdp.c
   cdp_input.c
   cdp_node.c
   cdp_periodic.c
+
+  API_FILES
+  cdp.api
 )
 
-add_vpp_api_test_plugin(cdp_test_plugin
+add_vpp_api_test_plugin(cdp_test
   cdp.api
   cdp_test.c
 )
index 6640704..0b08b06 100644 (file)
@@ -81,7 +81,17 @@ endif()
 ##############################################################################
 if(DPDK_INCLUDE_DIR AND DPDK_LIB)
   include_directories (${DPDK_INCLUDE_DIR})
-  add_vpp_plugin(dpdk_plugin
+
+  message(STATUS "Found DPDK ${DPDK_VERSION} in ${DPDK_INCLUDE_DIR}")
+  get_filename_component(DPDK_LIB_DIR ${DPDK_LIB} DIRECTORY)
+  set(DPDK_LINK_FLAGS "-L${DPDK_LIB_DIR} -Wl,--whole-archive,${DPDK_LIB},--no-whole-archive")
+  if(DPDK_RTE_LIBRTE_PMD_AESNI_MB OR DPDK_RTE_LIBRTE_PMD_AESNI_GCM)
+    set(DPDK_LINK_FLAGS "${DPDK_LINK_FLAGS} -Wl,--exclude-libs,libIPSec_MB.a,-l:libIPSec_MB.a")
+    message(STATUS "DPDK depends on IPSec MB library")
+  endif()
+  set(DPDK_LINK_FLAGS "${DPDK_LINK_FLAGS} -Wl,-lnuma")
+  add_vpp_plugin(dpdk
+    SOURCES
     buffer.c
     main.c
     thread.c
@@ -100,25 +110,19 @@ if(DPDK_INCLUDE_DIR AND DPDK_LIB)
     ipsec/esp_decrypt.c
     ipsec/esp_encrypt.c
     ipsec/ipsec.c
-    api/dpdk.api
-  )
 
-  vpp_library_set_multiarch_sources(dpdk_plugin
+    MULTIARCH_SOURCES
     buffer.c
     device/device.c
     device/node.c
-  )
 
-  message(STATUS "Found DPDK ${DPDK_VERSION} in ${DPDK_INCLUDE_DIR}")
-  get_filename_component(DPDK_LIB_DIR ${DPDK_LIB} DIRECTORY)
-  set(DPDK_LINK_FLAGS "-L${DPDK_LIB_DIR} -Wl,--whole-archive,${DPDK_LIB},--no-whole-archive")
-  if(DPDK_RTE_LIBRTE_PMD_AESNI_MB OR DPDK_RTE_LIBRTE_PMD_AESNI_GCM)
-    set(DPDK_LINK_FLAGS "${DPDK_LINK_FLAGS} -Wl,--exclude-libs,libIPSec_MB.a,-l:libIPSec_MB.a")
-    message(STATUS "DPDK depends on IPSec MB library")
-  endif()
-  set(DPDK_LINK_FLAGS "${DPDK_LINK_FLAGS} -Wl,-lnuma")
-  set_target_properties(dpdk_plugin PROPERTIES LINK_FLAGS "${DPDK_LINK_FLAGS}")
+    API_FILES
+    api/dpdk.api
+
+    LINK_FLAGS
+    ${DPDK_LINK_FLAGS}
+  )
 else()
-  message(WARNING "DPDK not found - dpdk_plugin disabled")
+  message(WARNING "DPDK not found - dpdk disabled")
 endif()
 
index df803a8..f65fe45 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(flowprobe_plugin
-  flowprobe.api
+add_vpp_plugin(flowprobe
+  SOURCES
   flowprobe.c
   node.c
+
+  API_FILES
+  flowprobe.api
 )
 
-add_vpp_api_test_plugin(flowprobe_test_plugin
+add_vpp_api_test_plugin(flowprobe_test
   flowprobe.api
   flowprobe_test.c
 )
index a9e9bd6..738154a 100644 (file)
@@ -11,8 +11,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(gbp_plugin
-  gbp.api
+add_vpp_plugin(gbp
+  SOURCES
   gbp_subnet.c
   gbp_contract.c
   gbp_endpoint.c
@@ -24,4 +24,7 @@ add_vpp_plugin(gbp_plugin
   gbp_fwd.c
   gbp_fwd_dpo.c
   gbp_api.c
+
+  API_FILES
+  gbp.api
 )
index 1633d43..1032b14 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(gtpu_plugin
-  gtpu.api
+add_vpp_plugin(gtpu
+  SOURCES
   gtpu.c
   gtpu_api.c
   gtpu_decap.c
   gtpu_encap.c
+
+  API_FILES
+  gtpu.api
 )
 
-add_vpp_api_test_plugin(gtpu_test_plugin
+add_vpp_api_test_plugin(gtpu_test
   gtpu.api
   gtpu_test.c
 )
index a3f976c..8ed8c48 100644 (file)
@@ -11,8 +11,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(igmp_plugin
-  igmp.api
+add_vpp_plugin(igmp
+  SOURCES
   igmp.c
   igmp_query.c
   igmp_report.c
@@ -26,4 +26,7 @@ add_vpp_plugin(igmp_plugin
   igmp_pkt.c
   igmp_ssm_range.c
   igmp_format.c
+
+  API_FILES
+  igmp.api
 )
index 2aa1892..f03655b 100644 (file)
@@ -11,5 +11,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(ila_plugin ila.c)
+add_vpp_plugin(ila SOURCES ila.c)
 
index ed8bd19..5648a65 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(ioam_plugin
+add_vpp_plugin(ioam
+  SOURCES
   # iOAM Proof of Transit
-  lib-pot/pot.api
   lib-pot/pot_util.c
   encap/ip6_ioam_pot.c
   lib-pot/pot_api.c
 
   # iOAM trace export for IPv6
-  export/ioam_export.api
   export/ioam_export.c
   export/node.c
   export/ioam_export_thread.c
 
   # iOAM Trace
-  lib-trace/trace.api
   lib-trace/trace_util.c
   encap/ip6_ioam_trace.c
   lib-trace/trace_api.c
 
   # VxLAN-GPE
-  lib-vxlan-gpe/ioam_vxlan_gpe.api
   lib-vxlan-gpe/ioam_encap.c
   lib-vxlan-gpe/ioam_decap.c
   lib-vxlan-gpe/ioam_transit.c
@@ -39,7 +36,6 @@ add_vpp_plugin(ioam_plugin
   lib-vxlan-gpe/vxlan_gpe_api.c
   lib-vxlan-gpe/vxlan_gpe_ioam_trace.c
   lib-vxlan-gpe/vxlan_gpe_ioam.c
-  export-vxlan-gpe/vxlan_gpe_ioam_export.api
   export-vxlan-gpe/vxlan_gpe_ioam_export.c
   export-vxlan-gpe/vxlan_gpe_node.c
   export-vxlan-gpe/vxlan_gpe_ioam_export_thread.c
@@ -59,40 +55,47 @@ add_vpp_plugin(ioam_plugin
   analyse/ioam_summary_export.c
 
   # iOAM record cache and rewrite
-  ip6/ioam_cache.api
   ip6/ioam_cache.c
   ip6/ioam_cache_node.c
   ip6/ioam_cache_tunnel_select_node.c
 
   # udp ping
-  udp-ping/udp_ping.api
   udp-ping/udp_ping_node.c
   udp-ping/udp_ping_util.c
   udp-ping/udp_ping_export.c
   udp-ping/udp_ping_api.c
+
+  API_FILES
+  lib-pot/pot.api
+  export/ioam_export.api
+  lib-trace/trace.api
+  lib-vxlan-gpe/ioam_vxlan_gpe.api
+  export-vxlan-gpe/vxlan_gpe_ioam_export.api
+  ip6/ioam_cache.api
+  udp-ping/udp_ping.api
 )
 
-add_vpp_api_test_plugin(ioam_pot_test_plugin
+add_vpp_api_test_plugin(ioam_pot_test
   lib-pot/pot.api
   lib-pot/pot_test.c
 )
 
-add_vpp_api_test_plugin(ioam_export_test_plugin
+add_vpp_api_test_plugin(ioam_export_test
   export/ioam_export.api
   export/ioam_export_test.c
 )
 
-add_vpp_api_test_plugin(ioam_trace_test_plugin
+add_vpp_api_test_plugin(ioam_trace_test
   lib-trace/trace.api
   lib-trace/trace_test.c
 )
 
-add_vpp_api_test_plugin(ioam_vxlan_gpe_test_plugin
+add_vpp_api_test_plugin(ioam_vxlan_gpe_test
   lib-vxlan-gpe/ioam_vxlan_gpe.api
   lib-vxlan-gpe/vxlan_gpe_test.c
 )
 
-add_vpp_api_test_plugin(ioam_udp_ping_test_plugin
+add_vpp_api_test_plugin(ioam_udp_ping_test
   udp-ping/udp_ping.api
   udp-ping/udp_ping_test.c
 )
index bd3454d..14d101e 100644 (file)
@@ -11,6 +11,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(ixge_plugin
-  ixge.c
-)
+add_vpp_plugin(ixge SOURCES ixge.c)
index ba9cc6a..27d5659 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(l2e_plugin
-  l2e.api
+add_vpp_plugin(l2e
+  SOURCES
   l2e_api.c
   l2e.c
+
+  API_FILES
+  l2e.api
 )
index 0bd79e9..f6a30a7 100644 (file)
@@ -11,8 +11,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(lacp_plugin
-  lacp.api
+add_vpp_plugin(lacp
+  SOURCES
   lacp.c
   lacp_api.c
   selection.c
@@ -23,9 +23,12 @@ add_vpp_plugin(lacp_plugin
   cli.c
   input.c
   node.c
+
+  API_FILES
+  lacp.api
 )
 
-add_vpp_api_test_plugin(lacp_test_plugin
+add_vpp_api_test_plugin(lacp_test
   lacp.api
   lacp_test.c
 )
index 4df9dae..f9bca07 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(lb_plugin
-  lb.api
+add_vpp_plugin(lb
+  SOURCES
   api.c
   cli.c
   lb.c
   node.c
   util.c
+
+  API_FILES
+  lb.api
 )
 
-add_vpp_api_test_plugin(lb_test_plugin
+add_vpp_api_test_plugin(lb_test
   lb.api
   lb_test.c
 )
index 5f82f4c..f2986a9 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(mactime_plugin
-  mactime.api
+add_vpp_plugin(mactime
+  SOURCES
   mactime.c
   node.c
+
+  API_FILES
+  mactime.api
 )
 
-add_vpp_api_test_plugin(mactime_test_plugin
+add_vpp_api_test_plugin(mactime_test
   mactime.api
   mactime_test.c
 )
index 1dc1bed..a3e6e3d 100644 (file)
@@ -11,8 +11,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(map_plugin
-  map.api
+add_vpp_plugin(map
+  SOURCES
   ip4_map.c
   ip4_map_t.c
   ip6_map.c
@@ -20,4 +20,7 @@ add_vpp_plugin(map_plugin
   map_api.c
   map.c
   map_dpo.c
+
+  API_FILES
+  map.api
 )
index 8767a4f..39b7b85 100644 (file)
@@ -15,7 +15,7 @@ find_path(MUSDK_INCLUDE_DIR NAMES marvell/pp2/pp2.h)
 find_library(MUSDK_LIB NAMES musdk)
 
 if(MUSDK_INCLUDE_DIR AND MUSDK_LIB)
-  add_vpp_plugin(marvell_plugin
+  add_vpp_plugin(marvell
     marvell.api
     plugin.c
     pp2/cli.c
index 54d0bef..b225192 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(memif_plugin
-  memif.api
+add_vpp_plugin(memif
+  SOURCES
   memif.c
   memif_api.c
   cli.c
   node.c
   device.c
   socket.c
-)
 
-vpp_library_set_multiarch_sources(memif_plugin
+  API_FILES
+  memif.api
+
+  MULTIARCH_SOURCES
   device.c
   node.c
 )
index 931fa2c..1d0b641 100644 (file)
@@ -11,8 +11,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(nat_plugin
-  nat.api
+add_vpp_plugin(nat
+  SOURCES
   nat.c
   nat_api.c
   in2out.c
@@ -38,4 +38,7 @@ add_vpp_plugin(nat_plugin
   nat66_cli.c
   nat66_in2out.c
   nat66_out2in.c
+
+  API_FILES
+  nat.api
 )
index fca2102..9059968 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(pppoe_plugin
-  pppoe.api
+add_vpp_plugin(pppoe
+  SOURCES
   pppoe_api.c
   pppoe.c
   pppoe_cp.c
   pppoe_cp_node.c
   pppoe_decap.c
+
+  API_FILES
+  pppoe.api
 )
 
-add_vpp_api_test_plugin(pppoe_test_plugin
+add_vpp_api_test_plugin(pppoe_test
   pppoe.api
   pppoe_test.c
 )
index 29959a1..dc222bf 100644 (file)
@@ -11,7 +11,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(srv6ad_plugin
+add_vpp_plugin(srv6ad
+  SOURCES
   ad.c
   node.c
 )
index 995db98..650142f 100644 (file)
@@ -11,7 +11,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(srv6am_plugin
+add_vpp_plugin(srv6am
+  SOURCES
   am.c
   node.c
 )
index 42b23f3..3140c9d 100644 (file)
@@ -11,7 +11,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(srv6as_plugin
+add_vpp_plugin(srv6as
+  SOURCES
   as.c
   node.c
 )
index c29cf5f..d987176 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(stn_plugin
-  stn.api
+add_vpp_plugin(stn
+  SOURCES
   stn.c
   stn_api.c
+
+  API_FILES
+  stn.api
 )
 
-add_vpp_api_test_plugin(stn_test_plugin
+add_vpp_api_test_plugin(stn_test
   stn.api
   stn_test.c
 )
index 03f8a17..13fa12e 100644 (file)
@@ -21,8 +21,13 @@ set (MBEDTLS_LIB ${MBEDTLS_LIB1} ${MBEDTLS_LIB2} ${MBEDTLS_LIB3})
 
 if(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIB)
   include_directories(${MBEDTLS_INCLUDE_DIR})
-  add_vpp_plugin(tlsmbedtls_plugin tls_mbedtls.c)
-  target_link_libraries(tlsmbedtls_plugin ${MBEDTLS_LIB})
+  add_vpp_plugin(tlsmbedtls
+    SOURCES
+    tls_mbedtls.c
+
+    LINK_LIBRARIES
+    ${MBEDTLS_LIB}
+  )
   message(STATUS "Found mbedTLS in ${MBEDTLS_INCLUDE_DIR}")
 else()
   message(WARNING "-- mbedTLS not found - tlsmbedtls_plugin disabled")
index 7659cc0..fac27f5 100644 (file)
 # limitations under the License.
 
 if(OPENSSL_FOUND)
-  add_vpp_plugin(tlsopenssl_plugin tls_openssl.c tls_async.c)
-  target_link_libraries(tlsopenssl_plugin ${OPENSSL_LIBRARIES})
+  add_vpp_plugin(tlsopenssl
+    SOURCES
+    tls_openssl.c
+    tls_async.c
+
+    LINK_LIBRARIES
+    ${OPENSSL_LIBRARIES}
+  )
 endif()
 
index eba6e23..f790a23 100644 (file)
@@ -11,7 +11,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-add_vpp_plugin(unittest_plugin
+add_vpp_plugin(unittest
+  SOURCES
   unittest.c
   tcp_test.c
   bihash_test.c