Skip to content

Instantly share code, notes, and snippets.

@bkarl
Created December 13, 2021 22:03
Show Gist options
  • Save bkarl/2ddef8dbb29e1fbeae07fec55574a87c to your computer and use it in GitHub Desktop.
Save bkarl/2ddef8dbb29e1fbeae07fec55574a87c to your computer and use it in GitHub Desktop.
DPDK CMake template

Prequisites

Only works on systems with pkg-config (tested with Ubuntu). Requires cmake with FindPkgConfig (tested with v 3.18).

Install DPDK

Guide https://doc.dpdk.org/guides-20.05/linux_gsg/build_dpdk.html

Basic steps:

meson <options> build
cd build
ninja
ninja install
ldconfig

Tested with version 21.11.

CMakeLists.txt

Used to build the flow_filter example.

cmake_minimum_required(VERSION 3.18)

SET(PRJ flow_filter)
PROJECT(${PRJ})

FIND_PACKAGE(PkgConfig REQUIRED)
pkg_check_modules(DPDK REQUIRED libdpdk)

ADD_EXECUTABLE(${PRJ} main.c)
TARGET_LINK_LIBRARIES(${PRJ} ${DPDK_LIBRARIES})
target_compile_options(${PRJ} PUBLIC ${DPDK_CFLAGS}) 
TARGET_LINK_LIBRARIES(${PRJ} pthread dl rt m numa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment