Skip to content

Commit 70de71d

Browse files
ShawnZhonganakryiko
authored andcommitted
cmake: Allow additional header deps for bpf_object
Signed-off-by: Shawn Zhong <[email protected]>
1 parent 902b91d commit 70de71d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tools/cmake/FindBpfObject.cmake

+8-4
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,19 @@ as the associated dependencies.
4141
4242
.. code-block:: cmake
4343
44-
bpf_object(<name> <source>)
44+
bpf_object(<name> <source> [<header> ...])
4545
4646
Given an abstract ``<name>`` for a BPF object and the associated ``<source>``
4747
file, generates an interface library target, ``<name>_skel``, that may be
48-
linked against by other cmake targets.
48+
linked against by other cmake targets. Additional headers may be provided to
49+
the macro to ensure that the generated skeleton is up-to-date.
4950
5051
Example Usage:
5152
5253
::
5354
5455
find_package(BpfObject REQUIRED)
55-
bpf_object(myobject myobject.bpf.c)
56+
bpf_object(myobject myobject.bpf.c myobject.h)
5657
add_executable(myapp myapp.c)
5758
target_link_libraries(myapp myobject_skel)
5859
@@ -156,6 +157,9 @@ endif()
156157
# Public macro
157158
macro(bpf_object name input)
158159
set(BPF_C_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${input})
160+
foreach(arg ${ARGN})
161+
list(APPEND BPF_H_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
162+
endforeach()
159163
set(BPF_O_FILE ${CMAKE_CURRENT_BINARY_DIR}/${name}.bpf.o)
160164
set(BPF_SKEL_FILE ${CMAKE_CURRENT_BINARY_DIR}/${name}.skel.h)
161165
set(OUTPUT_TARGET ${name}_skel)
@@ -167,7 +171,7 @@ macro(bpf_object name input)
167171
-isystem ${LIBBPF_INCLUDE_DIRS} -c ${BPF_C_FILE} -o ${BPF_O_FILE}
168172
COMMAND_EXPAND_LISTS
169173
VERBATIM
170-
DEPENDS ${BPF_C_FILE}
174+
DEPENDS ${BPF_C_FILE} ${BPF_H_FILES}
171175
COMMENT "[clang] Building BPF object: ${name}")
172176

173177
# Build BPF skeleton header

0 commit comments

Comments
 (0)