Skip to content

Commit 20709bc

Browse files
ekoopspoiana
authored andcommitted
fix(cmake/modules): fix inclusion of system libelf headers
In case `USE_BUNDLED_LIBELF` is set to `OFF`, system libelf target exposes its headers through INTERFACE_INCLUDE_DIRECTORIES, not INCLUDE_DIRECTORIES. Take it into account. Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
1 parent b9fe19d commit 20709bc

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

cmake/modules/libbpf.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ else()
4242
set(LIBBPF_INCLUDE "${LIBBPF_BUILD_DIR}/root/usr/include")
4343
set(LIBBPF_LIB "${LIBBPF_BUILD_DIR}/root/usr/lib64/libbpf.a")
4444

45+
# The bundled libelf exposes its headers through INCLUDE_DIRECTORIES, while a system libelf is
46+
# an IMPORTED target that exposes them through INTERFACE_INCLUDE_DIRECTORIES; fall back to the
47+
# latter so libbpf can find <libelf.h>.
4548
get_target_property(LIBELF_INCLUDE_DIR elf INCLUDE_DIRECTORIES)
49+
if(NOT LIBELF_INCLUDE_DIR)
50+
get_target_property(LIBELF_INCLUDE_DIR elf INTERFACE_INCLUDE_DIRECTORIES)
51+
endif()
4652

4753
foreach(dir ${LIBELF_INCLUDE_DIR})
4854
string(APPEND LIBELF_COMPILER_STRING "-I${dir} ")

0 commit comments

Comments
 (0)