Skip to content

Commit

Permalink
Append SDE pkgconfig folders to PKG_CONFIG_PATH (#319)
Browse files Browse the repository at this point in the history
- Check for `pkgconfig` directories in the DPDK SDE and append them to
  PKG_CONFIG_PATH before using pkg-config to find the DPDK module.

- Address a CMake module warning by using `DpdkDriver` as the DPDK
  package name instead of `DPDK`.

- Correct an error in a DPDK LDFLAGS variable reference.

- Update krnlmon submodule reference.

Signed-off-by: Derek G Foster <[email protected]>
  • Loading branch information
ffoulkes authored Oct 24, 2023
1 parent d52c7e2 commit 98c0741
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
40 changes: 31 additions & 9 deletions cmake/FindDpdkDriver.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
# This module requires that SDE_INSTALL_DIR be defined.
# It needs additional work to make it a proper CMake find-module.

#-----------------------------------------------------------------------
# Use pkg-config to find DPDK module
#-----------------------------------------------------------------------
include(FindPkgConfig)
pkg_check_modules(DPDK REQUIRED libdpdk)

#-----------------------------------------------------------------------
# Define SDE_INCLUDE_DIR
#-----------------------------------------------------------------------
Expand Down Expand Up @@ -121,12 +115,40 @@ set_target_properties(sde::target_utils PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${SDE_INCLUDE_DIR}
IMPORTED_LINK_INTERFACE_LANGUAGES C)

#-----------------------------------------------------------------------
# Append SDE pkgconfig directories to PKG_CONFIG_PATH
#-----------------------------------------------------------------------
function(_set_pkg_config_path)
file(TO_CMAKE_PATH "$ENV{PKG_CONFIG_PATH}" _sde_pkg_path)

foreach(_libdir lib lib64 lib/x86_64-linux-gnu)
set(_path ${SDE_INSTALL_DIR}/${_libdir}/pkgconfig)
if(EXISTS ${_path})
list(APPEND _sde_pkg_path ${_path})
endif()
endforeach()

list(JOIN _sde_pkg_path ":" _sde_pkg_path)

if(NOT _sde_pkg_path STREQUAL "")
set(ENV{PKG_CONFIG_PATH} "${_sde_pkg_path}")
endif()
endfunction()

_set_pkg_config_path()

#-----------------------------------------------------------------------
# Use pkg-config to find DPDK module
#-----------------------------------------------------------------------
include(FindPkgConfig)
pkg_check_modules(DpdkDriver REQUIRED libdpdk)

#-----------------------------------------------------------------------
# Define SDE_LIBRARY_DIRS
#-----------------------------------------------------------------------
set(SDE_LIBRARY_DIRS
${SDE_INSTALL_DIR}/lib
${DPDK_LIBRARY_DIRS}
${DpdkDriver_LIBRARY_DIRS}
)

#-----------------------------------------------------------------------
Expand All @@ -145,7 +167,7 @@ function(add_dpdk_target_libraries TGT)
target_link_directories(${TGT} PUBLIC ${SDE_LIBRARY_DIRS})

target_link_options(${TGT} PUBLIC
${DPDK_LD_FLAGS}
${DPDK_LDFLAGS_OTHER}
${DpdkDriver_LDFLAGS}
${DpdkDriver_LDFLAGS_OTHER}
)
endfunction()

0 comments on commit 98c0741

Please sign in to comment.