cmake: improve add_vpp_plugin macro

Change-Id: Iffd5c45ab242a919592a1f686f7f880936b68a1a
Signed-off-by: Damjan Marion <damarion@cisco.com>
This commit is contained in:
Damjan Marion
2018-08-25 11:33:29 +02:00
parent 2bfdda76d8
commit 74449b8b68
29 changed files with 177 additions and 94 deletions

View File

@@ -16,19 +16,33 @@ include_directories (
${CMAKE_CURRENT_BINARY_DIR} ${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) set(api_headers)
foreach(f ${ARGN}) foreach(f ${PLUGIN_API_FILES})
if(${f} MATCHES ".*\.api$") vpp_generate_api_header(${f} plugins)
vpp_generate_api_header(${f} plugins) list(APPEND api_headers ${f}.h ${f}.json)
list(APPEND api_headers ${f}.h ${f}.json)
endif()
endforeach() 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) add_dependencies(${plugin_name} vpp_version_h api_headers)
set_target_properties(${plugin_name} PROPERTIES set_target_properties(${plugin_name} PROPERTIES
PREFIX "" PREFIX ""
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/vpp_plugins) 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) install(TARGETS ${plugin_name} DESTINATION lib/vpp_plugins COMPONENT plugins)
endmacro() endmacro()

View File

@@ -11,9 +11,12 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(abf_plugin add_vpp_plugin(abf
abf.api SOURCES
abf_api.c abf_api.c
abf_itf_attach.c abf_itf_attach.c
abf_policy.c abf_policy.c
API_FILES
abf.api
) )

View File

@@ -11,11 +11,14 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(acl_plugin add_vpp_plugin(acl
acl.api SOURCES
acl.c acl.c
hash_lookup.c hash_lookup.c
lookup_context.c lookup_context.c
sess_mgmt_node.c sess_mgmt_node.c
dataplane_node.c dataplane_node.c
API_FILES
acl.api
) )

View File

@@ -11,7 +11,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(avf_plugin add_vpp_plugin(avf
SOURCES
cli.c cli.c
device.c device.c
format.c format.c
@@ -19,10 +20,11 @@ add_vpp_plugin(avf_plugin
output.c output.c
plugin.c plugin.c
avf_api.c avf_api.c
avf.api
)
vpp_library_set_multiarch_sources(avf_plugin MULTIARCH_SOURCES
input.c input.c
output.c output.c
API_FILES
avf.api
) )

View File

@@ -11,15 +11,18 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(cdp_plugin add_vpp_plugin(cdp
cdp.api SOURCES
cdp.c cdp.c
cdp_input.c cdp_input.c
cdp_node.c cdp_node.c
cdp_periodic.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.api
cdp_test.c cdp_test.c
) )

View File

@@ -81,7 +81,17 @@ endif()
############################################################################## ##############################################################################
if(DPDK_INCLUDE_DIR AND DPDK_LIB) if(DPDK_INCLUDE_DIR AND DPDK_LIB)
include_directories (${DPDK_INCLUDE_DIR}) 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 buffer.c
main.c main.c
thread.c thread.c
@@ -100,25 +110,19 @@ if(DPDK_INCLUDE_DIR AND DPDK_LIB)
ipsec/esp_decrypt.c ipsec/esp_decrypt.c
ipsec/esp_encrypt.c ipsec/esp_encrypt.c
ipsec/ipsec.c ipsec/ipsec.c
api/dpdk.api
)
vpp_library_set_multiarch_sources(dpdk_plugin MULTIARCH_SOURCES
buffer.c buffer.c
device/device.c device/device.c
device/node.c device/node.c
)
message(STATUS "Found DPDK ${DPDK_VERSION} in ${DPDK_INCLUDE_DIR}") API_FILES
get_filename_component(DPDK_LIB_DIR ${DPDK_LIB} DIRECTORY) api/dpdk.api
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) LINK_FLAGS
set(DPDK_LINK_FLAGS "${DPDK_LINK_FLAGS} -Wl,--exclude-libs,libIPSec_MB.a,-l:libIPSec_MB.a") ${DPDK_LINK_FLAGS}
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}")
else() else()
message(WARNING "DPDK not found - dpdk_plugin disabled") message(WARNING "DPDK not found - dpdk disabled")
endif() endif()

View File

@@ -11,13 +11,16 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(flowprobe_plugin add_vpp_plugin(flowprobe
flowprobe.api SOURCES
flowprobe.c flowprobe.c
node.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.api
flowprobe_test.c flowprobe_test.c
) )

View File

