add cmake option: build_execsnoop_dl, build_static

This commit is contained in:
Fancy Zhang
2020-07-05 16:57:00 +08:00
parent f5dc84e34a
commit 5398740bf3
7 changed files with 43 additions and 51 deletions

View File

@@ -1,9 +1,19 @@
# find libbpf
find_library(LIBBPF bpf)
if (build_static)
find_library(LIBBPF libbpf.a)
else()
find_library(LIBBPF bpf)
endif()
if (LIBBPF-NOTFOUND)
message(FATAL_ERROR "libbpf not found")
endif()
add_library(execsnoop MODULE execsnoop_share.cpp)
target_link_libraries(execsnoop PRIVATE bpf)
install(TARGETS execsnoop DESTINATION ${CMAKE_INSTALL_LIBDIR}/cgproxy/)
if (build_execsnoop_dl)
add_library(execsnoop MODULE execsnoop_share.cpp)
install(TARGETS execsnoop DESTINATION ${CMAKE_INSTALL_LIBDIR}/cgproxy/)
else()
add_library(execsnoop execsnoop_share.cpp)
endif()
target_link_libraries(execsnoop PRIVATE ${LIBBPF} -lelf -lz)

View File

@@ -10,9 +10,11 @@ namespace CGPROXY::EXECSNOOP {
extern "C" void startThread(function<int(int)> c, promise<void> _status);
#ifdef BUIlD_EXECSNOOP_DL
// only for dlsym()
using startThread_t=decltype(startThread);
startThread_t *_startThread;
#endif
} // namespace CGPROXY::EXECSNOOP
#endif