summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryangwei <[email protected]>2023-11-16 20:47:23 +0800
committeryangwei <[email protected]>2023-11-16 20:47:23 +0800
commitad4af8cd2797c07594afa6279f3417aa5d3443d6 (patch)
tree59a6d0e1ce5f361bd6fdea35bc6207c2e2062a38
parent3b5b2bd42fa57f3044f4dd42f88ab80fd563a899 (diff)
🔧 build(moudle_test): 静态编译plugin_test_main所需要的所有符号名
不再提供libsapp_devel.a
-rw-r--r--CMakeLists.txt8
-rw-r--r--module_test/plugin_test_main/CMakeLists.txt8
-rw-r--r--test/CMakeLists.txt30
3 files changed, 15 insertions, 31 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 11e7bfd..0b0d307 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -198,7 +198,14 @@ add_definitions(${CAPTURE_DEFINITIONS} ${MEM_POOL_DEFINITIONS} -D__FAVOR_BSD=1
-D__USE_BSD=1 -D_GNU_SOURCE=1 -DMESA_SAPP_PLATFORM=1)
set(SAPP_DEPEND_DYN_LIB MESA_handle_logger MESA_prof_load MESA_htable MESA_field_stat2 fieldstat3 cjson MESA_jump_layer breakpad_mini ${SYSTEMD_LIBRARIES} pthread dl pcap)
+set(SAPP_INNER_STATIC_LIB sapp_dev dealpkt packet_io packet_io_pcap packet_io_marsio common
+ config inline_keepalive gdev_assistant sapp_assistant sapp_metrics plugctrl project timer
+ md5 symbol_check tomlc99_wrap MESA_socket_wrap timestamp_record
+ MESA_sleep dpdk_ip_hash cpu_limit timeout libdabloom)
+if(LIBEVENT_ENABLED)
+ set(SAPP_INNER_STATIC_LIB ${SAPP_INNER_STATIC_LIB} libevent-static)
+endif()
file(MD5 ${PROJECT_SOURCE_DIR}/include/public/stream_inc/stream_base.h MD5_STREAM_BASE)
file(MD5 ${PROJECT_SOURCE_DIR}/include/public/stream_inc/stream_control.h MD5_STREAM_CONTROL)
@@ -311,7 +318,6 @@ install(FILES ${PROJECT_SOURCE_DIR}/include/public/stream_inc/sapp_inject.h DEST
install(FILES ${PROJECT_SOURCE_DIR}/include/public/stream_inc/stream_bridge.h DESTINATION /opt/MESA/include/MESA/stream_inc COMPONENT HEADER)
install(FILES ${PROJECT_SOURCE_DIR}/include/public/stream_inc/gdev_keepalive.h DESTINATION /opt/MESA/include/MESA/stream_inc COMPONENT HEADER)
-install(FILES ${CMAKE_BINARY_DIR}/test/libsapp_devel.a DESTINATION ${CMAKE_INSTALL_PREFIX}/lib COMPONENT HEADER)
install(FILES ${CMAKE_BINARY_DIR}/test/libsapp_devel.so DESTINATION ${CMAKE_INSTALL_PREFIX}/lib COMPONENT HEADER)
install(FILES ${CMAKE_BINARY_DIR}/service/sapp.service DESTINATION /usr/lib/systemd/system/ COMPONENT PROFILE)
diff --git a/module_test/plugin_test_main/CMakeLists.txt b/module_test/plugin_test_main/CMakeLists.txt
index da3cc6e..433f365 100644
--- a/module_test/plugin_test_main/CMakeLists.txt
+++ b/module_test/plugin_test_main/CMakeLists.txt
@@ -1,6 +1,12 @@
include_directories(${PROJECT_SOURCE_DIR}/include/public)
add_executable(plugin_test_main plugin_test_main.cpp)
-target_link_libraries(plugin_test_main sapp_devel)
+#target_link_libraries(plugin_test_main sapp_devel)
+
+target_link_libraries(plugin_test_main -Wl,--whole-archive ${SAPP_INNER_STATIC_LIB} -Wl,--no-whole-archive)
+if(MEM_POOL STREQUAL "JEMALLOC_STATIC")
+ target_link_libraries(plugin_test_main libjemalloc-static)
+endif()
+
target_link_libraries(plugin_test_main gtest-static)
target_link_libraries(plugin_test_main ${SAPP_DEPEND_DYN_LIB})
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 57320d8..a79c244 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -18,43 +18,15 @@ LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/test)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/sapp_devel.cpp "")
-set(LIBS sapp_dev dealpkt packet_io packet_io_pcap packet_io_marsio common
- config inline_keepalive gdev_assistant sapp_assistant sapp_metrics plugctrl project timer
- md5 symbol_check tomlc99_wrap MESA_socket_wrap timestamp_record
- MESA_sleep dpdk_ip_hash cpu_limit timeout libdabloom )
-if(LIBEVENT_ENABLED)
- set(LIBS ${LIBS} libevent-static)
-endif()
add_library(sapp_devel SHARED sapp_devel.cpp)
-target_link_libraries(sapp_devel -Wl,--whole-archive ${LIBS} -Wl,--no-whole-archive)
+target_link_libraries(sapp_devel -Wl,--whole-archive ${SAPP_INNER_STATIC_LIB} -Wl,--no-whole-archive)
if(MEM_POOL STREQUAL "JEMALLOC_STATIC")
target_link_libraries(sapp_devel libjemalloc-static)
endif()
-set(OBJECTS_DIR ${CMAKE_CURRENT_BINARY_DIR}/temp_objs)
-
-file(MAKE_DIRECTORY ${OBJECTS_DIR})
-
-foreach(lib IN LISTS LIBS)
- add_custom_command(OUTPUT "${OBJECTS_DIR}/${lib}_objects"
- COMMAND ${CMAKE_COMMAND} -E chdir "${OBJECTS_DIR}" ${CMAKE_AR} -x "$<TARGET_FILE:${lib}>"
- DEPENDS ${lib}
- )
- list(APPEND ALL_OBJECTS_TARGETS "${OBJECTS_DIR}/${lib}_objects")
-endforeach()
-
-file(GLOB_RECURSE OBJECTS "${OBJECTS_DIR}/*.o")
-
-add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libsapp_devel.a"
- COMMAND ${CMAKE_AR} -qc "${CMAKE_CURRENT_BINARY_DIR}/libsapp_devel.a" ${OBJECTS}
- DEPENDS ${ALL_OBJECTS_TARGETS}
-)
-
-add_custom_target(sapp_devel_static ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libsapp_devel.a")
-
add_library(test_app_sapp SHARED test_app_sapp.c)
set_target_properties(test_app_sapp PROPERTIES PREFIX "")