Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append SDE pkgconfig folders to PKG_CONFIG_PATH #319

Merged
merged 6 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()