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_"
]]
skynet CMakeLists.txt
最新推荐文章于 2023-11-02 16:18:48 发布