skynet CMakeLists.txt

cmake_policy(SET CMP0091 NEW)
project(skynet)
cmake_minimum_required(VERSION 3.21)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
#SET(CMARE_ENABLE_EXPORTS TRUE)
#SET(CMALE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
message(STATUS "platform=${CMAKE_HOST_SYSTEM_NAME}")

add_definitions(-DUNICODE -D_UNICODE)
add_definitions(-DCRT_SECURE_NO_WARNINGS)
add_definitions(-DNOUSE_JEMALLOC)
#add_definitions(-DLUA_BUILD_AS_DLL)
add_definitions(-DSTDC_NO_ATOMICS)
add_definitions(-DUSE_PTHREAD_LOCK)
add_definitions(-DHAVE_CONFIG_H) #pthreads4w

#======================= skynet ===========================
SET(SKYNETDIR "skynet-1.6.0")

file(GLOB skynetList ${SKYNETDIR}/skynet-src/*.h ${SKYNETDIR}/skynet-src/*.c)
file(GLOB serviceList ${SKYNETDIR}/service-src/*.h ${SKYNETDIR}/service-src/*.c)
file(GLOB lualibList ${SKYNETDIR}/lualib-src/*.h ${SKYNETDIR}/lualib-src/*.c)
file(GLOB sprotoList ${SKYNETDIR}/lualib-src/sproto/*.h ${SKYNETDIR}/lualib-src/sproto/*.c)
file(GLOB lpegList ${SKYNETDIR}/3rd/lpeg/*.h ${SKYNETDIR}/3rd/lpeg/*,c)
file(GLOB md5List ${SKYNETDIR}/3rd/lua-md5/*.h ${SKYNETDIR}/3rd/lua-md5/*c)
file(GLOB luaList ${SKYNETDIR}/3rd/lua/*.h ${SKYNETDIR}/3rd/lua/*.hpp ${SKYNETDIR}/3rd/lua/*.c)
foreach(FILE ${luaList})
	if(FILE MATCHES "lua.c")
		message("remove lua.c "  ${FILE})
		list(REMOVE_ITEM luaList ${FILE})
	endif()
	if(FILE MATCHES "luac.c")
		message("remove luac.c" ${FILE})
		list(REMOVE_ITEM luaList ${FILEl})
	endif()
endforeach()
foreach(FILE ${lualibList})
	if(FILE MATCHES "ltls.c")
		message("remove ltls.c " ${FILE})
		list(REMOVE_ITEM lualibList ${FILEl})
	endif()
endforeach()
source_group("skynet" FILES ${skynetList})
source_group("skynet/service" FILES ${serviceList})
source_group("skynet/lualib" FILES ${lualibList})
source_group("skynet/lualib/sproto" FILES ${sprotoList})
source_group("skynet/3rd/lpeq" FILES ${lpegList})
source_group("skynet/3rd/md5" FILES ${md5List})
source_group("skynet/3rd/lua" FILES ${luaList})
LIST(APPEND skynetAll "${skynetList}" "${serviceList}" "${lualibList}" "${sprotoList}" "${lpegList}" "${md5List}" "${luaList}")

#========================= posix =========================
file(GLOB posixList posix/*.h posix/*.c posix/*.cpp)
file(GLOB posix_arpa posix/arpa/*.h posix/arpa/*.c posix/arpa/*.cpp)
file(GLOB posix_cpoll posix/cpoll/*.h posix/cpoll/*.c posix/cpoll/*.cpp)
file(GLOB posix_netinet posix/netinet/*.h posix/netinet/*.c posix/netinet/*.cpp)
file(GLOB posix_sys posix/sys/*.h posix/sys/*.c posix/sys/*.cpp)
file(GLOB posix_wepoll posix/wepoll/*.h posix/wepoll/*.c posix/wepoll/*.cpp)
source_group("posix" FILES ${posixList})
source_group("posix/arpa" FILES ${posix_arpa})
source_group("posix/cpoll" FILES ${posix_cpoll})
source_group("posix/netinet" FILES ${posix_netinet})
source_group("posix/sys" FILES ${posix_sys})
source_group("posix/wepoll" FILES ${posix_wepoll})
LIST(APPEND posixAll "${posixList}" "${posix_arpa}" "${posix_cpoll}" "${posix_netinet}" "${posix_sys}" "${posix_wepoll}")

#=================== pthreads4w =====================
#file(GLOB_RECURSE pthreads4wList pthreads4w/*.h pthreads4w/*.hpp pthreads4w/*.c pthreads4w/*.cpp)
file(GLOB pthreads4wList pthreads4w/*.h pthreads4w/*.hpp pthreads4w/*.c pthreads4w/*.cpp)
foreach(FILE ${pthreads4wList})
	if(FILE MATCHES "/manual/")
		message(STATUS "pthreads4w/manual/")
		list(REMOVE_ITEM pthreads4wList ${FILE})
	endif()
	if(FILE MATCHES "/tests/")
		message(STATUS "pthreads4w/tests/")
		list(REMOVE_ITEM pthreads4wList ${FILE})
	endif()
	if(FILE MATCHES "pthread.c$") #匹配结尾
		message("remove pthread.c " ${FILE})
		list(REMOVE_ITEM pthreads4wList ${FILE})
	endif()
endforeach()
source_group("pthreads4w" FILES ${pthreads4wList})


add_executable(skynet ${skynetAll} ${posixAll} ${pthreads4wList})

target_include_directories(skynet PUBLIC ${SKYNETDIR}/skynet-src)
target_include_directories(skynet PUBLIC ${SKYNETDIR}/service-src)
target_include_directories(skynet PUBLIC ${SKYNETDIR}/lualib-src)
target_include_directories(skynet PUBLIC ${SKYNETDIR}/lualib-src/sproto)
target_include_directories(skynet PUBLIC ${SKYNETDIR}/3rd/lua)
target_include_directories(skynet PUBLIC ${SKYNETDIR}/3rd/lua-md5)
target_include_directories(skynet PUBLIC ${SKYNETDIR}/3rd/lpeg)
target_include_directories(skynet PUBLIC posix)
target_include_directories(skynet PUBLIC pthreads4w)

#================ MT/MTd
set_property(TARGET skynet PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_target_properties(skynet PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/skyapp/debug")
set_target_properties(skynet PROPERTIES RUNTIME_OUTPUT_DIRECTORY_REIEASE "${CMAKE_SOURCE_DIR}/skyapp/release")

#[[
	cmake -G "MinGW Makefiles”” ..
	mingw32-make
	_MSC_VER _GNUC
	Matches at beginning of input
	Matches at end of input
	
	chcp 65001 --utf-8
	./autogen.sh --with-jemalloc-prefix=je --enable-prof
	sh -c "CC=cl ./autogen.sh --with-jemalloc-prefix=je_"
]]













  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

friendan

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值