Configuring DPDK projects with CMake

I’ve recently started to look at and play around with DPDK and try to understand it all. Let’s just say that I’m far from understanding all of it yet, as most of my experience has been with the transport layer and up in the OSI stack. But one thing I do know is that getting some hands-on experience whilst learning new technologies is one of the best ways to get answers for all one’s questions and thesis on how the inner workings actually fit together. Of course looking at the source code of the technology being used will tell you it better, but with all the new terms being thrown at you, it’s good to just play around and get inspired instead of being overwhelmed and discouraged by the task of learning all the new concepts and namings.

So to start playing around I would like to use CMake as my build configuration tool and not Meson that DPDK is built with. Meson looks great, but I’m really comfortable with CMake as of now, and it also works great with CLion, which is my IDE of choice.

DPDK comes with support for pkg-config which I’ll be using to link my application with the DPDK SDK. This means that I’ve built and installed the DPDK libraries on my machine so that they are located in the usr/local.

Next is a template for CMake to link your application with the SDK. There are two options, shared or static linking.

CMake DPDK Template

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cmake_minimum_required(VERSION 3.20)
project(test_dpdk)

find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBDPDK REQUIRED libdpdk)

add_executable(test_dpdk main.cpp)

# Use the following for SHARED linking
target_compile_options(test_dpdk PRIVATE ${LIBDPDK_CFLAGS})
target_link_libraries(test_dpdk ${LIBDPDK_LDFLAGS})

# or use the following for STATIC linking
target_compile_options(test_dpdk PRIVATE ${LIBDPDK_STATIC_CFLAGS})
target_link_libraries(test_dpdk ${LIBDPDK_STATIC_LDFLAGS})

I hope this may become a handy simple template for you to start off your new DPDK projects.

Sign your Git commits Network interface management on Linux made easy with Netplan
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×