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}
)
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()

View File

@ -11,9 +11,12 @@
# 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
)

View File

@ -11,11 +11,14 @@
# 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
)

View 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
)

View File

@ -11,15 +11,18 @@
# 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
)

View 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()

View File

@ -11,13 +11,16 @@
# 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
)

View 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
)

View File

@ -11,15 +11,18 @@
# 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
)

View 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
)

View 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)

View File

@ -11,27 +11,24 @@
# 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
)

View 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)

View File

@ -11,8 +11,11 @@
# 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
)

View 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
)

View File

@ -11,16 +11,19 @@
# 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
)

View File

@ -11,13 +11,16 @@
# 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
)

View 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
)

View 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

View File

@ -11,17 +11,19 @@
# 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
)

View 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
)

View File

@ -11,16 +11,19 @@
# 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
)

View 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
)

View 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
)

View 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
)

View File

@ -11,13 +11,16 @@
# 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
)

View 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")

View File

@ -12,7 +12,13 @@
# 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()

View 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