From a123c8525635e9283f00bdc213e63f3f7f4ca977 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 24 Oct 2019 17:35:26 +0800 Subject: [PATCH] cmake: enable Finddpdk to find DPDK to be built find_package(dpdk...) is used by seastar to find DPDK if Seastar_DPDK is enabled. but `build_dpdk()` only exposes `dpdk::dpdk`, and it does not set the variables like `dpdk_INCLUDE_DIRS` and `dpdk_LIBRARIES` when it gets called. so we need to adapt Finddpdk to query them from `dpdk::dpdk` target. Signed-off-by: Kefu Chai --- cmake/modules/Finddpdk.cmake | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/cmake/modules/Finddpdk.cmake b/cmake/modules/Finddpdk.cmake index fdb44ec61c7..751e1c4594d 100644 --- a/cmake/modules/Finddpdk.cmake +++ b/cmake/modules/Finddpdk.cmake @@ -12,7 +12,12 @@ if(PKG_CONFIG_FOUND) pkg_check_modules(dpdk QUIET libdpdk) endif() -if(NOT dpdk_INCLUDE_DIRS) +if(dpdk_INCLUDE_DIRS) + # good +elseif(TARGET dpdk::dpdk) + get_target_property(dpdk_INCLUDE_DIRS + dpdk::dpdk INTERFACE_INCLUDE_DIRECTORIES) +else() find_path(dpdk_config_INCLUDE_DIR rte_config.h HINTS ENV DPDK_DIR @@ -58,13 +63,18 @@ set(_dpdk_libs) set(dpdk_LIBRARIES) foreach(c ${components}) - find_library(DPDK_rte_${c}_LIBRARY rte_${c} - HINTS - ENV DPDK_DIR - ${dpdk_LIBRARY_DIRS} - PATH_SUFFIXES lib) + set(dpdk_lib dpdk::${c}) + if(TARGET ${dpdk_lib}) + get_target_property(DPDK_rte_${c}_LIBRARY + ${dpdk_lib} IMPORTED_LOCATION) + else() + find_library(DPDK_rte_${c}_LIBRARY rte_${c} + HINTS + ENV DPDK_DIR + ${dpdk_LIBRARY_DIRS} + PATH_SUFFIXES lib) + endif() if(DPDK_rte_${c}_LIBRARY) - set(dpdk_lib dpdk::${c}) if (NOT TARGET ${dpdk_lib}) add_library(${dpdk_lib} UNKNOWN IMPORTED) set_target_properties(${dpdk_lib} PROPERTIES -- 2.39.5