因为个人在skynet需要在windows平台使用(clion/vs/vscode其中一种IDE)+(WSL/Remote Linux)+CMAKE,调试运行skynet,所以写了一份CMAKE。
skynet根目录

# 校验CMake版本
cmake_minimum_required(VERSION 3.10)

# 工程名
project(skynet)

# 头文件路径
include_directories(
    skynet-src
    3rd/lua
    3rd/lua-md5
    3rd/jemalloc/include/jemalloc
    3rd/lpeg
    lualib-src
    lualib-src/sproto
)

# 库路径
link_directories(
    /usr/local/lib
    3rd/jemalloc/lib/
)

# 编译参数
add_definitions(-O0 -g -Wall -std=gnu99 -pthread)
#add_definitions(-O2 -g -Wall -std=gnu99 -pthread)

# 设置可执行文件输出目录
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR})

# 去这些目录下找CMakeLists.txt执行
subdirs(
    skynet-src
    service-src
    lualib-src
)

skynet-src

# 查找当前目录下的所有源文件
aux_source_directory(. DIR_SRCS)

# 设置编译选项
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wl,-E)

# 生成可执行文件
add_executable(skynet_run ${DIR_SRCS})

# 添加依赖库
target_link_libraries(skynet_run jemalloc_pic pthread dl lua m ssl rt)

service-src

# 设置库生成路径
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/cservice)

# 遍历文件列表生成对应库
SET(FILE_LIST snlua logger gate harbor)
foreach (file ${FILE_LIST})
    add_library(${file} SHARED "service_${file}.c")
    set_target_properties(${file} PROPERTIES PREFIX "")
endforeach()

lualib-src

# 指定库生成路径
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/luaclib)

# 设置编译选项
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wl,-E)

# skynet库
aux_source_directory(. DIR_SRCS)
add_library(skynet SHARED ${DIR_SRCS})
target_link_libraries(skynet ssl)

# client库
add_library(client SHARED lua-clientsocket.c lua-crypt.c lsha1.c)

# bson库
add_library(bson SHARED lua-bson.c)

# sproto库
add_library(sproto SHARED ./sproto/sproto.c ./sproto/lsproto.c)

# ltls库
add_library(ltls SHARED ltls.c)

# lpeg库
aux_source_directory("../3rd/lpeg" LPEG_SRCS)
add_library(lpeg SHARED ${LPEG_SRCS})

# lua库
add_definitions(-DLUA_USE_LINUX)
aux_source_directory("../3rd/lua" LUA_SRCS)
add_library(lua STATIC ${LUA_SRCS})

# lua-md5库
aux_source_directory("../3rd/lua-md5" LUA_MD5_SRCS)
add_library(md5 SHARED ${LUA_MD5_SRCS})

# 去掉lib前缀
SET(FILE_LIST skynet client bson ltls lpeg sproto md5)
foreach (file ${FILE_LIST})
    set_target_properties(${file} PROPERTIES PREFIX "")
endforeach ()

附上一张效果图
skynet.png

特别感谢:

感谢在我遇到问题的时候,飞哥给予我的帮助!
飞哥的博客