1 Star 0 Fork 0

MyProjects/GameServer 2.0

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
common.cmake 2.25 KB
一键复制 编辑 原始数据 按行查看 历史
bacuijg 提交于 2024-10-25 22:00 . update
# 编译server
macro(build_server server_name)
cmake_minimum_required(VERSION 3.24)
project(${server_name})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O2")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/output)
set(ThirdPartyDIR ${CMAKE_SOURCE_DIR}/thirdparty)
include_directories(.)
file(GLOB_RECURSE SRC_ALL_FILES ${CMAKE_CURRENT_LIST_DIR} "*.cpp" "*.cc" "*.h" "*.hpp")
add_executable(${server_name} ${SRC_ALL_FILES})
target_link_libraries(${server_name} PRIVATE
SvrSDK
SvrMessage
# thirdparty
debug fmtd
optimized fmt
debug protobufd
optimized protobuf
debug hiredisd
optimized hiredis
tinyxml2 event event_core event_extra event_openssl event_pthreads
rdkafka++ rdkafka redis++ mysqlclient prometheus-cpp-core
prometheus-cpp-pull prometheus-cpp-push zookeeper_mt #gtest
curl ssl crypto z pthread dl
)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(${server_name} PRIVATE
uuid rt tcmalloc_minimal
)
endif ()
endmacro()
# 编译ext_module
macro(build_ext_mdoule module_name)
cmake_minimum_required(VERSION 3.24)
project(${module_name})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O2")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/output/ext_modules/${module_name})
set(ThirdPartyDIR ${CMAKE_SOURCE_DIR}/thirdparty)
include_directories(.)
file(GLOB_RECURSE SRC_ALL_FILES ${CMAKE_CURRENT_LIST_DIR} "*.cpp" "*.cc" "*.h" "*.hpp")
add_library(${module_name} SHARED
${SRC_ALL_FILES} ../IBaseExtModule.h
)
target_link_libraries(${module_name} PRIVATE
SvrSDK
# thirdparty
debug fmtd
optimized fmt
tinyxml2 z pthread dl
)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(${module_name} PRIVATE
uuid rt tcmalloc_minimal
)
endif ()
endmacro()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/myprojects-all/GameServer.git
git@gitee.com:myprojects-all/GameServer.git
myprojects-all
GameServer
GameServer 2.0
master

搜索帮助