bpf_trace_filter: plugin for BPF Trace Filtering
[vpp.git] / src / plugins / bpf_trace_filter / CMakeLists.txt
1 # Copyright (c) 2023 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 vpp_find_path(PCAP_INCLUDE_DIR NAMES pcap.h)
15 if (NOT PCAP_INCLUDE_DIR)
16   message(WARNING "libpcap headers not found - bpf_trace_filter plugin disabled")
17   return()
18 endif()
19
20 vpp_plugin_find_library(bpf_trace_filter PCAP_LIB libpcap.so)
21
22 if (NOT PCAP_LIB)
23   message(WARNING "bpf_trace_filter plugin - missing libraries - bpf_trace_filter plugin disabled")
24   return()
25 endif()
26
27 set(CMAKE_REQUIRED_FLAGS "-fPIC")
28 set(CMAKE_REQUIRED_INCLUDES "${PCAP_INCLUDE_DIR}")
29 set(CMAKE_REQUIRED_LIBRARIES "${PCAP_LIB}")
30
31 include_directories(${PCAP_INCLUDE_DIR})
32
33 add_vpp_plugin(bpf_trace_filter
34   SOURCES
35   cli.c
36   plugin.c
37   bpf_trace_filter.c
38   api.c
39
40   API_FILES
41   bpf_trace_filter.api
42
43   LINK_LIBRARIES
44   ${PCAP_LIB}
45 )