xref: /aosp_15_r20/external/bcc/introspection/CMakeLists.txt (revision 387f9dfdfa2baef462e92476d413c7bc2470293e)
1# Copyright (c) Facebook, Inc.
2# Licensed under the Apache License, Version 2.0 (the "License")
3
4include_directories(${PROJECT_SOURCE_DIR}/src/cc)
5include_directories(${PROJECT_SOURCE_DIR}/src/cc/api)
6if (CMAKE_USE_LIBBPF_PACKAGE AND LIBBPF_FOUND)
7include_directories(${PROJECT_SOURCE_DIR}/src/cc/compat)
8else()
9include_directories(${PROJECT_SOURCE_DIR}/src/cc/libbpf/include/uapi)
10endif()
11
12option(INSTALL_INTROSPECTION "Install BPF introspection tools" ON)
13option(BPS_LINK_RT "Pass -lrt to linker when linking bps tool" ON)
14
15# Note that the order matters! bpf-static first, the rest later
16if(CMAKE_USE_LIBBPF_PACKAGE AND LIBBPF_FOUND)
17set(bps_libs_to_link bpf-shared ${LIBBPF_LIBRARIES})
18else()
19set(bps_libs_to_link bpf-static)
20endif()
21list(APPEND bps_libs_to_link elf z)
22if(BPS_LINK_RT)
23list(APPEND bps_libs_to_link rt)
24endif()
25
26add_executable(bps bps.c)
27target_link_libraries(bps ${bps_libs_to_link})
28
29install (TARGETS bps DESTINATION share/bcc/introspection)
30