summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryangwei <[email protected]>2024-08-23 16:57:50 +0800
committeryangwei <[email protected]>2024-08-23 16:57:50 +0800
commit2ef4c8f3cad74fa4291129c7047a3bfdca5a3861 (patch)
tree3078146a3e89ba71e7ad55a8941f0e527246f3de
parentea64461bcc79a6735c16e0299907372d06eb1ddc (diff)
🔧 build(unify SAPP_MODULES ): define depend library in SAPP_MODULES
-rw-r--r--CMakeLists.txt34
-rw-r--r--module_test/plugin_test_main/CMakeLists.txt7
-rw-r--r--src/entry/CMakeLists.txt32
-rw-r--r--test/CMakeLists.txt6
-rw-r--r--vendor/CMakeLists.txt2
5 files changed, 34 insertions, 47 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f0136d4..6bd8fc3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -87,6 +87,8 @@ message(STATUS "PLATFORM_MODE='${PLATFORM_MODE}'")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLINK_MODE_DYNAMIC=0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLINK_MODE_DYNAMIC=0")
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+
# CPU profiler
set(CPU_PROFILE "OFF" CACHE STRING
" set cpu profiler chosen by the user, using OFF as default")
@@ -200,13 +202,33 @@ 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 fieldstat4 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 ap_bloom libdabloom token_bucket)
+set(SAPP_DEPEND_DYN_LIB ${SAPP_DEPEND_DYN_LIB} packet_io_pcap)
+if(CAPTURE_MODE STREQUAL "MARSIO")
+ set(SAPP_DEPEND_DYN_LIB ${SAPP_DEPEND_DYN_LIB} packet_io_marsio)
+endif()
+
+if(CAPTURE_MODE STREQUAL "TUN")
+ set(SAPP_DEPEND_DYN_LIB ${SAPP_DEPEND_DYN_LIB} packet_io_tun)
+endif()
+
+set(SAPP_MODULES timestamp_record md5
+ symbol_check MESA_sleep MESA_socket_wrap
+ packet_io dealpkt project plugctrl common
+ config timer tomlc99_wrap dpdk_ip_hash
+ gdev_assistant inline_keepalive ap_bloom libdabloom
+ sapp_dev sapp_assistant sapp_metrics
+ platform_support cpu_limit timeout token_bucket)
+
+if(LIBEVENT_ENABLED STREQUAL "ON")
+ set(SAPP_MODULES ${SAPP_MODULES} libevent-static)
+endif()
+
+if(MEM_POOL STREQUAL "JEMALLOC_STATIC")
+ set(SAPP_MODULES ${SAPP_MODULES} libjemalloc-static)
+endif()
-if(LIBEVENT_ENABLED)
- set(SAPP_INNER_STATIC_LIB ${SAPP_INNER_STATIC_LIB} libevent-static)
+if(MEM_POOL STREQUAL "MIMALLOC")
+ set(SAPP_MODULES ${SAPP_MODULES} libmimalloc-static)
endif()
file(MD5 ${PROJECT_SOURCE_DIR}/include/public/stream_inc/stream_base.h MD5_STREAM_BASE)
diff --git a/module_test/plugin_test_main/CMakeLists.txt b/module_test/plugin_test_main/CMakeLists.txt
index 433f365..1fd32a1 100644
--- a/module_test/plugin_test_main/CMakeLists.txt
+++ b/module_test/plugin_test_main/CMakeLists.txt
@@ -2,11 +2,10 @@ 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 -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 -Wl,--whole-archive ${SAPP_MODULES} -Wl,--no-whole-archive)
+
target_link_libraries(plugin_test_main gtest-static)
target_link_libraries(plugin_test_main ${SAPP_DEPEND_DYN_LIB})
+
diff --git a/src/entry/CMakeLists.txt b/src/entry/CMakeLists.txt
index 66f8e8c..dcaa8ab 100644
--- a/src/entry/CMakeLists.txt
+++ b/src/entry/CMakeLists.txt
@@ -17,13 +17,10 @@ if(CAPTURE_MODE STREQUAL "MARSIO")
endif()
-
if(HASP_ENABLED)
include_directories(/opt/tsg/hasp-tools/include/)
endif()
-
-
add_executable(sapp sapp_main.c)
target_compile_options(sapp PUBLIC ${MEM_POOL_DEFINITIONS})
target_include_directories(sapp PRIVATE ${SYSTEMD_INCLUDE_DIRS})
@@ -34,34 +31,7 @@ if(HASP_ENABLED STREQUAL "ON")
target_link_libraries(sapp ${HASP_TOOLS_LIB})
endif()
-set(SAPP_MODULES timestamp_record md5
- symbol_check MESA_sleep MESA_socket_wrap
- packet_io dealpkt project plugctrl common
- config timer tomlc99_wrap dpdk_ip_hash
- gdev_assistant inline_keepalive ap_bloom libdabloom
- sapp_dev sapp_assistant sapp_metrics
- platform_support cpu_limit timeout token_bucket)
-
-if(LIBEVENT_ENABLED STREQUAL "ON")
- set(SAPP_MODULES ${SAPP_MODULES} libevent-static)
-endif()
-
-if(MEM_POOL STREQUAL "JEMALLOC_STATIC")
- set(SAPP_MODULES ${SAPP_MODULES} libjemalloc-static)
-endif()
-
-if(MEM_POOL STREQUAL "MIMALLOC")
- set(SAPP_MODULES ${SAPP_MODULES} libmimalloc-static)
-endif()
-
target_link_libraries(sapp -Wl,--whole-archive ${SAPP_MODULES} -Wl,--no-whole-archive)
target_link_libraries(sapp ${SAPP_DEPEND_DYN_LIB})
-target_link_libraries(sapp packet_io_pcap)
-if(CAPTURE_MODE STREQUAL "MARSIO")
- target_link_libraries(sapp packet_io_marsio)
-endif()
-
-if(CAPTURE_MODE STREQUAL "TUN")
- target_link_libraries(sapp packet_io_tun)
-endif()
+
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index a79c244..1229831 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -21,11 +21,7 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/sapp_devel.cpp "")
add_library(sapp_devel SHARED sapp_devel.cpp)
-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()
+target_link_libraries(sapp_devel -Wl,--whole-archive ${SAPP_MODULES} -Wl,--no-whole-archive)
add_library(test_app_sapp SHARED test_app_sapp.c)
diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt
index 89ff8c0..a3dc3af 100644
--- a/vendor/CMakeLists.txt
+++ b/vendor/CMakeLists.txt
@@ -26,7 +26,7 @@ if(MEM_POOL STREQUAL "JEMALLOC_STATIC")
ExternalProject_Add(libjemalloc PREFIX libjemalloc
URL ${CMAKE_CURRENT_SOURCE_DIR}/jemalloc-5.3.0.tar.gz
URL_MD5 594dd8e0a1e8c1ef8a1b210a1a5aff5b
- CONFIGURE_COMMAND ./autogen.sh CFLAGS=-fPIC --disable-shared --enable-prof
+ CONFIGURE_COMMAND ./autogen.sh CFLAGS=-fPIC CXXFLAGS=-fPIC --disable-shared --enable-prof
#$<IF:$<CONFIG:Debug>,--enable-prof,>
--prefix=<INSTALL_DIR>
BUILD_COMMAND make -j${CPU_COUNT}