@@ -41,18 +41,19 @@ as the associated dependencies.
41
41
42
42
.. code-block:: cmake
43
43
44
- bpf_object(<name> <source>)
44
+ bpf_object(<name> <source> [<header> ...] )
45
45
46
46
Given an abstract ``<name>`` for a BPF object and the associated ``<source>``
47
47
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.
49
50
50
51
Example Usage:
51
52
52
53
::
53
54
54
55
find_package(BpfObject REQUIRED)
55
- bpf_object(myobject myobject.bpf.c)
56
+ bpf_object(myobject myobject.bpf.c myobject.h )
56
57
add_executable(myapp myapp.c)
57
58
target_link_libraries(myapp myobject_skel)
58
59
@@ -156,6 +157,9 @@ endif()
156
157
# Public macro
157
158
macro (bpf_object name input )
158
159
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 ()
159
163
set (BPF_O_FILE ${CMAKE_CURRENT_BINARY_DIR} /${name} .bpf.o)
160
164
set (BPF_SKEL_FILE ${CMAKE_CURRENT_BINARY_DIR} /${name} .skel.h)
161
165
set (OUTPUT_TARGET ${name} _skel)
@@ -167,7 +171,7 @@ macro(bpf_object name input)
167
171
-isystem ${LIBBPF_INCLUDE_DIRS} -c ${BPF_C_FILE} -o ${BPF_O_FILE}
168
172
COMMAND_EXPAND_LISTS
169
173
VERBATIM
170
- DEPENDS ${BPF_C_FILE}
174
+ DEPENDS ${BPF_C_FILE} ${BPF_H_FILES}
171
175
COMMENT "[clang] Building BPF object: ${name} " )
172
176
173
177
# Build BPF skeleton header
0 commit comments