2016-08-02 15:50:13 +00:00
|
|
|
# Try to find dpdk
|
2016-02-03 10:31:45 +00:00
|
|
|
#
|
|
|
|
# Once done, this will define
|
|
|
|
#
|
2018-08-17 04:27:49 +00:00
|
|
|
# dpdk_FOUND
|
|
|
|
# dpdk_INCLUDE_DIR
|
|
|
|
# dpdk_LIBRARIES
|
2016-02-03 10:31:45 +00:00
|
|
|
|
2018-08-17 04:27:49 +00:00
|
|
|
find_package(PkgConfig QUIET)
|
|
|
|
if(PKG_CONFIG_FOUND)
|
2018-08-20 14:11:02 +00:00
|
|
|
pkg_check_modules(dpdk QUIET libdpdk)
|
2018-08-17 04:27:49 +00:00
|
|
|
endif()
|
|
|
|
|
2018-08-20 14:11:02 +00:00
|
|
|
if(NOT dpdk_INCLUDE_DIRS)
|
|
|
|
find_path(dpdk_config_INCLUDE_DIR rte_config.h
|
|
|
|
HINTS
|
|
|
|
ENV DPDK_DIR
|
|
|
|
PATH_SUFFIXES
|
|
|
|
dpdk
|
|
|
|
include)
|
|
|
|
find_path(dpdk_common_INCLUDE_DIR rte_common.h
|
|
|
|
HINTS
|
|
|
|
ENC DPDK_DIR
|
|
|
|
PATH_SUFFIXES
|
|
|
|
dpdk
|
|
|
|
include)
|
|
|
|
set(dpdk_INCLUDE_DIRS "${dpdk_config_INCLUDE_DIR}")
|
|
|
|
if(NOT dpdk_config_INCLUDE_DIR EQUAL dpdk_common_INCLUDE_DIR)
|
|
|
|
list(APPEND dpdk_INCLUDE_DIRS "${dpdk_common_INCLUDE_DIR}")
|
|
|
|
endif()
|
|
|
|
endif()
|
2016-08-02 15:50:13 +00:00
|
|
|
|
2017-01-10 07:14:01 +00:00
|
|
|
set(components
|
2018-08-17 04:27:49 +00:00
|
|
|
bus_pci
|
|
|
|
cmdline
|
|
|
|
eal
|
|
|
|
ethdev
|
|
|
|
hash
|
|
|
|
kvargs
|
|
|
|
mbuf
|
|
|
|
mempool
|
|
|
|
mempool_ring
|
|
|
|
mempool_stack
|
|
|
|
pci
|
|
|
|
pmd_af_packet
|
|
|
|
pmd_bond
|
|
|
|
pmd_i40e
|
|
|
|
pmd_ixgbe
|
|
|
|
pmd_mlx5
|
|
|
|
pmd_ring
|
|
|
|
pmd_vmxnet3_uio
|
2017-01-10 07:14:01 +00:00
|
|
|
ring)
|
2016-02-03 10:31:45 +00:00
|
|
|
|
2018-08-17 04:27:49 +00:00
|
|
|
set(dpdk_LIBRARIES)
|
|
|
|
|
2017-01-10 07:14:01 +00:00
|
|
|
foreach(c ${components})
|
|
|
|
find_library(DPDK_rte_${c}_LIBRARY rte_${c}
|
2018-08-17 04:27:49 +00:00
|
|
|
HINTS
|
|
|
|
ENV DPDK_DIR
|
2018-08-20 14:11:02 +00:00
|
|
|
${dpdk_LIBRARY_DIRS}
|
2018-08-17 04:27:49 +00:00
|
|
|
PATH_SUFFIXES lib)
|
2018-07-20 10:50:07 +00:00
|
|
|
if(DPDK_rte_${c}_LIBRARY)
|
2018-08-17 04:27:49 +00:00
|
|
|
set(dpdk_lib dpdk::${c})
|
|
|
|
if (NOT TARGET ${dpdk_lib})
|
|
|
|
add_library(${dpdk_lib} UNKNOWN IMPORTED)
|
|
|
|
set_target_properties(${dpdk_lib} PROPERTIES
|
2018-08-20 14:11:02 +00:00
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${dpdk_INCLUDE_DIRS}"
|
2018-08-17 04:27:49 +00:00
|
|
|
IMPORTED_LOCATION "${DPDK_rte_${c}_LIBRARY}")
|
|
|
|
if(c STREQUAL pmd_mlx5)
|
|
|
|
find_package(verbs QUIET)
|
|
|
|
if(verbs_FOUND)
|
|
|
|
target_link_libraries(${dpdk_lib} INTERFACE IBVerbs::verbs)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
list(APPEND dpdk_LIBRARIES ${dpdk_lib})
|
2018-07-20 10:50:07 +00:00
|
|
|
endif()
|
2017-01-10 07:14:01 +00:00
|
|
|
endforeach()
|
|
|
|
|
2018-08-20 14:11:02 +00:00
|
|
|
mark_as_advanced(dpdk_INCLUDE_DIRS ${dpdk_LIBRARIES})
|
2016-02-03 10:31:45 +00:00
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args(dpdk DEFAULT_MSG
|
2018-08-20 14:11:02 +00:00
|
|
|
dpdk_INCLUDE_DIRS
|
2018-08-17 04:27:49 +00:00
|
|
|
dpdk_LIBRARIES)
|
2016-02-03 10:31:45 +00:00
|
|
|
|
2018-08-17 04:27:49 +00:00
|
|
|
if(dpdk_FOUND)
|
2018-08-20 14:11:02 +00:00
|
|
|
if(NOT TARGET dpdk::cflags)
|
|
|
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64")
|
|
|
|
set(rte_cflags "-march=core2")
|
|
|
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|ARM")
|
|
|
|
set(rte_cflags "-march=armv7-a")
|
|
|
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64")
|
|
|
|
set(rte_cflags "-march=armv8-a+crc")
|
|
|
|
endif()
|
|
|
|
add_library(dpdk::cflags INTERFACE IMPORTED)
|
|
|
|
if (rte_cflags)
|
|
|
|
set_target_properties(dpdk::cflags PROPERTIES
|
|
|
|
INTERFACE_COMPILE_OPTIONS "${rte_cflags}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-08-17 04:27:49 +00:00
|
|
|
if(NOT TARGET dpdk::dpdk)
|
|
|
|
add_library(dpdk::dpdk INTERFACE IMPORTED)
|
|
|
|
find_package(Threads QUIET)
|
2018-08-20 14:11:02 +00:00
|
|
|
list(APPEND dpdk_LIBRARIES
|
|
|
|
Threads::Threads
|
|
|
|
dpdk::cflags)
|
2018-08-17 04:27:49 +00:00
|
|
|
set_target_properties(dpdk::dpdk PROPERTIES
|
2018-08-20 14:11:02 +00:00
|
|
|
INTERFACE_LINK_LIBRARIES "${dpdk_LIBRARIES}"
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${dpdk_INCLUDE_DIRS}")
|
2017-01-10 07:14:01 +00:00
|
|
|
endif()
|
2018-08-17 04:27:49 +00:00
|
|
|
endif()
|