xref: /aosp_15_r20/external/bcc/examples/cpp/CMakeLists.txt (revision 387f9dfdfa2baef462e92476d413c7bc2470293e)
1*387f9dfdSAndroid Build Coastguard Worker# Copyright (c) Facebook, Inc.
2*387f9dfdSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License")
3*387f9dfdSAndroid Build Coastguard Worker
4*387f9dfdSAndroid Build Coastguard Workerinclude_directories(${PROJECT_BINARY_DIR}/src/cc)
5*387f9dfdSAndroid Build Coastguard Workerinclude_directories(${PROJECT_SOURCE_DIR}/src/cc)
6*387f9dfdSAndroid Build Coastguard Workerinclude_directories(${PROJECT_SOURCE_DIR}/src/cc/api)
7*387f9dfdSAndroid Build Coastguard Workerinclude_directories(${LLVM_INCLUDE_DIRS})
8*387f9dfdSAndroid Build Coastguard Worker
9*387f9dfdSAndroid Build Coastguard Workerif (CMAKE_USE_LIBBPF_PACKAGE AND LIBBPF_FOUND)
10*387f9dfdSAndroid Build Coastguard Workerinclude_directories(${PROJECT_SOURCE_DIR}/src/cc/compat)
11*387f9dfdSAndroid Build Coastguard Workerelse()
12*387f9dfdSAndroid Build Coastguard Workerinclude_directories(${PROJECT_SOURCE_DIR}/src/cc/libbpf/include/uapi)
13*387f9dfdSAndroid Build Coastguard Workerendif()
14*387f9dfdSAndroid Build Coastguard Worker
15*387f9dfdSAndroid Build Coastguard Workerset(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
16*387f9dfdSAndroid Build Coastguard Workerset(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
17*387f9dfdSAndroid Build Coastguard Worker
18*387f9dfdSAndroid Build Coastguard Workeroption(INSTALL_CPP_EXAMPLES "Install C++ examples. Those binaries are statically linked and can take plenty of disk space" OFF)
19*387f9dfdSAndroid Build Coastguard Worker
20*387f9dfdSAndroid Build Coastguard Workerfile(GLOB EXAMPLES *.cc)
21*387f9dfdSAndroid Build Coastguard Workerforeach(EXAMPLE ${EXAMPLES})
22*387f9dfdSAndroid Build Coastguard Worker  get_filename_component(NAME ${EXAMPLE} NAME_WE)
23*387f9dfdSAndroid Build Coastguard Worker  add_executable(${NAME} ${EXAMPLE})
24*387f9dfdSAndroid Build Coastguard Worker
25*387f9dfdSAndroid Build Coastguard Worker  if(NOT CMAKE_USE_LIBBPF_PACKAGE)
26*387f9dfdSAndroid Build Coastguard Worker    target_link_libraries(${NAME} bcc-static)
27*387f9dfdSAndroid Build Coastguard Worker  else()
28*387f9dfdSAndroid Build Coastguard Worker    target_link_libraries(${NAME} bcc-shared)
29*387f9dfdSAndroid Build Coastguard Worker  endif()
30*387f9dfdSAndroid Build Coastguard Worker
31*387f9dfdSAndroid Build Coastguard Worker  if(INSTALL_CPP_EXAMPLES)
32*387f9dfdSAndroid Build Coastguard Worker    install (TARGETS ${NAME} DESTINATION share/bcc/examples/cpp)
33*387f9dfdSAndroid Build Coastguard Worker  endif(INSTALL_CPP_EXAMPLES)
34*387f9dfdSAndroid Build Coastguard Workerendforeach()
35*387f9dfdSAndroid Build Coastguard Worker
36*387f9dfdSAndroid Build Coastguard Workeradd_subdirectory(pyperf)
37