ecap_server 分布式改造

This commit is contained in:
2026-07-03 16:50:53 +08:00
parent 6e22ccdc6b
commit e8eec327dd
+31 -46
View File
@@ -14,26 +14,25 @@ if (WIN32)
set(IMPORT_ATTR "__attribute__((dllimport))")
set(LOCAL_ATTR "")
set(COMPILER_NAME "Clang on Windows")
else()
else ()
set(EXPORT_ATTR "__declspec(dllexport)")
set(IMPORT_ATTR "__declspec(dllimport)")
set(LOCAL_ATTR "")
set(COMPILER_NAME "${CMAKE_CXX_COMPILER_ID} on Windows")
endif()
else()
endif ()
else ()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
set(EXPORT_ATTR "__attribute__((visibility(\"default\")))")
set(IMPORT_ATTR "__attribute__((visibility(\"default\")))")
set(LOCAL_ATTR "__attribute__((visibility(\"hidden\")))")
set(COMPILER_NAME "${CMAKE_CXX_COMPILER_ID}")
else()
else ()
set(EXPORT_ATTR "")
set(IMPORT_ATTR "")
set(LOCAL_ATTR "")
set(COMPILER_NAME "${CMAKE_CXX_COMPILER_ID}")
endif()
endif()
endif ()
endif ()
set(global_include_dir ${CMAKE_CURRENT_LIST_DIR}/psc_global_include)
@@ -45,22 +44,18 @@ string(APPEND global_include_cpp "${base_dir}/global_include.cpp")
string(APPEND global_include_h_content "#pragma once\n")
string(APPEND global_include_cpp_content "#pragma once\n")
set(rel_global_include "../../psc_global_include")
foreach(h IN LISTS hs)
foreach (h IN LISTS hs)
file(RELATIVE_PATH rel_h ${global_include_dir} ${h})
string(APPEND global_include_h_content "#include \"${rel_global_include}/${rel_h}\"\n")
endforeach()
foreach(s IN LISTS ss)
endforeach ()
foreach (s IN LISTS ss)
file(RELATIVE_PATH rel_s ${global_include_dir} ${s})
string(APPEND global_include_cpp_content "#include \"${rel_global_include}/${rel_s}\"\n")
endforeach()
endforeach ()
file(WRITE ${global_include_h} ${global_include_h_content})
file(WRITE ${global_include_cpp} ${global_include_cpp_content})
include(${CMAKE_CURRENT_LIST_DIR}/3rd/asio/main.cmake)
@@ -88,9 +83,7 @@ target_precompile_headers(Core_Static PRIVATE
)
if(NOT spdlog_FOUND)
if (NOT spdlog_FOUND)
set(SPDLOG_BUILD_PIC ON)
set(spdlog_name spdlog-1.17.0)
set(spdlog_root_dir "${3rd_dir}/spdlog/${spdlog_name}")
@@ -103,15 +96,15 @@ if(NOT spdlog_FOUND)
set(SPDLOG_INSTALL ON CACHE BOOL "" FORCE)
target_include_directories(Core_Interface INTERFACE ${spdlog_root_dir}/include)
add_subdirectory(${spdlog_root_dir} ${CMAKE_CURRENT_BINARY_DIR}/Core_spdlog)
else()
else ()
message(STATUS "Found spdlog: ${spdlog_VERSION}")
endif()
endif ()
target_include_directories(Core_Interface INTERFACE "${CMAKE_CURRENT_LIST_DIR}")
target_include_directories(Core_Interface INTERFACE "${CMAKE_CURRENT_LIST_DIR}/3rd/ucoro/include")
target_include_directories(Core_Interface INTERFACE ${3rd_dir}/magic_enum/magic_enum/include)
target_include_directories(Core_Interface INTERFACE ${3rd_dir}/magic_enum/magic_enum/include)
target_compile_definitions(Core_Interface INTERFACE SPDLOG_COMPILED_LIB)
target_compile_definitions(Core_Interface INTERFACE INCL_EXTRA_HTON_FUNCTIONS)
set_target_properties(Core_Interface PROPERTIES FOLDER "Core")
target_compile_definitions(Core_Interface INTERFACE INCL_EXTRA_HTON_FUNCTIONS)
set_target_properties(Core_Interface PROPERTIES FOLDER "Core")
# ============================================================
# Core compile definitions
@@ -132,7 +125,7 @@ target_compile_definitions(Core_Interface INTERFACE
# Compiler options
# ============================================================
if(MSVC)
if (MSVC)
target_compile_options(Core_Interface INTERFACE
/wd4819
/utf-8
@@ -140,7 +133,7 @@ if(MSVC)
/EHsc
/bigobj
)
else()
else ()
target_compile_options(Core_Interface INTERFACE
-fvisibility=hidden
-fvisibility-inlines-hidden
@@ -151,14 +144,14 @@ else()
-Wconversion
-Wsign-conversion
)
endif()
endif ()
# ============================================================
# Platform link libraries
# ============================================================
if(WIN32)
if (WIN32)
target_link_libraries(Core_Static PRIVATE
ole32
oleaut32
@@ -169,36 +162,29 @@ if(WIN32)
iphlpapi
)
endif()
endif ()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(Core_Static PUBLIC
rt
dl
pthread
)
endif()
endif ()
#include("${CMAKE_CURRENT_LIST_DIR}/3rd/ucoro/main.cmake")
if(1)
if (NOT GTest_FOUND)
find_package(GTest)
endif()
if (NOT GTest_FOUND)
add_subdirectory(${CMAKE_SOURCE_DIR}/3rdParty/GTest)
endif()
set(ucoro_dir "${CMAKE_CURRENT_LIST_DIR}/3rd/ucoro")
file(GLOB_RECURSE ucoro_srcs ${ucoro_dir}/*.h ${ucoro_dir}/*.hpp ${ucoro_dir}/*.cpp)
target_compile_definitions(Core_Interface INTERFACE _USE_GTEST)
target_link_libraries(Core_Static PUBLIC GTest::gtest GTest::gmock)
target_sources(Core_Static PUBLIC ${ucoro_srcs})
endif()
#if (1)
# set(ucoro_dir "${CMAKE_CURRENT_LIST_DIR}/3rd/ucoro")
# file(GLOB_RECURSE ucoro_srcs ${ucoro_dir}/*.h ${ucoro_dir}/*.hpp ${ucoro_dir}/*.cpp)
# target_compile_definitions(Core_Interface INTERFACE _USE_GTEST)
# target_link_libraries(Core_Static PUBLIC GTest::gtest GTest::gmock)
# target_sources(Core_Static PUBLIC ${ucoro_srcs})
#
#endif ()
target_link_libraries(Core_Static PUBLIC boost_pfr)
target_link_libraries(Core_Static PUBLIC Core_Interface)
target_link_libraries(Core_Static PUBLIC spdlog::spdlog)
target_link_libraries(Core_Static PUBLIC asio_object)
@@ -217,7 +203,6 @@ add_executable(Core_exe ${CMAKE_CURRENT_LIST_DIR}/main.cpp)
target_link_libraries(Core_exe PRIVATE Core_Static)
get_target_property(_c_launcher Core_Static C_COMPILER_LAUNCHER)
get_target_property(_cxx_launcher Core_Static CXX_COMPILER_LAUNCHER)
message("Core_Static C_COMPILER_LAUNCHER=${_c_launcher}")