Skip to content

Commit

Permalink
New optional parameter HINTS_DIRS added to CHECK_DEPENDECIES
Browse files Browse the repository at this point in the history
- Intially the HINTS variable for find_libraries was hard coded.
- The path may change for different Operating Systems.
- The HINTS parameter can now be populated by the caller, and will only be used if provided.
- Minor Typos are also fixed.

Signed-off-by: Parth Shitole <[email protected]>
  • Loading branch information
ParthShitole committed Oct 24, 2024
1 parent 6019ef7 commit 038dd22
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backends/ebpf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ if(TEST_DEPENDENCY_PRESENT)
# We do not have support for dynamic addition of tables in the test framework
p4c_add_test_with_args("ebpf" ${EBPF_DRIVER_TEST} TRUE "testdata/p4_16_samples/ebpf_conntrack_extern.p4" "testdata/p4_16_samples/ebpf_conntrack_extern.p4" "--extern-file ${P4C_SOURCE_DIR}/testdata/extern_modules/extern-conntrack-ebpf.c" "")
else()
message(WARNING "Skipped adding Tests due to missing dependencies" "Please install the dependencies and try again")
message(WARNING "Skipped adding Tests due to missing dependencies" " Please install the dependencies and try again")
endif()

message(STATUS "Done with configuring BPF back end")
14 changes: 12 additions & 2 deletions cmake/P4CUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,11 @@ function(get_all_targets _result _dir)
set(${_result} ${${_result}} ${_sub_targets} PARENT_SCOPE)
endfunction()

# Checks for presence of programs and dependencies
# Checks for presence of programs and dependencies
# This function supports a optional parameter HINTS_DIRS.
# In case cmake is unable to find a library even if it is present,
# you can pass the exact directory path as the last parameter of this function.
# Eg. CHECK_DEPENDENCIES(VAR "${TEST_PROGRAMS}" "${TEST_LIBRARIES}" "${HINTS_DIRS}")
function(CHECK_DEPENDENCIES OUT_VAR TEST_DEPENDENCY_PROGRAMS TEST_DEPENDENCY_LIBRARIES)
set(ALL_FOUND TRUE)

Expand All @@ -437,7 +441,13 @@ function(CHECK_DEPENDENCIES OUT_VAR TEST_DEPENDENCY_PROGRAMS TEST_DEPENDENCY_LIB
endforeach()

foreach(LIB ${TEST_DEPENDENCY_LIBRARIES})
find_library(LIB_PATH ${LIB} HINTS "${CMAKE_CURRENT_SOURCE_DIR}/runtime/usr/lib64/")
if (ARGC GREATER 3)
set(HINTS_DIRS_ARG ${ARGV4})
find_library(LIB_PATH ${LIB} HINTS ${HINTS_DIRS})
else()
find_library(LIB_PATH ${LIB})
endif()

if (NOT LIB_PATH)
message(WARNING "Missing library ${LIB}."
" Please install ${LIB}.")
Expand Down

0 comments on commit 038dd22

Please sign in to comment.