diff --git a/execsnoop-kernel/CMakeLists.txt b/execsnoop-kernel/CMakeLists.txt index 7cef479..ee4a6cc 100644 --- a/execsnoop-kernel/CMakeLists.txt +++ b/execsnoop-kernel/CMakeLists.txt @@ -12,8 +12,8 @@ endif() if (build_execsnoop_dl) add_library(execsnoop MODULE execsnoop_share.cpp) install(TARGETS execsnoop DESTINATION ${CMAKE_INSTALL_LIBDIR}/cgproxy/) + target_link_libraries(execsnoop PRIVATE ${LIBBPF} -lelf -lz) else() - add_library(execsnoop execsnoop_share.cpp) + add_library(execsnoop STATIC execsnoop_share.cpp) + target_link_libraries(execsnoop PRIVATE ${LIBBPF} -l:libelf.a -l:libz.a) endif() - -target_link_libraries(execsnoop PRIVATE ${LIBBPF} -lelf -lz) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bfb4679..06e51dd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,3 @@ -find_package(Threads REQUIRED) find_package(nlohmann_json REQUIRED) include_directories(${PROJECT_SOURCE_DIR}) include_directories(${PROJECT_SOURCE_DIR}/execsnoop-kernel/) @@ -14,10 +13,12 @@ else() endif() add_executable(main main.cpp common.cpp config.cpp cgroup_attach.cpp socket_client.cpp socket_server.cpp) -target_link_libraries(main PRIVATE nlohmann_json::nlohmann_json Threads::Threads ${DL_LIB} ${EXECSNOOP_LIB}) +target_link_libraries(main PRIVATE nlohmann_json::nlohmann_json ${DL_LIB} ${EXECSNOOP_LIB}) set_target_properties(main PROPERTIES OUTPUT_NAME cgproxy) install(TARGETS main RUNTIME) if (build_static) - target_link_libraries(main PRIVATE -static-libgcc -static-libstdc++) + target_link_libraries(main PRIVATE -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive) +else() + target_link_libraries(main PRIVATE -lpthread) endif()