@@ -11,8 +11,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(gbp_plugin add_vpp_plugin(gbp
gbp.api SOURCES
gbp_subnet.c gbp_subnet.c
gbp_contract.c gbp_contract.c
gbp_endpoint.c gbp_endpoint.c
@@ -24,4 +24,7 @@ add_vpp_plugin(gbp_plugin
gbp_fwd.c gbp_fwd.c
gbp_fwd_dpo.c gbp_fwd_dpo.c
gbp_api.c gbp_api.c
API_FILES
gbp.api
) )

View File

@@ -11,15 +11,18 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(gtpu_plugin add_vpp_plugin(gtpu
gtpu.api SOURCES
gtpu.c gtpu.c
gtpu_api.c gtpu_api.c
gtpu_decap.c gtpu_decap.c
gtpu_encap.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.api
gtpu_test.c gtpu_test.c
) )

View File

@@ -11,8 +11,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(igmp_plugin add_vpp_plugin(igmp
igmp.api SOURCES
igmp.c igmp.c
igmp_query.c igmp_query.c
igmp_report.c igmp_report.c
@@ -26,4 +26,7 @@ add_vpp_plugin(igmp_plugin
igmp_pkt.c igmp_pkt.c
igmp_ssm_range.c igmp_ssm_range.c
igmp_format.c igmp_format.c
API_FILES
igmp.api
) )

View File

@@ -11,5 +11,5 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(ila_plugin ila.c) add_vpp_plugin(ila SOURCES ila.c)

View File

@@ -11,27 +11,24 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(ioam_plugin add_vpp_plugin(ioam
SOURCES
# iOAM Proof of Transit # iOAM Proof of Transit
lib-pot/pot.api
lib-pot/pot_util.c lib-pot/pot_util.c
encap/ip6_ioam_pot.c encap/ip6_ioam_pot.c
lib-pot/pot_api.c lib-pot/pot_api.c
# iOAM trace export for IPv6 # iOAM trace export for IPv6
export/ioam_export.api
export/ioam_export.c export/ioam_export.c
export/node.c export/node.c
export/ioam_export_thread.c export/ioam_export_thread.c
# iOAM Trace # iOAM Trace
lib-trace/trace.api
lib-trace/trace_util.c lib-trace/trace_util.c
encap/ip6_ioam_trace.c encap/ip6_ioam_trace.c
lib-trace/trace_api.c lib-trace/trace_api.c
# VxLAN-GPE # VxLAN-GPE
lib-vxlan-gpe/ioam_vxlan_gpe.api
lib-vxlan-gpe/ioam_encap.c lib-vxlan-gpe/ioam_encap.c
lib-vxlan-gpe/ioam_decap.c lib-vxlan-gpe/ioam_decap.c
lib-vxlan-gpe/ioam_transit.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_api.c
lib-vxlan-gpe/vxlan_gpe_ioam_trace.c lib-vxlan-gpe/vxlan_gpe_ioam_trace.c
lib-vxlan-gpe/vxlan_gpe_ioam.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_ioam_export.c
export-vxlan-gpe/vxlan_gpe_node.c export-vxlan-gpe/vxlan_gpe_node.c
export-vxlan-gpe/vxlan_gpe_ioam_export_thread.c export-vxlan-gpe/vxlan_gpe_ioam_export_thread.c
@@ -59,40 +55,47 @@ add_vpp_plugin(ioam_plugin
analyse/ioam_summary_export.c analyse/ioam_summary_export.c
# iOAM record cache and rewrite # iOAM record cache and rewrite
ip6/ioam_cache.api
ip6/ioam_cache.c ip6/ioam_cache.c
ip6/ioam_cache_node.c ip6/ioam_cache_node.c
ip6/ioam_cache_tunnel_select_node.c ip6/ioam_cache_tunnel_select_node.c
# udp ping # udp ping
udp-ping/udp_ping.api
udp-ping/udp_ping_node.c udp-ping/udp_ping_node.c
udp-ping/udp_ping_util.c udp-ping/udp_ping_util.c
udp-ping/udp_ping_export.c udp-ping/udp_ping_export.c
udp-ping/udp_ping_api.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.api
lib-pot/pot_test.c 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.api
export/ioam_export_test.c 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.api
lib-trace/trace_test.c 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/ioam_vxlan_gpe.api
lib-vxlan-gpe/vxlan_gpe_test.c 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.api
udp-ping/udp_ping_test.c udp-ping/udp_ping_test.c
) )

View File

@@ -11,6 +11,4 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(ixge_plugin add_vpp_plugin(ixge SOURCES ixge.c)
ixge.c
)

View File

@@ -11,8 +11,11 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(l2e_plugin add_vpp_plugin(l2e
l2e.api SOURCES
l2e_api.c l2e_api.c
l2e.c l2e.c
API_FILES
l2e.api
) )

View File

@@ -11,8 +11,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(lacp_plugin add_vpp_plugin(lacp
lacp.api SOURCES
lacp.c lacp.c
lacp_api.c lacp_api.c
selection.c selection.c
@@ -23,9 +23,12 @@ add_vpp_plugin(lacp_plugin
cli.c cli.c
input.c input.c
node.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.api
lacp_test.c lacp_test.c
) )

View File

@@ -11,16 +11,19 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(lb_plugin add_vpp_plugin(lb
lb.api SOURCES
api.c api.c
cli.c cli.c
lb.c lb.c
node.c node.c
util.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.api
lb_test.c lb_test.c
) )

View File

@@ -11,13 +11,16 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(mactime_plugin add_vpp_plugin(mactime
mactime.api SOURCES
mactime.c mactime.c
node.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.api
mactime_test.c mactime_test.c
) )

View File

@@ -11,8 +11,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(map_plugin add_vpp_plugin(map
map.api SOURCES
ip4_map.c ip4_map.c
ip4_map_t.c ip4_map_t.c
ip6_map.c ip6_map.c
@@ -20,4 +20,7 @@ add_vpp_plugin(map_plugin
map_api.c map_api.c
map.c map.c
map_dpo.c map_dpo.c
API_FILES
map.api
) )

View File

@@ -15,7 +15,7 @@ find_path(MUSDK_INCLUDE_DIR NAMES marvell/pp2/pp2.h)
find_library(MUSDK_LIB NAMES musdk) find_library(MUSDK_LIB NAMES musdk)
if(MUSDK_INCLUDE_DIR AND MUSDK_LIB) if(MUSDK_INCLUDE_DIR AND MUSDK_LIB)
add_vpp_plugin(marvell_plugin add_vpp_plugin(marvell
marvell.api marvell.api
plugin.c plugin.c
pp2/cli.c pp2/cli.c

View File

@@ -11,17 +11,19 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(memif_plugin add_vpp_plugin(memif
memif.api SOURCES
memif.c memif.c
memif_api.c memif_api.c
cli.c cli.c
node.c node.c
device.c device.c
socket.c socket.c
)
vpp_library_set_multiarch_sources(memif_plugin API_FILES
memif.api
MULTIARCH_SOURCES
device.c device.c
node.c node.c
) )

View File

@@ -11,8 +11,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(nat_plugin add_vpp_plugin(nat
nat.api SOURCES
nat.c nat.c
nat_api.c nat_api.c
in2out.c in2out.c
@@ -38,4 +38,7 @@ add_vpp_plugin(nat_plugin
nat66_cli.c nat66_cli.c
nat66_in2out.c nat66_in2out.c
nat66_out2in.c nat66_out2in.c
API_FILES
nat.api
) )

View File

@@ -11,16 +11,19 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(pppoe_plugin add_vpp_plugin(pppoe
pppoe.api SOURCES
pppoe_api.c pppoe_api.c
pppoe.c pppoe.c
pppoe_cp.c pppoe_cp.c
pppoe_cp_node.c pppoe_cp_node.c
pppoe_decap.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.api
pppoe_test.c pppoe_test.c
) )

View File

@@ -11,7 +11,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(srv6ad_plugin add_vpp_plugin(srv6ad
SOURCES
ad.c ad.c
node.c node.c
) )

View File

@@ -11,7 +11,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(srv6am_plugin add_vpp_plugin(srv6am
SOURCES
am.c am.c
node.c node.c
) )

View File

@@ -11,7 +11,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(srv6as_plugin add_vpp_plugin(srv6as
SOURCES
as.c as.c
node.c node.c
) )

View File

@@ -11,13 +11,16 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(stn_plugin add_vpp_plugin(stn
stn.api SOURCES
stn.c stn.c
stn_api.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.api
stn_test.c stn_test.c
) )

View File

@@ -21,8 +21,13 @@ set (MBEDTLS_LIB ${MBEDTLS_LIB1} ${MBEDTLS_LIB2} ${MBEDTLS_LIB3})
if(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIB) if(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIB)
include_directories(${MBEDTLS_INCLUDE_DIR}) include_directories(${MBEDTLS_INCLUDE_DIR})
add_vpp_plugin(tlsmbedtls_plugin tls_mbedtls.c) add_vpp_plugin(tlsmbedtls
target_link_libraries(tlsmbedtls_plugin ${MBEDTLS_LIB}) SOURCES
tls_mbedtls.c
LINK_LIBRARIES
${MBEDTLS_LIB}
)
message(STATUS "Found mbedTLS in ${MBEDTLS_INCLUDE_DIR}") message(STATUS "Found mbedTLS in ${MBEDTLS_INCLUDE_DIR}")
else() else()
message(WARNING "-- mbedTLS not found - tlsmbedtls_plugin disabled") message(WARNING "-- mbedTLS not found - tlsmbedtls_plugin disabled")

View File

@@ -12,7 +12,13 @@
# limitations under the License. # limitations under the License.
if(OPENSSL_FOUND) if(OPENSSL_FOUND)
add_vpp_plugin(tlsopenssl_plugin tls_openssl.c tls_async.c) add_vpp_plugin(tlsopenssl
target_link_libraries(tlsopenssl_plugin ${OPENSSL_LIBRARIES}) SOURCES
tls_openssl.c
tls_async.c
LINK_LIBRARIES
${OPENSSL_LIBRARIES}
)
endif() endif()

View File

@@ -11,7 +11,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
add_vpp_plugin(unittest_plugin add_vpp_plugin(unittest
SOURCES
unittest.c unittest.c
tcp_test.c tcp_test.c
bihash_test.c bihash_test.c