Skip to content

Commit

Permalink
dpdk: set DPDK compile and linker flags at libuhd toplevel
Browse files Browse the repository at this point in the history
Move all DPDK related settings to host/lib/CMakeLists.txt
  • Loading branch information
joergho committed Oct 2, 2024
1 parent 088cba2 commit f7f9fa6
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 37 deletions.
10 changes: 9 additions & 1 deletion host/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,17 @@ if(ENABLE_MPMD)
endif()
add_library(uhd SHARED ${libuhd_sources})
target_link_libraries(uhd ${Boost_LIBRARIES} ${libuhd_libs})
if(DPDK_FOUND)
if(ENABLE_DPDK)
add_definitions(-DHAVE_DPDK)
# The compile flags DPDK_CFLAGS add the DPDK_INCLUDE_DIRS include
# directories and set the -march=native compiler flag.
target_compile_options(uhd PRIVATE ${DPDK_CFLAGS})
# The linker flags DPDK_LDFLAGS contains the list of DPDK libraries
# as well as the path where to find the libraries
target_link_options(uhd PUBLIC ${DPDK_LDFLAGS})
# explicitly link against the DPDK libraries, otherwise there are
# undefined references when linking libuhd
target_link_libraries(uhd ${DPDK_LIBRARIES})
endif()
if(APPLE)
target_link_options(uhd PRIVATE "LINKER:-undefined,dynamic_lookup")
Expand Down
5 changes: 0 additions & 5 deletions host/lib/transport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,10 @@ endif(ENABLE_X300)

if(ENABLE_DPDK)
INCLUDE_SUBDIRECTORY(uhd-dpdk)
include_directories(${DPDK_INCLUDE_DIRS})

LIBUHD_APPEND_SOURCES(
${CMAKE_CURRENT_SOURCE_DIR}/udp_dpdk_link.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dpdk_simple.cpp
)
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/udp_dpdk_link.cpp
PROPERTIES COMPILE_FLAGS "${UHD_DPDK_CFLAGS} -D_GNU_SOURCE"
)
endif(ENABLE_DPDK)

14 changes: 0 additions & 14 deletions host/lib/transport/uhd-dpdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,11 @@
# Add the subdirectories
########################################################################
if(ENABLE_DPDK)
if(NOT DEFINED UHD_DPDK_CFLAGS)
message(STATUS "")
set(UHD_DPDK_CFLAGS "-march=native"
CACHE STRING "CFLAGS to use when building uhd-dpdk sources")
message(STATUS "DPDK: Using default UHD_DPDK_CFLAGS=" ${UHD_DPDK_CFLAGS})
endif(NOT DEFINED UHD_DPDK_CFLAGS)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})

LIBUHD_APPEND_SOURCES(
${CMAKE_CURRENT_SOURCE_DIR}/dpdk_common.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dpdk_io_service.cpp
)
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/dpdk_common.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dpdk_io_service.cpp
PROPERTIES COMPILE_FLAGS "${UHD_DPDK_CFLAGS} -D_GNU_SOURCE"
)
include_directories(${DPDK_INCLUDE_DIRS})
LIBUHD_APPEND_LIBS(${DPDK_LIBRARIES})
endif(ENABLE_DPDK)

1 change: 0 additions & 1 deletion host/lib/usrp/mpmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ if(ENABLE_MPMD)
endif(ENABLE_SIM)

if(ENABLE_DPDK)
include_directories(${DPDK_INCLUDE_DIRS})
set_property(
SOURCE
${CMAKE_CURRENT_SOURCE_DIR}/mpmd_link_if_ctrl_udp.cpp
Expand Down
5 changes: 0 additions & 5 deletions host/lib/usrp/x300/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,4 @@ if(ENABLE_X300)
${CMAKE_CURRENT_SOURCE_DIR}/x300_prop_tree.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cdecode.c
)

if(ENABLE_DPDK)
include_directories(${DPDK_INCLUDE_DIRS})
add_definitions(-DHAVE_DPDK)
endif(ENABLE_DPDK)
endif(ENABLE_X300)
5 changes: 0 additions & 5 deletions host/lib/usrp/x400/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,4 @@ if(ENABLE_X400)
${CMAKE_CURRENT_SOURCE_DIR}/x400_rfdc_control.cpp
${CMAKE_CURRENT_SOURCE_DIR}/x400_internal_sync.cpp
)

if(ENABLE_DPDK)
include_directories(${DPDK_INCLUDE_DIRS})
add_definitions(-DHAVE_DPDK)
endif(ENABLE_DPDK)
endif(ENABLE_X400)
8 changes: 2 additions & 6 deletions host/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,8 @@ if(ENABLE_DPDK)
EXTRA_LIBS ${DPDK_LIBRARIES}
NOAUTORUN # Don't register for auto-run, it requires special config
)
set_source_files_properties(
${UHD_SOURCE_DIR}/lib/transport/uhd-dpdk/dpdk_common.cpp
${UHD_SOURCE_DIR}/lib/transport/uhd-dpdk/dpdk_io_service.cpp
${UHD_SOURCE_DIR}/lib/transport/udp_dpdk_link.cpp
PROPERTIES COMPILE_FLAGS "-march=native -D_GNU_SOURCE"
)
target_compile_options(dpdk_test PRIVATE ${DPDK_CFLAGS})
target_compile_options(dpdk_port_test PRIVATE ${DPDK_CFLAGS})
ENDIF(ENABLE_DPDK)

UHD_ADD_NONAPI_TEST(
Expand Down

0 comments on commit f7f9fa6

Please sign in to comment.