Refactor CMake to be nicer, more modern, easier to understand
This commit is contained in:
parent
8fd752f9cd
commit
c69587c2e7
46
3rdparty/httplib/CMakeLists.txt
vendored
46
3rdparty/httplib/CMakeLists.txt
vendored
@ -1,38 +1,18 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
add_library(httplib STATIC ${HTTPLIB_SOURCES})
|
||||
|
||||
if ( NOT ENABLE_WEB_SERVER )
|
||||
return()
|
||||
endif( NOT ENABLE_WEB_SERVER )
|
||||
target_sources(httplib PRIVATE "httplib.cc")
|
||||
|
||||
SET (this_target httplib)
|
||||
PROJECT(${this_target})
|
||||
|
||||
find_path ( HTTPLIB_INCLUDE_DIRS "httplib.h"
|
||||
PATHS "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
NO_DEFAULT_PATH )
|
||||
|
||||
find_path ( HTTPLIB_SOURCE_DIR "httplib.cc"
|
||||
PATHS "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
NO_DEFAULT_PATH )
|
||||
|
||||
mark_as_advanced( HTTPLIB_INCLUDE_DIRS )
|
||||
mark_as_advanced( HTTPLIB_SOURCE_DIR )
|
||||
|
||||
set ( HTTPLIB_HEADERS
|
||||
"${HTTPLIB_INCLUDE_DIRS}/httplib.h"
|
||||
CACHE INTERNAL "httplib headers" )
|
||||
|
||||
set ( HTTPLIB_SOURCES
|
||||
"${HTTPLIB_SOURCE_DIR}/httplib.cc"
|
||||
CACHE INTERNAL "httplib sources" )
|
||||
|
||||
set ( HTTPLIB_DEFINITIONS
|
||||
"-std=c++11"
|
||||
CACHE INTERNAL "http definitions" )
|
||||
include_directories( ${HTTPLIB_INCLUDE_DIRS} ${HTTPLIB_SOURCE_DIR} )
|
||||
|
||||
ADD_LIBRARY( ${this_target} STATIC ${HTTPLIB_SOURCES} )
|
||||
target_include_directories(httplib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if(NOT WIN32)
|
||||
target_compile_definitions(${this_target} PUBLIC "CPPHTTPLIB_SEND_FLAGS=MSG_NOSIGNAL")
|
||||
target_compile_definitions(httplib PUBLIC "CPPHTTPLIB_SEND_FLAGS=MSG_NOSIGNAL")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_sources(httplib PRIVATE "httplib.h")
|
||||
set_target_properties(httplib PROPERTIES FOLDER "3rdparty")
|
||||
endif()
|
||||
|
||||
if(NOT ENABLE_WEB_SERVER)
|
||||
set_target_properties(httplib PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||
endif()
|
||||
|
||||
8
3rdparty/json/CMakeLists.txt
vendored
8
3rdparty/json/CMakeLists.txt
vendored
@ -1,7 +1,3 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
add_library(json INTERFACE)
|
||||
|
||||
set (JSON_INCLUDE_DIRS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
CACHE INTERNAL "json include dir" )
|
||||
|
||||
mark_as_advanced( JSON_INCLUDE_DIRS )
|
||||
target_include_directories(json INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
|
||||
52
3rdparty/libconfig/CMakeLists.txt
vendored
52
3rdparty/libconfig/CMakeLists.txt
vendored
@ -1,29 +1,27 @@
|
||||
|
||||
find_path( LIBCONFIG_INCLUDE_DIRS "libconfig.h"
|
||||
PATHS "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
NO_DEFAULT_PATH )
|
||||
find_path( LIBCONFIG_SOURCE_DIR "libconfig.c"
|
||||
PATHS "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
NO_DEFAULT_PATH )
|
||||
mark_as_advanced( LIBCONFIG_INCLUDE_DIRS )
|
||||
mark_as_advanced( LIBCONFIG_SOURCE_DIR )
|
||||
add_library(libconfig STATIC)
|
||||
|
||||
set( LIBCONFIG_HEADERS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/grammar.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/libconfig.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/parsectx.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scanctx.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scanner.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/strbuf.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/wincompat.h"
|
||||
CACHE INTERNAL "libconfig headers" )
|
||||
set( LIBCONFIG_SOURCES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/grammar.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/libconfig.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scanctx.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scanner.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/strbuf.c"
|
||||
CACHE INTERNAL "libconfig sources" )
|
||||
set( LIBCONFIG_DEFINITIONS
|
||||
"-DLIBCONFIG_STATIC"
|
||||
CACHE INTERNAL "libconfig definitions" )
|
||||
target_sources(libconfig PRIVATE
|
||||
"grammar.c"
|
||||
"libconfig.c"
|
||||
"scanctx.c"
|
||||
"scanner.c"
|
||||
"strbuf.c"
|
||||
)
|
||||
|
||||
target_include_directories(libconfig PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
target_compile_definitions(libconfig PUBLIC "-DLIBCONFIG_STATIC")
|
||||
|
||||
if(WIN32)
|
||||
target_sources(libconfig PRIVATE
|
||||
"grammar.h"
|
||||
"libconfig.h"
|
||||
"parsectx.h"
|
||||
"scanctx.h"
|
||||
"scanner.h"
|
||||
"strbuf.h"
|
||||
"wincompat.h"
|
||||
)
|
||||
set_target_properties(libconfig PROPERTIES FOLDER "3rdparty")
|
||||
endif()
|
||||
|
||||
13
3rdparty/rapidyaml/CMakeLists.txt
vendored
13
3rdparty/rapidyaml/CMakeLists.txt
vendored
@ -95,6 +95,13 @@ endif()
|
||||
|
||||
c4_add_dev_targets()
|
||||
|
||||
add_custom_target(ryml-uninstall
|
||||
"${CMAKE_COMMAND}" -P "${PROJECT_SOURCE_DIR}/cmake/uninstall.cmake"
|
||||
)
|
||||
# [rathena]
|
||||
# don't need to uninstall, since we're using a subdirectory
|
||||
# add_custom_target(ryml-uninstall
|
||||
# "${CMAKE_COMMAND}" -P "${PROJECT_SOURCE_DIR}/cmake/uninstall.cmake"
|
||||
# )
|
||||
|
||||
# rathena
|
||||
if(WIN32)
|
||||
set_target_properties(ryml PROPERTIES FOLDER "3rdparty")
|
||||
endif()
|
||||
|
||||
19
3rdparty/rapidyaml/ext/c4core/CMakeLists.txt
vendored
19
3rdparty/rapidyaml/ext/c4core/CMakeLists.txt
vendored
@ -78,12 +78,14 @@ endif()
|
||||
set(C4CORE_AMALGAMATED ${C4CORE_SRC_DIR}/../src_singleheader/c4/c4core_all.hpp)
|
||||
list(TRANSFORM C4CORE_SRC_FILES PREPEND "${C4CORE_SRC_DIR}/" OUTPUT_VARIABLE C4CORE_SRC_FILES_FULL)
|
||||
|
||||
add_custom_target(c4core-amalgamate
|
||||
python ${CMAKE_CURRENT_LIST_DIR}/tools/amalgamate.py ${C4CORE_AMALGAMATED}
|
||||
COMMENT "${CMAKE_CURRENT_LIST_DIR}/tools/amalgamate.py ${C4CORE_AMALGAMATED}"
|
||||
BYPRODUCTS ${C4CORE_AMALGAMATED}
|
||||
DEPENDS ${C4CORE_SRC_FILES_FULL}
|
||||
)
|
||||
# [rathena]
|
||||
# remove this, we don't use it and don't need it poluting our solution
|
||||
# add_custom_target(c4core-amalgamate
|
||||
# python ${CMAKE_CURRENT_LIST_DIR}/tools/amalgamate.py ${C4CORE_AMALGAMATED}
|
||||
# COMMENT "${CMAKE_CURRENT_LIST_DIR}/tools/amalgamate.py ${C4CORE_AMALGAMATED}"
|
||||
# BYPRODUCTS ${C4CORE_AMALGAMATED}
|
||||
# DEPENDS ${C4CORE_SRC_FILES_FULL}
|
||||
# )
|
||||
|
||||
c4_add_library(c4core
|
||||
INC_DIRS
|
||||
@ -105,3 +107,8 @@ c4_install_exports()
|
||||
c4_add_dev_targets()
|
||||
|
||||
c4_pack_project(TYPE LIBRARY)
|
||||
|
||||
# rathena
|
||||
if(WIN32)
|
||||
set_target_properties(c4core PROPERTIES FOLDER "3rdparty")
|
||||
endif()
|
||||
|
||||
152
3rdparty/yaml-cpp/CMakeLists.txt
vendored
152
3rdparty/yaml-cpp/CMakeLists.txt
vendored
@ -1,83 +1,73 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
## start setting
|
||||
SET (this_target yaml-cpp)
|
||||
PROJECT(${this_target})
|
||||
|
||||
find_path( YAML_INCLUDE_DIRS "yaml-cpp/yaml.h"
|
||||
PATHS "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
NO_DEFAULT_PATH )
|
||||
find_path( YAML_SOURCE_DIR "regex_yaml.cpp"
|
||||
PATHS "${CMAKE_CURRENT_SOURCE_DIR}/src"
|
||||
NO_DEFAULT_PATH )
|
||||
mark_as_advanced( YAML_INCLUDE_DIRS )
|
||||
mark_as_advanced( YAML_SOURCE_DIR )
|
||||
|
||||
set(YAML_HEADERS
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/yaml.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/traits.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/stlemitter.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/parser.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/ostream_wrapper.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/null.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/noncopyable.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/mark.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/exceptions.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/eventhandler.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/emitterstyle.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/emittermanip.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/emitter.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/emitterdef.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/emitfromevents.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/dll.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/binary.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/anchor.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/node/type.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/node/ptr.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/node/parse.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/node/node.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/node/iterator.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/node/impl.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/node/emit.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/node/convert.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/contrib/graphbuilder.h"
|
||||
"${YAML_INCLUDE_DIRS}/yaml-cpp/contrib/anchordict.h"
|
||||
CACHE INTERNAL "yaml headers" )
|
||||
"yaml.h"
|
||||
"traits.h"
|
||||
"stlemitter.h"
|
||||
"parser.h"
|
||||
"ostream_wrapper.h"
|
||||
"null.h"
|
||||
"noncopyable.h"
|
||||
"mark.h"
|
||||
"exceptions.h"
|
||||
"eventhandler.h"
|
||||
"emitterstyle.h"
|
||||
"emittermanip.h"
|
||||
"emitter.h"
|
||||
"emitterdef.h"
|
||||
"emitfromevents.h"
|
||||
"dll.h"
|
||||
"binary.h"
|
||||
"anchor.h"
|
||||
"node/type.h"
|
||||
"node/ptr.h"
|
||||
"node/parse.h"
|
||||
"node/node.h"
|
||||
"node/iterator.h"
|
||||
"node/impl.h"
|
||||
"node/emit.h"
|
||||
"node/convert.h"
|
||||
"contrib/graphbuilder.h"
|
||||
"contrib/anchordict.h"
|
||||
)
|
||||
list(TRANSFORM YAML_HEADERS PREPEND "include/yaml-cpp/")
|
||||
|
||||
set(YAML_SOURCES
|
||||
"${YAML_SOURCE_DIR}/binary.cpp"
|
||||
"${YAML_SOURCE_DIR}/convert.cpp"
|
||||
"${YAML_SOURCE_DIR}/directives.cpp"
|
||||
"${YAML_SOURCE_DIR}/emit.cpp"
|
||||
"${YAML_SOURCE_DIR}/emitfromevents.cpp"
|
||||
"${YAML_SOURCE_DIR}/emitter.cpp"
|
||||
"${YAML_SOURCE_DIR}/emitterstate.cpp"
|
||||
"${YAML_SOURCE_DIR}/emitterutils.cpp"
|
||||
"${YAML_SOURCE_DIR}/exceptions.cpp"
|
||||
"${YAML_SOURCE_DIR}/exp.cpp"
|
||||
"${YAML_SOURCE_DIR}/memory.cpp"
|
||||
"${YAML_SOURCE_DIR}/nodebuilder.cpp"
|
||||
"${YAML_SOURCE_DIR}/node.cpp"
|
||||
"${YAML_SOURCE_DIR}/node_data.cpp"
|
||||
"${YAML_SOURCE_DIR}/nodeevents.cpp"
|
||||
"${YAML_SOURCE_DIR}/null.cpp"
|
||||
"${YAML_SOURCE_DIR}/ostream_wrapper.cpp"
|
||||
"${YAML_SOURCE_DIR}/parse.cpp"
|
||||
"${YAML_SOURCE_DIR}/parser.cpp"
|
||||
"${YAML_SOURCE_DIR}/regex_yaml.cpp"
|
||||
"${YAML_SOURCE_DIR}/scanner.cpp"
|
||||
"${YAML_SOURCE_DIR}/scanscalar.cpp"
|
||||
"${YAML_SOURCE_DIR}/scantag.cpp"
|
||||
"${YAML_SOURCE_DIR}/scantoken.cpp"
|
||||
"${YAML_SOURCE_DIR}/simplekey.cpp"
|
||||
"${YAML_SOURCE_DIR}/singledocparser.cpp"
|
||||
"${YAML_SOURCE_DIR}/stream.cpp"
|
||||
"${YAML_SOURCE_DIR}/tag.cpp"
|
||||
"${YAML_SOURCE_DIR}/contrib/graphbuilderadapter.cpp"
|
||||
"${YAML_SOURCE_DIR}/contrib/graphbuilder.cpp"
|
||||
CACHE INTERNAL "yaml sources" )
|
||||
set( YAML_DEFINITIONS
|
||||
"-std=c++11"
|
||||
CACHE INTERNAL "yaml definitions" )
|
||||
include_directories(${YAML_INCLUDE_DIRS} ${YAML_SOURCE_DIR})
|
||||
#message(STATUS "YAML_INCLUDE_DIRS : ${YAML_INCLUDE_DIRS}, YAML_SOURCE_DIR=${YAML_SOURCE_DIR}")
|
||||
ADD_LIBRARY(${this_target} STATIC ${YAML_SOURCES} )
|
||||
"binary.cpp"
|
||||
"convert.cpp"
|
||||
"directives.cpp"
|
||||
"emit.cpp"
|
||||
"emitfromevents.cpp"
|
||||
"emitter.cpp"
|
||||
"emitterstate.cpp"
|
||||
"emitterutils.cpp"
|
||||
"exceptions.cpp"
|
||||
"exp.cpp"
|
||||
"memory.cpp"
|
||||
"nodebuilder.cpp"
|
||||
"node.cpp"
|
||||
"node_data.cpp"
|
||||
"nodeevents.cpp"
|
||||
"null.cpp"
|
||||
"ostream_wrapper.cpp"
|
||||
"parse.cpp"
|
||||
"parser.cpp"
|
||||
"regex_yaml.cpp"
|
||||
"scanner.cpp"
|
||||
"scanscalar.cpp"
|
||||
"scantag.cpp"
|
||||
"scantoken.cpp"
|
||||
"simplekey.cpp"
|
||||
"singledocparser.cpp"
|
||||
"stream.cpp"
|
||||
"tag.cpp"
|
||||
"contrib/graphbuilderadapter.cpp"
|
||||
"contrib/graphbuilder.cpp"
|
||||
)
|
||||
list(TRANSFORM YAML_SOURCES PREPEND "src/")
|
||||
|
||||
add_library(yaml-cpp STATIC EXCLUDE_FROM_ALL ${YAML_SOURCES})
|
||||
|
||||
target_include_directories(yaml-cpp PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
|
||||
if(WIN32)
|
||||
set_target_properties(yaml-cpp PROPERTIES FOLDER "3rdparty")
|
||||
endif()
|
||||
|
||||
516
CMakeLists-old.txt
Normal file
516
CMakeLists-old.txt
Normal file
@ -0,0 +1,516 @@
|
||||
#####################################################################
|
||||
#
|
||||
# "Getting Started with CMake", a tutorial video by Eric Wing.
|
||||
# Part 1 of 6: http://www.youtube.com/watch?v=CLvZTyji_Uw
|
||||
# Part 2 of 6: http://www.youtube.com/watch?v=gUW-RrRQjEg
|
||||
# Part 3 of 6: http://www.youtube.com/watch?v=sz6cPhbuTk4
|
||||
# Part 4 of 6: http://www.youtube.com/watch?v=JICZOkyNXbg
|
||||
# Part 5 of 6: http://www.youtube.com/watch?v=lAiuLHy4dCk
|
||||
# Part 6 of 6: http://www.youtube.com/watch?v=fAtJNzDZdH8
|
||||
#
|
||||
# You can use notepad++ for syntax highlighting.
|
||||
# Naming conventions:
|
||||
# WITH_* : option to use an external package or not
|
||||
# ENABLE_* : option to use an internal feature/code or not
|
||||
# HAVE_* : internal variable indicating if we have and are using something
|
||||
#
|
||||
# Maintainers: Flavio J. Saraiva (feel free to send complaints or suggestions)
|
||||
# flaviojs @ rAthena forum/irc
|
||||
# flaviojs2005 \A-T/ gmail <D.o,T> com
|
||||
# lightaisme \A-T/ gmail <D.o,T> com
|
||||
#
|
||||
#####################################################################
|
||||
|
||||
cmake_minimum_required(VERSION 3.11)
|
||||
|
||||
project( rAthena )
|
||||
set(CMAKE_CXX_STANDARD 14) # C++14...
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/${suffixInstallStr})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/${suffixInstallStr})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# Set a default build type if none was specified
|
||||
set(default_build_type "Release")
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
|
||||
STRING "Choose the type of build." FORCE)
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
#
|
||||
# Prevent building in the source directory by default
|
||||
#
|
||||
if( CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR )
|
||||
message( FATAL_ERROR
|
||||
"Do not use the source directory to build your files, instead delete CMakeCache.txt, create a separate folder and build there.\n"
|
||||
"Example: (build in subdir 'build' and install to source dir)\n"
|
||||
" rm -f CMakeCache.txt\n"
|
||||
" mkdir build\n"
|
||||
" cd build\n"
|
||||
" cmake -G\"Unix Makefiles\" -DINSTALL_TO_SOURCE=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ..\n"
|
||||
" make install\n"
|
||||
" cd ..\n"
|
||||
" rm -rf build\n"
|
||||
"To skip this check, set ALLOW_SAME_DIRECTORY to ON (-DALLOW_SAME_DIRECTORY=ON)" )
|
||||
endif()
|
||||
|
||||
|
||||
# #
|
||||
# # Global stuff
|
||||
# #
|
||||
# if( WIN32 )
|
||||
# set(RATHENA_GLOBAL_DEFINITIONS "${RATHENA_GLOBAL_DEFINITIONS} -DFD_SETSIZE=4096")
|
||||
# endif()
|
||||
# if( MSVC )
|
||||
# set(RATHENA_GLOBAL_LIBRARIES "${RATHENA_GLOBAL_LIBRARIES} \"oldnames.lib\" \"ws2_32.lib\" ")
|
||||
# set(RATHENA_GLOBAL_DEFINITIONS "${RATHENA_GLOBAL_DEFINITIONS} -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE" )
|
||||
# endif()
|
||||
# if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC)
|
||||
# set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -fno-strict-aliasing" )
|
||||
# #set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -O2" ); #need more test to enable this
|
||||
# endif()
|
||||
|
||||
|
||||
#
|
||||
# 3rd party
|
||||
#
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cmake")
|
||||
include( CheckCSourceCompiles )
|
||||
include( CheckCSourceRuns )
|
||||
include( CheckIncludeFile )
|
||||
include( CheckFunctionExists )
|
||||
include( FindFunctionLibrary )
|
||||
include( TestBigEndian )
|
||||
|
||||
|
||||
#
|
||||
# PACKETVER
|
||||
#
|
||||
option(PACKETVER "Sets the PACKETVER define of the servers. (see src/common/mmo.hpp)")
|
||||
|
||||
|
||||
#
|
||||
# Find git
|
||||
#
|
||||
message( STATUS "Detecting git" )
|
||||
find_package(Git)
|
||||
if(GIT_FOUND)
|
||||
if(GIT_VERSION_STRING)
|
||||
message(STATUS "Found git : ${GIT_EXECUTABLE} version (${GIT_VERSION_STRING})")
|
||||
else()
|
||||
message(STATUS "Found git : ${GIT_EXECUTABLE}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(GetGitVersion)
|
||||
get_git_version()
|
||||
|
||||
|
||||
#
|
||||
# threads
|
||||
#
|
||||
message(STATUS "Detecting threads library")
|
||||
set(THREADS_PREFER_PTHREAD_FLAG 1)
|
||||
find_package(Threads REQUIRED)
|
||||
if(Threads_FOUND)
|
||||
message( STATUS "Found thread library: ${CMAKE_THREAD_LIBS_INIT}" )
|
||||
endif()
|
||||
message( STATUS "Detecting threads library - done" )
|
||||
|
||||
|
||||
#
|
||||
# enable web server?
|
||||
#
|
||||
option( ENABLE_WEB_SERVER "Build web-server (default=ON)" ON )
|
||||
|
||||
#
|
||||
# Test for big endian
|
||||
#
|
||||
TEST_BIG_ENDIAN( BIG_ENDIAN )
|
||||
if( NOT DEFINED BIG_ENDIAN )
|
||||
message( WARNING "unable to determine endianess, only LITTLE ENDIAN is supported" )
|
||||
elseif( BIG_ENDIAN )
|
||||
message( FATAL_ERROR "bigendian is not supported" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Test monotonic clock
|
||||
#
|
||||
# CLOCK_MONOTONIC clock for clock_gettime
|
||||
# Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix
|
||||
# compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD
|
||||
# >= 5.1.0, which does not have the posix defines (ref. r11983)) would be
|
||||
# checked but some systems define them even when they do not support it
|
||||
# (ref. bugreport:1003).
|
||||
#
|
||||
message( STATUS "Check for monotonic clock" )
|
||||
find_library( RT_LIBRARY rt )# (optional, rt on Debian)
|
||||
mark_as_advanced( RT_LIBRARY )
|
||||
set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} ${RT_LIBRARY} )
|
||||
file( READ "${CMAKE_SOURCE_DIR}/3rdparty/cmake/tests/HAVE_MONOTONIC_CLOCK.c" _SOURCE )
|
||||
CHECK_C_SOURCE_RUNS( "${_SOURCE}" HAVE_MONOTONIC_CLOCK )
|
||||
if( HAVE_MONOTONIC_CLOCK )
|
||||
message( STATUS "Check for monotonic clock - yes" )
|
||||
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${RT_LIBRARY} )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DHAVE_MONOTONIC_CLOCK" )
|
||||
else()
|
||||
message( STATUS "Check for monotonic clock - no" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Test if function exists:
|
||||
# setrlimit - used to set the socket limit
|
||||
# strnlen - string length with upper scan bound
|
||||
# getpid - process id
|
||||
# gettid - thread id
|
||||
#
|
||||
CHECK_FUNCTION_EXISTS( setrlimit HAVE_SETRLIMIT )
|
||||
CHECK_FUNCTION_EXISTS( strnlen HAVE_STRNLEN )
|
||||
CHECK_FUNCTION_EXISTS( getpid HAVE_GETPID )
|
||||
CHECK_FUNCTION_EXISTS( gettid HAVE_GETTID )
|
||||
foreach( define HAVE_SETRLIMIT HAVE_STRNLEN HAVE_GETPID HAVE_GETTID )
|
||||
if( ${define} )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -D${define}" )
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
||||
#
|
||||
# Use RDTSC instruction as a timing source (time stamp counter on x86 since Pentium) (default=OFF)
|
||||
#
|
||||
# Enable it when you've timing issues. (ex: in conjunction with XEN or Other Virtualization mechanisms)
|
||||
# Please ensure that you've disabled dynamic CPU-Frequencys, such as power saving options.
|
||||
# (On the most modern Dedicated Servers cpufreq is preconfigured, see your distribution's manual how to disable it)
|
||||
#
|
||||
option( ENABLE_RDTSC "use RDTSC instruction as a timing source (default=OFF)" OFF )
|
||||
if( ENABLE_RDTSC )
|
||||
# set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DENABLE_RDTSC" )
|
||||
message( STATUS "Enabled RDTSC as a timing source" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Enable extra debug code (default=OFF)
|
||||
#
|
||||
option( ENABLE_EXTRA_DEBUG_CODE "enable extra debug code (default=OFF)" OFF )
|
||||
if( ENABLE_EXTRA_DEBUG_CODE )
|
||||
# set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DDEBUG" )
|
||||
message( STATUS "Enabled extra DEBUG code" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Enable builtin memory manager (default=default)
|
||||
#
|
||||
set( MEMMGR_OPTIONS "default;yes;no" )
|
||||
set( ENABLE_MEMMGR "default" CACHE STRING "enable builtin memory manager: ${MEMMGR_OPTIONS} (default=default)" )
|
||||
set_property( CACHE ENABLE_MEMMGR PROPERTY STRINGS ${MEMMGR_OPTIONS} )
|
||||
if( ENABLE_MEMMGR STREQUAL "default" )
|
||||
SET (RATHENA_ENABLE_MEMMGR ON)
|
||||
elseif( ENABLE_MEMMGR STREQUAL "yes" )
|
||||
SET (RATHENA_ENABLE_MEMMGR ON)
|
||||
message( STATUS "Enabled the builtin memory manager" )
|
||||
elseif( ENABLE_MEMMGR STREQUAL "no" )
|
||||
SET (RATHENA_ENABLE_MEMMGR OFF)
|
||||
message( STATUS "Disabled the builtin memory manager" )
|
||||
else()
|
||||
message( FATAL_ERROR "invalid option ENABLE_MEMMGR=${ENABLE_MEMMGR} (valid options: ${MEMMGR_OPTIONS})" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Enable memory library (default=system)
|
||||
#
|
||||
set( MEMORY_OPTIONS "system;memwatch;dmalloc;gcollect" )
|
||||
set( ENABLE_MEMORY "system" CACHE STRING "enable memory library: ${MEMORY_OPTIONS} (default=system)" )
|
||||
set_property( CACHE ENABLE_MEMORY PROPERTY STRINGS ${MEMORY_OPTIONS} )
|
||||
if( ENABLE_MEMORY STREQUAL "system" )
|
||||
# use system functions
|
||||
|
||||
elseif( ENABLE_MEMORY STREQUAL "memwatch" )
|
||||
CHECK_INCLUDE_FILE( memwatch.h HAVE_MEMWATCH_H )
|
||||
find_library( MEMWATCH_LIBRARY memwatch )
|
||||
mark_as_advanced( MEMWATCH_LIBRARY )
|
||||
if( HAVE_MEMWATCH_H AND MEMWATCH_LIBRARY )
|
||||
message( STATUS "Adding global library: ${MEMWATCH_LIBRARY}" )
|
||||
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${MEMWATCH_LIBRARY} )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DMEMWATCH" )
|
||||
message( STATUS "Enabled the memory library memwatch" )
|
||||
else()
|
||||
message( FATAL_ERROR "Failed to enable the memory library memwatch" )
|
||||
endif()
|
||||
|
||||
elseif( ENABLE_MEMORY STREQUAL "dmalloc" )
|
||||
CHECK_INCLUDE_FILE( dmalloc.h HAVE_DMALLOC_H )
|
||||
find_library( DMALLOC_LIBRARY dmalloc )
|
||||
mark_as_advanced( DMALLOC_LIBRARY )
|
||||
if( HAVE_DMALLOC_H AND DMALLOC_LIBRARY )
|
||||
message( STATUS "Adding global library: ${DMALLOC_LIBRARY}" )
|
||||
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${DMALLOC_LIBRARY} )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DDMALLOC -DDMALLOC_FUNC_CHECK" )
|
||||
message( STATUS "Enabled the memory library dmalloc" )
|
||||
else()
|
||||
message( FATAL_ERROR "Failed to enable the memory library dmalloc" )
|
||||
endif()
|
||||
|
||||
elseif( ENABLE_MEMORY STREQUAL "gcollect" )
|
||||
CHECK_INCLUDE_FILE( gc.h HAVE_GC_H )
|
||||
find_library( GC_LIBRARY gc )
|
||||
mark_as_advanced( GC_LIBRARY )
|
||||
if( HAVE_GC_H AND GC_LIBRARY )
|
||||
message( STATUS "Adding global library: ${GC_LIBRARY}" )
|
||||
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${GC_LIBRARY} )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DGCOLLECT" )
|
||||
message( STATUS "Enabled the memory library gcollect" )
|
||||
else()
|
||||
message( FATAL_ERROR "Failed to enable the memory library gcollect" )
|
||||
endif()
|
||||
|
||||
else()
|
||||
message( FATAL_ERROR "invalid option ENABLE_MEMORY=${ENABLE_MEMORY} (valid options: ${MEMORY_OPTIONS})" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Enable profiler (default=none)
|
||||
#
|
||||
set( PROFILER_OPTIONS "none;gprof" )
|
||||
set( ENABLE_PROFILER "none" CACHE STRING "enable profiler: ${PROFILER_OPTIONS} (default=none)" )
|
||||
set_property( CACHE ENABLE_PROFILER PROPERTY STRINGS ${PROFILER_OPTIONS} )
|
||||
if( ENABLE_PROFILER STREQUAL "none" )
|
||||
# no profiler
|
||||
|
||||
elseif( ENABLE_PROFILER STREQUAL "gprof" )
|
||||
if( CMAKE_C_COMPILER_ID STREQUAL "GNU" )
|
||||
if( NOT HAVE_GPROF_FLAGS )
|
||||
set_property( CACHE CMAKE_C_FLAGS PROPERTY VALUE "${CMAKE_C_FLAGS} -pg" )
|
||||
set_property( CACHE CMAKE_EXE_LINKER_FLAGS PROPERTY VALUE "${CMAKE_EXE_LINKER_FLAGS} -pg" )
|
||||
set( HAVE_GPROF_FLAGS ON CACHE INTERNAL "" )
|
||||
endif()
|
||||
message( STATUS "Enabled the profiler gprof" )
|
||||
else()
|
||||
message( FATAL_ERROR "Failed to enable the profiler gprof - not GNU" )
|
||||
endif()
|
||||
|
||||
else()
|
||||
message( FATAL_ERROR "invalid option ENABLE_PROFILER=${ENABLE_PROFILER} (valid options: ${PROFILER_OPTIONS})" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Enable extra buildbot code (default=OFF)
|
||||
#
|
||||
option( ENABLE_EXTRA_BUILDBOT_CODE "enable extra buildbot code (default=OFF)" OFF )
|
||||
if( ENABLE_EXTRA_BUILDBOT_CODE )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DBUILDBOT" )
|
||||
message( STATUS "Enabled extra BUILDBOT code" )
|
||||
endif()
|
||||
|
||||
|
||||
#####################################################################
|
||||
# package stuff
|
||||
#
|
||||
set( CPACK_PACKAGE_NAME "rAthena" )
|
||||
set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "MMORPG server package" )
|
||||
set( CPACK_PACKAGE_VERSION ${SVNVERSION} )
|
||||
set( CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE )
|
||||
#set( CPACK_MONOLITHIC_INSTALL ON )
|
||||
include( CPACK OPTIONAL RESULT_VARIABLE HAVE_CPACK )
|
||||
if( HAVE_CPACK )
|
||||
option( WITH_CPACK "enable building packages with CPack ('package' target)" ON )
|
||||
endif()
|
||||
if( NOT WITH_CPACK )
|
||||
# empty replacements
|
||||
macro( cpack_add_component_group )
|
||||
endmacro()
|
||||
macro( cpack_add_component )
|
||||
endmacro()
|
||||
message( STATUS "Disabled package creation" )
|
||||
endif()
|
||||
|
||||
set( Runtime "Runtime files" CACHE INTERNAL "" )
|
||||
set( Runtime_base "configurations, dbs, npcs, docs, ..." CACHE INTERNAL "" )
|
||||
set( Runtime_templates "conf/import and save (generated from conf/import-tmpl and save-tmpl)" CACHE INTERNAL "" )
|
||||
cpack_add_component_group( Runtime DESCRIPTION ${Runtime} DISPLAY_NAME "Runtime" )
|
||||
cpack_add_component( Runtime_base DESCRIPTION ${Runtime_base} DISPLAY_NAME "Base files" GROUP Runtime )
|
||||
cpack_add_component( Runtime_templates DESCRIPTION ${Runtime_templates} DISPLAY_NAME "Base templates" GROUP Runtime )
|
||||
|
||||
set( Development "Development files" CACHE INTERNAL "" )
|
||||
set( Development_base "projects, 3rdparty, sources, templates" CACHE INTERNAL "" )
|
||||
cpack_add_component_group( Development DESCRIPTION ${Development} DISPLAY_NAME "Development" )
|
||||
cpack_add_component( Development_base DESCRIPTION ${Development_base} DISPLAY_NAME "Base files" GROUP Development )
|
||||
|
||||
|
||||
#
|
||||
# install stuff
|
||||
#
|
||||
option( INSTALL_COMPONENT_RUNTIME "install/package files needed to run the project" ON )
|
||||
option( INSTALL_COMPONENT_DEVELOPMENT "install/package files needed to build the project" OFF )
|
||||
option( INSTALL_TO_PATH "copy files to INSTALL_PATH" OFF )
|
||||
option( INSTALL_TO_SOURCE "copy files to source directory, skips what is already there (${CMAKE_CURRENT_SOURCE_DIR})" OFF )
|
||||
option( INSTALL_TO_SUBDIR "copy files to subdirectory (${CMAKE_CURRENT_BINARY_DIR}/install)" OFF )
|
||||
set( INSTALL_PATH "${CMAKE_INSTALL_PREFIX}" CACHE STRING "install path (only used when INSTALL_TO_PATH is set)" )
|
||||
mark_as_advanced( CMAKE_INSTALL_PREFIX )
|
||||
if( INSTALL_TO_PATH AND NOT ("${INSTALL_TO}" STREQUAL "path") )# changed to path
|
||||
set_property( CACHE INSTALL_TO_SOURCE INSTALL_TO_SUBDIR PROPERTY VALUE OFF )
|
||||
elseif( INSTALL_TO_SOURCE AND NOT ("${INSTALL_TO}" STREQUAL "source") )# changed to source
|
||||
set_property( CACHE INSTALL_TO_PATH INSTALL_TO_SUBDIR PROPERTY VALUE OFF )
|
||||
elseif( INSTALL_TO_SUBDIR AND NOT ("${INSTALL_TO}" STREQUAL "subdir") )# changed to subdir
|
||||
set_property( CACHE INSTALL_TO_PATH INSTALL_TO_SOURCE PROPERTY VALUE OFF )
|
||||
elseif( NOT INSTALL_TO_PATH AND NOT INSTALL_TO_SOURCE AND NOT INSTALL_TO_SUBDIR )# default
|
||||
set_property( CACHE INSTALL_TO_SUBDIR PROPERTY VALUE ON )
|
||||
endif()
|
||||
if( INSTALL_TO_PATH )
|
||||
set( INSTALL_TO "path" CACHE INTERNAL "" )
|
||||
set_property( CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${INSTALL_PATH}" )
|
||||
elseif( INSTALL_TO_SOURCE )
|
||||
set( INSTALL_TO "source" CACHE INTERNAL "" )
|
||||
set_property( CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${CMAKE_CURRENT_SOURCE_DIR}" )
|
||||
elseif( INSTALL_TO_SUBDIR )
|
||||
set( INSTALL_TO "subdir" CACHE INTERNAL "" )
|
||||
set_property( CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${CMAKE_CURRENT_BINARY_DIR}/install" )
|
||||
endif()
|
||||
set( SVN_FOLDER_PATTERN "[\\.]svn" CACHE STRING "pattern of svn folder that we exclude from instalations" )
|
||||
mark_as_advanced( SVN_FOLDER_PATTERN )
|
||||
set( DEVELOPMENT_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/configure"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/configure.in"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/rAthena.sln"
|
||||
)
|
||||
set( DEVELOPMENT_DIRECTORIES
|
||||
"3rdparty"
|
||||
"conf/import-tmpl"
|
||||
"conf/msg_conf/import-tmpl"
|
||||
"db/import-tmpl"
|
||||
"src"
|
||||
)
|
||||
set( RUNTIME_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/athena-start"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/README.md"
|
||||
)
|
||||
if (WIN32)
|
||||
set (RUNTIME_FILES
|
||||
${RUNTIME_FILES}
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/dbghelp.dll"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/libmysql.dll"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pcre3.dll"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/zlib1.dll"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tools/charserv.bat"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tools/logserv.bat"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tools/mapserv.bat"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tools/runserver.bat"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tools/serv.bat"
|
||||
)
|
||||
endif(WIN32)
|
||||
|
||||
set( RUNTIME_DIRECTORIES
|
||||
"conf"
|
||||
"db"
|
||||
"doc"
|
||||
"log"
|
||||
"npc"
|
||||
"sql-files"
|
||||
"tools"
|
||||
)
|
||||
if( INSTALL_TO_SOURCE )# skip, already in the source dir
|
||||
else()
|
||||
if( INSTALL_COMPONENT_RUNTIME )
|
||||
install( FILES ${RUNTIME_FILES}
|
||||
DESTINATION "."
|
||||
COMPONENT Runtime_base )
|
||||
foreach( DIR IN ITEMS ${RUNTIME_DIRECTORIES} )
|
||||
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${DIR}/" )
|
||||
install( DIRECTORY "${DIR}/"
|
||||
DESTINATION "${DIR}"
|
||||
COMPONENT Runtime_base
|
||||
PATTERN ${SVN_FOLDER_PATTERN} EXCLUDE
|
||||
PATTERN "conf/import-tmpl" EXCLUDE )
|
||||
else()
|
||||
# create empty directory
|
||||
install( CODE "file(MAKE_DIRECTORY \"\${ENV}\${CMAKE_INSTALL_PREFIX}/${DIR}\")"
|
||||
COMPONENT Runtime_base )
|
||||
endif()
|
||||
endforeach()
|
||||
endif( INSTALL_COMPONENT_RUNTIME )
|
||||
if( INSTALL_COMPONENT_DEVELOPMENT )
|
||||
install( FILES ${DEVELOPMENT_FILES}
|
||||
DESTINATION "."
|
||||
COMPONENT Development_base )
|
||||
foreach( DIR IN ITEMS ${DEVELOPMENT_DIRECTORIES} )
|
||||
install( DIRECTORY "${DIR}/"
|
||||
DESTINATION "${DIR}"
|
||||
COMPONENT Development_base
|
||||
PATTERN ${SVN_FOLDER_PATTERN} EXCLUDE )
|
||||
endforeach()
|
||||
endif( INSTALL_COMPONENT_DEVELOPMENT )
|
||||
endif()
|
||||
if( INSTALL_COMPONENT_RUNTIME )
|
||||
# templates
|
||||
set( _TEMPLATES
|
||||
"conf/import-tmpl" "conf/import"
|
||||
"conf/msg_conf/import-tmpl" "conf/msg_conf/import"
|
||||
"db/import-tmpl" "db/import"
|
||||
)
|
||||
set( INSTALL_TEMPLATES_FILE "${CMAKE_CURRENT_BINARY_DIR}/InstallTemplates.cmake" )
|
||||
file( WRITE "${INSTALL_TEMPLATES_FILE}"
|
||||
"macro( INSTALL_TEMPLATE _SRC _DST )\n"
|
||||
" set( SRC \"${CMAKE_CURRENT_SOURCE_DIR}/\${_SRC}\" )\n"
|
||||
" set( DST \"\${CMAKE_INSTALL_PREFIX}/\${_DST}\" )\n"
|
||||
" if( EXISTS \"\${DST}\" )\n"
|
||||
" message( \"-- Already exists: \${DST}\" )\n"
|
||||
" else()\n"
|
||||
" message( \"-- Installing template: \${DST}\" )\n"
|
||||
" execute_process( COMMAND \"${CMAKE_COMMAND}\" -E copy \"\${SRC}\" \"\${DST}\" )\n"
|
||||
" endif()\n"
|
||||
"endmacro()\n"
|
||||
)
|
||||
while( _TEMPLATES )
|
||||
list( GET _TEMPLATES 0 _SRC )
|
||||
list( GET _TEMPLATES 1 _DST )
|
||||
list( REMOVE_AT _TEMPLATES 0 1 )
|
||||
if( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_SRC}" )
|
||||
file( GLOB _PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${_SRC}/*" )
|
||||
foreach( _PATH IN ITEMS ${_PATHS} )
|
||||
string( REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/${_SRC}/" "" _PATH "${_PATH}" )
|
||||
if( NOT "${_PATH}" MATCHES "${SVN_FOLDER_PATTERN}" )
|
||||
list( APPEND _TEMPLATES "${_SRC}/${_PATH}" "${_DST}/${_PATH}" )
|
||||
endif()
|
||||
endforeach()
|
||||
else()
|
||||
file( APPEND "${INSTALL_TEMPLATES_FILE}" "INSTALL_TEMPLATE( \"${_SRC}\" \"${_DST}\" )\n" )
|
||||
endif()
|
||||
endwhile()
|
||||
install( SCRIPT "${INSTALL_TEMPLATES_FILE}"
|
||||
COMPONENT Runtime_templates )
|
||||
endif( INSTALL_COMPONENT_RUNTIME )
|
||||
|
||||
|
||||
#
|
||||
# sources
|
||||
#
|
||||
set( TARGET_LIST CACHE INTERNAL "" )
|
||||
add_subdirectory( 3rdparty )
|
||||
add_subdirectory( src )
|
||||
|
||||
|
||||
#####################################################################
|
||||
# final checks and warnings
|
||||
#
|
||||
|
||||
list( LENGTH TARGET_LIST _LEN )
|
||||
if( _LEN EQUAL 0 )
|
||||
message( FATAL_ERROR "no targets available" )
|
||||
endif()
|
||||
message( STATUS "Available targets:" )
|
||||
foreach( _TARGET IN ITEMS ${TARGET_LIST} )
|
||||
message( STATUS "\t${_TARGET}" )
|
||||
endforeach()
|
||||
626
CMakeLists.txt
626
CMakeLists.txt
@ -1,630 +1,62 @@
|
||||
#####################################################################
|
||||
#
|
||||
# "Getting Started with CMake", a tutorial video by Eric Wing.
|
||||
# Part 1 of 6: http://www.youtube.com/watch?v=CLvZTyji_Uw
|
||||
# Part 2 of 6: http://www.youtube.com/watch?v=gUW-RrRQjEg
|
||||
# Part 3 of 6: http://www.youtube.com/watch?v=sz6cPhbuTk4
|
||||
# Part 4 of 6: http://www.youtube.com/watch?v=JICZOkyNXbg
|
||||
# Part 5 of 6: http://www.youtube.com/watch?v=lAiuLHy4dCk
|
||||
# Part 6 of 6: http://www.youtube.com/watch?v=fAtJNzDZdH8
|
||||
#
|
||||
# You can use notepad++ for syntax highlighting.
|
||||
# Naming conventions:
|
||||
# WITH_* : option to use an external package or not
|
||||
# ENABLE_* : option to use an internal feature/code or not
|
||||
# HAVE_* : internal variable indicating if we have and are using something
|
||||
#
|
||||
# Maintainers: Flavio J. Saraiva (feel free to send complaints or suggestions)
|
||||
# flaviojs @ rAthena forum/irc
|
||||
# flaviojs2005 \A-T/ gmail <D.o,T> com
|
||||
# lightaisme \A-T/ gmail <D.o,T> com
|
||||
#
|
||||
#####################################################################
|
||||
cmake_minimum_required(VERSION 3.11)
|
||||
|
||||
|
||||
#cmake_minimum_required( VERSION 2.8.4 )
|
||||
# Functional changes from 2.8.3 to 2.8.4:
|
||||
# string(SUBSTRING) works with length -1 as "rest of string"
|
||||
# changes to some CPack generators
|
||||
# CYGWIN no longer defines WIN32
|
||||
# CMP0017: Prefer files from the CMake module directory when including from there.
|
||||
# Update to 3.1 for CMAKE_CXX_STANDARD cross support definition
|
||||
set( CMAKE_LEGACY_CYGWIN_WIN32 0 )
|
||||
cmake_minimum_required( VERSION 3.1 )
|
||||
project(rAthena)
|
||||
if( CYGWIN )
|
||||
unset( WIN32 )
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD 14) # C++14...
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
|
||||
#set(CMAKE_CXX_EXTENSIONS OFF) #...without compiler extensions like gnu++11
|
||||
|
||||
#actually this might be misleading for arm...
|
||||
if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
|
||||
set(architecture x86)
|
||||
elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
||||
set(architecture x64)
|
||||
else()
|
||||
message( FATAL_ERROR "unexpected architecture (CMAKE_SIZEOF_VOID_P is ${CMAKE_SIZEOF_VOID_P})" )
|
||||
endif()
|
||||
# Configure CMake Modules
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cmake")
|
||||
|
||||
|
||||
# options
|
||||
set(PACKETVER 20211103 CACHE STRING "Sets the PACKETVER define of the servers (see src/common/mmo.hpp)")
|
||||
option(ENABLE_PRERENEWAL "Whether or not to enable Pre-renewal (default=OFF)" OFF)
|
||||
option(ENABLE_WEB_SERVER "Build web-server (default=ON)" ON)
|
||||
option(ENABLE_RDTSC "Enable RDTSC instruction as a timing source (default=OFF)" OFF)
|
||||
option(ENABLE_EXTRA_DEBUG_CODE "Enable extra debug code (default=OFF)" OFF)
|
||||
option(ENABLE_MEMMGR "Enable memory manager (default=ON)" ON)
|
||||
# TODO(vstumpf): If no one uses this, we can just remove it
|
||||
# set(ENABLE_MEMORY "system" CACHE STRING "Enable memory library (default=system)")
|
||||
option(ENABLE_PROFILER "Enable profiler (default=OFF)" OFF)
|
||||
option(ENABLE_EXTRA_BUILDBOT_CODE "Enable extra buildbot code (default=OFF)" OFF)
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/${suffixInstallStr})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/${suffixInstallStr})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(CMAKE_C_CREATE_SHARED_LIBRARY)
|
||||
set(CMAKE_CXX_CREATE_SHARED_LIBRARY)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
set(CMAKE_RELEASE_POSTFIX "r")
|
||||
|
||||
# Set a default build type if none was specified
|
||||
set(default_build_type "Release")
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
|
||||
STRING "Choose the type of build." FORCE)
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel" FORCE)
|
||||
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
|
||||
endif()
|
||||
|
||||
#
|
||||
# Prevent building in the source directory by default
|
||||
#
|
||||
option( ALLOW_SAME_DIRECTORY "Allow CMake to build in the source directory." OFF )
|
||||
if( ALLOW_SAME_DIRECTORY )
|
||||
elseif( "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}" )
|
||||
if( CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR )
|
||||
message( FATAL_ERROR
|
||||
"Do not use the source directory to build your files, instead delete CMakeCache.txt, create a separate folder and build there.\n"
|
||||
"Example: (build in subdir 'build' and install to source dir)\n"
|
||||
" rm -f CMakeCache.txt\n"
|
||||
" mkdir build\n"
|
||||
" cd build\n"
|
||||
" cmake -G\"Unix Makefiles\" -DINSTALL_TO_SOURCE=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ..\n"
|
||||
" cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..\n"
|
||||
" make install\n"
|
||||
" cd ..\n"
|
||||
" rm -rf build\n"
|
||||
"To skip this check, set ALLOW_SAME_DIRECTORY to ON (-DALLOW_SAME_DIRECTORY=ON)" )
|
||||
" rm -rf build\n")
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Global stuff
|
||||
#
|
||||
set( GLOBAL_LIBRARIES ${LINK_LIBRARIES} CACHE INTERNAL "" )# list (comma separated values)
|
||||
set( GLOBAL_INCLUDE_DIRS ${INCLUDE_DIRECTORIES} CACHE INTERNAL "" )# list (comma separated values)
|
||||
set( GLOBAL_DEFINITIONS ${COMPILE_DEFINITIONS} CACHE INTERNAL "" )# string (space separated values -DFOO=bar)
|
||||
mark_as_advanced( GLOBAL_LIBRARIES GLOBAL_INCLUDE_DIRS GLOBAL_DEFINITIONS )
|
||||
if(WIN32)
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DFD_SETSIZE=4096" )
|
||||
endif()
|
||||
if( MSVC )
|
||||
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} "oldnames.lib" "ws2_32.lib" )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE" )
|
||||
endif()
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC)
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -fno-strict-aliasing" )
|
||||
#set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -O2" ); #need more test to enable this
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# 3rd party
|
||||
#
|
||||
set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cmake CACHE INTERNAL "" )
|
||||
include( CheckCSourceCompiles )
|
||||
include( CheckCSourceRuns )
|
||||
include( CheckIncludeFile )
|
||||
include( CheckFunctionExists )
|
||||
include( FindFunctionLibrary )
|
||||
include( TestBigEndian )
|
||||
# Configure C++ Standard
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
|
||||
#
|
||||
# PACKETVER
|
||||
#
|
||||
set( PACKETVER CACHE STRING "Sets the PACKETVER define of the servers. (see src/common/mmo.h)" )
|
||||
if( PACKETVER )
|
||||
list( APPEND GLOBAL_DEFINITIONS PACKETVER=${PACKETVER} )
|
||||
endif()
|
||||
# Set build directories
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/${suffixInstallStr})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/${suffixInstallStr})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
|
||||
#
|
||||
# Find git
|
||||
#
|
||||
message( STATUS "Detecting git" )
|
||||
find_package(Git)
|
||||
if(GIT_FOUND)
|
||||
if(GIT_VERSION_STRING)
|
||||
message(STATUS "Found git : ${GIT_EXECUTABLE} version (${GIT_VERSION_STRING})")
|
||||
else()
|
||||
message(STATUS "Found git : ${GIT_EXECUTABLE}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(GetGitVersion)
|
||||
get_git_version()
|
||||
|
||||
#include(GetSvnVersion)
|
||||
#get_svn_version(SVN_VERSION)
|
||||
#message( STATUS "SVN_VERSION: ${SVN_VERSION}" )
|
||||
|
||||
|
||||
#
|
||||
# threads
|
||||
#
|
||||
message( STATUS "Detecting threads library" )
|
||||
set( CMAKE_THREAD_PREFER_PTHREAD 1 )
|
||||
find_package(Threads REQUIRED)
|
||||
if( CMAKE_THREAD_LIBS_INIT )
|
||||
message( STATUS "Adding global library: ${CMAKE_THREAD_LIBS_INIT}" )
|
||||
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
|
||||
endif()
|
||||
message( STATUS "Detecting threads library - done" )
|
||||
|
||||
message( STATUS "Check if supporting Thread local storage (TLS)" )
|
||||
file( READ "${CMAKE_SOURCE_DIR}/3rdparty/cmake/tests/HAVE_TLS.c" _SOURCE )
|
||||
CHECK_C_SOURCE_RUNS( "${_SOURCE}" HAVE_TLS )
|
||||
if( HAVE_TLS )
|
||||
message( STATUS "Check for TLS- yes" )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DHAVE_TLS" )
|
||||
else()
|
||||
message( STATUS "Check for TLS - no" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# math library (FreeBSD/Linux/Solaris)
|
||||
#
|
||||
if( NOT WIN32 )
|
||||
message( STATUS "Detecting math library (m)" )
|
||||
CHECK_INCLUDE_FILE( math.h HAVE_MATH_H )
|
||||
if( NOT HAVE_MATH_H )
|
||||
message( FATAL_ERROR "math.h not found" )
|
||||
endif()
|
||||
set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} )
|
||||
find_function_library( floor FUNCTION_FLOOR_LIBRARIES m )
|
||||
if( FUNCTION_FLOOR_LIBRARIES )
|
||||
message( STATUS "Adding global library: ${FUNCTION_FLOOR_LIBRARIES}" )
|
||||
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${FUNCTION_FLOOR_LIBRARIES} )
|
||||
endif()
|
||||
message( STATUS "Detecting math library (m) - done" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# dynamic loading library (Linux)
|
||||
#
|
||||
if( NOT WIN32 )
|
||||
message( STATUS "Detecting dynamic loading library (dl)" )
|
||||
set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} )
|
||||
find_function_library( dlopen FUNCTION_DLOPEN_LIBRARIES dl )
|
||||
if( FUNCTION_DLOPEN_LIBRARIES )
|
||||
message( STATUS "Adding global library: ${FUNCTION_DLOPEN_LIBRARIES}" )
|
||||
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${FUNCTION_DLOPEN_LIBRARIES} )
|
||||
endif()
|
||||
message( STATUS "Detecting dynamic loading library (dl) - done" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# networking library (Solaris/MinGW)
|
||||
#
|
||||
if( NOT MSVC )
|
||||
message( STATUS "Detecting networking library (socket/nsl/ws2_32)" )
|
||||
#set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} )
|
||||
#find_function_library( bind FUNCTION_BIND_LIBRARIES socket ws2_32 )
|
||||
#if( FUNCTION_BIND_LIBRARIES )
|
||||
# message( STATUS "Adding global library: ${FUNCTION_BIND_LIBRARIES}" )
|
||||
# set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${FUNCTION_BIND_LIBRARIES} )
|
||||
#endif()
|
||||
set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} )
|
||||
find_function_library( gethostbyname FUNCTION_GETHOSTBYNAME_LIBRARIES nsl )
|
||||
if( FUNCTION_GETHOSTBYNAME_LIBRARIES )
|
||||
message( STATUS "Adding global library: ${FUNCTION_GETHOSTBYNAME_LIBRARIES}" )
|
||||
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${FUNCTION_GETHOSTBYNAME_LIBRARIES} )
|
||||
endif()
|
||||
message( STATUS "Detecting networking library (socket/nsl/ws2_32) - done" )
|
||||
endif()
|
||||
|
||||
#
|
||||
# enable web server?
|
||||
#
|
||||
option( ENABLE_WEB_SERVER "Build web-server (default=ON)" ON )
|
||||
|
||||
#
|
||||
# Test for big endian
|
||||
#
|
||||
TEST_BIG_ENDIAN( BIG_ENDIAN )
|
||||
if( NOT DEFINED BIG_ENDIAN )
|
||||
message( WARNING "unable to determine endianess, only LITTLE ENDIAN is supported" )
|
||||
elseif( BIG_ENDIAN )
|
||||
message( FATAL_ERROR "bigendian is not supported" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Test monotonic clock
|
||||
#
|
||||
# CLOCK_MONOTONIC clock for clock_gettime
|
||||
# Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix
|
||||
# compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD
|
||||
# >= 5.1.0, which does not have the posix defines (ref. r11983)) would be
|
||||
# checked but some systems define them even when they do not support it
|
||||
# (ref. bugreport:1003).
|
||||
#
|
||||
message( STATUS "Check for monotonic clock" )
|
||||
find_library( RT_LIBRARY rt )# (optional, rt on Debian)
|
||||
mark_as_advanced( RT_LIBRARY )
|
||||
set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} ${RT_LIBRARY} )
|
||||
file( READ "${CMAKE_SOURCE_DIR}/3rdparty/cmake/tests/HAVE_MONOTONIC_CLOCK.c" _SOURCE )
|
||||
CHECK_C_SOURCE_RUNS( "${_SOURCE}" HAVE_MONOTONIC_CLOCK )
|
||||
if( HAVE_MONOTONIC_CLOCK )
|
||||
message( STATUS "Check for monotonic clock - yes" )
|
||||
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${RT_LIBRARY} )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DHAVE_MONOTONIC_CLOCK" )
|
||||
else()
|
||||
message( STATUS "Check for monotonic clock - no" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Test if function exists:
|
||||
# setrlimit - used to set the socket limit
|
||||
# strnlen - string length with upper scan bound
|
||||
# getpid - process id
|
||||
# gettid - thread id
|
||||
#
|
||||
CHECK_FUNCTION_EXISTS( setrlimit HAVE_SETRLIMIT )
|
||||
CHECK_FUNCTION_EXISTS( strnlen HAVE_STRNLEN )
|
||||
CHECK_FUNCTION_EXISTS( getpid HAVE_GETPID )
|
||||
CHECK_FUNCTION_EXISTS( gettid HAVE_GETTID )
|
||||
foreach( define HAVE_SETRLIMIT HAVE_STRNLEN HAVE_GETPID HAVE_GETTID )
|
||||
if( ${define} )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -D${define}" )
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
||||
#
|
||||
# Use RDTSC instruction as a timing source (time stamp counter on x86 since Pentium) (default=OFF)
|
||||
#
|
||||
# Enable it when you've timing issues. (ex: in conjunction with XEN or Other Virtualization mechanisms)
|
||||
# Please ensure that you've disabled dynamic CPU-Frequencys, such as power saving options.
|
||||
# (On the most modern Dedicated Servers cpufreq is preconfigured, see your distribution's manual how to disable it)
|
||||
#
|
||||
option( ENABLE_RDTSC "use RDTSC instruction as a timing source (default=OFF)" OFF )
|
||||
if( ENABLE_RDTSC )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DENABLE_RDTSC" )
|
||||
message( STATUS "Enabled RDTSC as a timing source" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Enable extra debug code (default=OFF)
|
||||
#
|
||||
option( ENABLE_EXTRA_DEBUG_CODE "enable extra debug code (default=OFF)" OFF )
|
||||
if( ENABLE_EXTRA_DEBUG_CODE )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DDEBUG" )
|
||||
message( STATUS "Enabled extra DEBUG code" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Enable EPOLL (default=OFF)
|
||||
# Only for Linux
|
||||
#
|
||||
option( ENABLE_EXTRA_SOCKET_POLL "enable SOCKET_EPOLL (default=OFF)" OFF )
|
||||
if( ENABLE_EXTRA_SOCKET_POLL )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DSOCKET_EPOLL" )
|
||||
message( STATUS "Enabled SOCKET_EPOLL" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Enable builtin memory manager (default=default)
|
||||
#
|
||||
set( MEMMGR_OPTIONS "default;yes;no" )
|
||||
set( ENABLE_MEMMGR "default" CACHE STRING "enable builtin memory manager: ${MEMMGR_OPTIONS} (default=default)" )
|
||||
set_property( CACHE ENABLE_MEMMGR PROPERTY STRINGS ${MEMMGR_OPTIONS} )
|
||||
if( ENABLE_MEMMGR STREQUAL "default" )
|
||||
# use source code default
|
||||
elseif( ENABLE_MEMMGR STREQUAL "yes" )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DUSE_MEMMGR" )
|
||||
message( STATUS "Enabled the builtin memory manager" )
|
||||
elseif( ENABLE_MEMMGR STREQUAL "no" )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DNO_MEMMGR" )
|
||||
message( STATUS "Disabled the builtin memory manager" )
|
||||
else()
|
||||
message( FATAL_ERROR "invalid option ENABLE_MEMMGR=${ENABLE_MEMMGR} (valid options: ${MEMMGR_OPTIONS})" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Enable memory library (default=system)
|
||||
#
|
||||
set( MEMORY_OPTIONS "system;memwatch;dmalloc;gcollect" )
|
||||
set( ENABLE_MEMORY "system" CACHE STRING "enable memory library: ${MEMORY_OPTIONS} (default=system)" )
|
||||
set_property( CACHE ENABLE_MEMORY PROPERTY STRINGS ${MEMORY_OPTIONS} )
|
||||
if( ENABLE_MEMORY STREQUAL "system" )
|
||||
# use system functions
|
||||
|
||||
elseif( ENABLE_MEMORY STREQUAL "memwatch" )
|
||||
CHECK_INCLUDE_FILE( memwatch.h HAVE_MEMWATCH_H )
|
||||
find_library( MEMWATCH_LIBRARY memwatch )
|
||||
mark_as_advanced( MEMWATCH_LIBRARY )
|
||||
if( HAVE_MEMWATCH_H AND MEMWATCH_LIBRARY )
|
||||
message( STATUS "Adding global library: ${MEMWATCH_LIBRARY}" )
|
||||
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${MEMWATCH_LIBRARY} )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DMEMWATCH" )
|
||||
message( STATUS "Enabled the memory library memwatch" )
|
||||
else()
|
||||
message( FATAL_ERROR "Failed to enable the memory library memwatch" )
|
||||
endif()
|
||||
|
||||
elseif( ENABLE_MEMORY STREQUAL "dmalloc" )
|
||||
CHECK_INCLUDE_FILE( dmalloc.h HAVE_DMALLOC_H )
|
||||
find_library( DMALLOC_LIBRARY dmalloc )
|
||||
mark_as_advanced( DMALLOC_LIBRARY )
|
||||
if( HAVE_DMALLOC_H AND DMALLOC_LIBRARY )
|
||||
message( STATUS "Adding global library: ${DMALLOC_LIBRARY}" )
|
||||
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${DMALLOC_LIBRARY} )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DDMALLOC -DDMALLOC_FUNC_CHECK" )
|
||||
message( STATUS "Enabled the memory library dmalloc" )
|
||||
else()
|
||||
message( FATAL_ERROR "Failed to enable the memory library dmalloc" )
|
||||
endif()
|
||||
|
||||
elseif( ENABLE_MEMORY STREQUAL "gcollect" )
|
||||
CHECK_INCLUDE_FILE( gc.h HAVE_GC_H )
|
||||
find_library( GC_LIBRARY gc )
|
||||
mark_as_advanced( GC_LIBRARY )
|
||||
if( HAVE_GC_H AND GC_LIBRARY )
|
||||
message( STATUS "Adding global library: ${GC_LIBRARY}" )
|
||||
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${GC_LIBRARY} )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DGCOLLECT" )
|
||||
message( STATUS "Enabled the memory library gcollect" )
|
||||
else()
|
||||
message( FATAL_ERROR "Failed to enable the memory library gcollect" )
|
||||
endif()
|
||||
|
||||
else()
|
||||
message( FATAL_ERROR "invalid option ENABLE_MEMORY=${ENABLE_MEMORY} (valid options: ${MEMORY_OPTIONS})" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Enable profiler (default=none)
|
||||
#
|
||||
set( PROFILER_OPTIONS "none;gprof" )
|
||||
set( ENABLE_PROFILER "none" CACHE STRING "enable profiler: ${PROFILER_OPTIONS} (default=none)" )
|
||||
set_property( CACHE ENABLE_PROFILER PROPERTY STRINGS ${PROFILER_OPTIONS} )
|
||||
if( ENABLE_PROFILER STREQUAL "none" )
|
||||
# no profiler
|
||||
|
||||
elseif( ENABLE_PROFILER STREQUAL "gprof" )
|
||||
if( CMAKE_C_COMPILER_ID STREQUAL "GNU" )
|
||||
if( NOT HAVE_GPROF_FLAGS )
|
||||
set_property( CACHE CMAKE_C_FLAGS PROPERTY VALUE "${CMAKE_C_FLAGS} -pg" )
|
||||
set_property( CACHE CMAKE_EXE_LINKER_FLAGS PROPERTY VALUE "${CMAKE_EXE_LINKER_FLAGS} -pg" )
|
||||
set( HAVE_GPROF_FLAGS ON CACHE INTERNAL "" )
|
||||
endif()
|
||||
message( STATUS "Enabled the profiler gprof" )
|
||||
else()
|
||||
message( FATAL_ERROR "Failed to enable the profiler gprof - not GNU" )
|
||||
endif()
|
||||
|
||||
else()
|
||||
message( FATAL_ERROR "invalid option ENABLE_PROFILER=${ENABLE_PROFILER} (valid options: ${PROFILER_OPTIONS})" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Enable extra buildbot code (default=OFF)
|
||||
#
|
||||
option( ENABLE_EXTRA_BUILDBOT_CODE "enable extra buildbot code (default=OFF)" OFF )
|
||||
if( ENABLE_EXTRA_BUILDBOT_CODE )
|
||||
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DBUILDBOT" )
|
||||
message( STATUS "Enabled extra BUILDBOT code" )
|
||||
endif()
|
||||
|
||||
|
||||
#####################################################################
|
||||
# package stuff
|
||||
#
|
||||
set( CPACK_PACKAGE_NAME "rAthena" )
|
||||
set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "MMORPG server package" )
|
||||
set( CPACK_PACKAGE_VERSION ${SVNVERSION} )
|
||||
set( CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE )
|
||||
#set( CPACK_MONOLITHIC_INSTALL ON )
|
||||
include( CPACK OPTIONAL RESULT_VARIABLE HAVE_CPACK )
|
||||
if( HAVE_CPACK )
|
||||
option( WITH_CPACK "enable building packages with CPack ('package' target)" ON )
|
||||
endif()
|
||||
if( NOT WITH_CPACK )
|
||||
# empty replacements
|
||||
macro( cpack_add_component_group )
|
||||
endmacro()
|
||||
macro( cpack_add_component )
|
||||
endmacro()
|
||||
message( STATUS "Disabled package creation" )
|
||||
endif()
|
||||
|
||||
set( Runtime "Runtime files" CACHE INTERNAL "" )
|
||||
set( Runtime_base "configurations, dbs, npcs, docs, ..." CACHE INTERNAL "" )
|
||||
set( Runtime_templates "conf/import and save (generated from conf/import-tmpl and save-tmpl)" CACHE INTERNAL "" )
|
||||
cpack_add_component_group( Runtime DESCRIPTION ${Runtime} DISPLAY_NAME "Runtime" )
|
||||
cpack_add_component( Runtime_base DESCRIPTION ${Runtime_base} DISPLAY_NAME "Base files" GROUP Runtime )
|
||||
cpack_add_component( Runtime_templates DESCRIPTION ${Runtime_templates} DISPLAY_NAME "Base templates" GROUP Runtime )
|
||||
|
||||
set( Development "Development files" CACHE INTERNAL "" )
|
||||
set( Development_base "projects, 3rdparty, sources, templates" CACHE INTERNAL "" )
|
||||
cpack_add_component_group( Development DESCRIPTION ${Development} DISPLAY_NAME "Development" )
|
||||
cpack_add_component( Development_base DESCRIPTION ${Development_base} DISPLAY_NAME "Base files" GROUP Development )
|
||||
|
||||
|
||||
#
|
||||
# install stuff
|
||||
#
|
||||
option( INSTALL_COMPONENT_RUNTIME "install/package files needed to run the project" ON )
|
||||
option( INSTALL_COMPONENT_DEVELOPMENT "install/package files needed to build the project" OFF )
|
||||
option( INSTALL_TO_PATH "copy files to INSTALL_PATH" OFF )
|
||||
option( INSTALL_TO_SOURCE "copy files to source directory, skips what is already there (${CMAKE_CURRENT_SOURCE_DIR})" OFF )
|
||||
option( INSTALL_TO_SUBDIR "copy files to subdirectory (${CMAKE_CURRENT_BINARY_DIR}/install)" OFF )
|
||||
set( INSTALL_PATH "${CMAKE_INSTALL_PREFIX}" CACHE STRING "install path (only used when INSTALL_TO_PATH is set)" )
|
||||
mark_as_advanced( CMAKE_INSTALL_PREFIX )
|
||||
if( INSTALL_TO_PATH AND NOT ("${INSTALL_TO}" STREQUAL "path") )# changed to path
|
||||
set_property( CACHE INSTALL_TO_SOURCE INSTALL_TO_SUBDIR PROPERTY VALUE OFF )
|
||||
elseif( INSTALL_TO_SOURCE AND NOT ("${INSTALL_TO}" STREQUAL "source") )# changed to source
|
||||
set_property( CACHE INSTALL_TO_PATH INSTALL_TO_SUBDIR PROPERTY VALUE OFF )
|
||||
elseif( INSTALL_TO_SUBDIR AND NOT ("${INSTALL_TO}" STREQUAL "subdir") )# changed to subdir
|
||||
set_property( CACHE INSTALL_TO_PATH INSTALL_TO_SOURCE PROPERTY VALUE OFF )
|
||||
elseif( NOT INSTALL_TO_PATH AND NOT INSTALL_TO_SOURCE AND NOT INSTALL_TO_SUBDIR )# default
|
||||
set_property( CACHE INSTALL_TO_SUBDIR PROPERTY VALUE ON )
|
||||
endif()
|
||||
if( INSTALL_TO_PATH )
|
||||
set( INSTALL_TO "path" CACHE INTERNAL "" )
|
||||
set_property( CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${INSTALL_PATH}" )
|
||||
elseif( INSTALL_TO_SOURCE )
|
||||
set( INSTALL_TO "source" CACHE INTERNAL "" )
|
||||
set_property( CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${CMAKE_CURRENT_SOURCE_DIR}" )
|
||||
elseif( INSTALL_TO_SUBDIR )
|
||||
set( INSTALL_TO "subdir" CACHE INTERNAL "" )
|
||||
set_property( CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${CMAKE_CURRENT_BINARY_DIR}/install" )
|
||||
endif()
|
||||
set( SVN_FOLDER_PATTERN "[\\.]svn" CACHE STRING "pattern of svn folder that we exclude from instalations" )
|
||||
mark_as_advanced( SVN_FOLDER_PATTERN )
|
||||
set( DEVELOPMENT_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/configure"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/configure.in"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/rAthena.sln"
|
||||
)
|
||||
set( DEVELOPMENT_DIRECTORIES
|
||||
"3rdparty"
|
||||
"conf/import-tmpl"
|
||||
"conf/msg_conf/import-tmpl"
|
||||
"db/import-tmpl"
|
||||
"src"
|
||||
)
|
||||
set( RUNTIME_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/athena-start"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/README.md"
|
||||
)
|
||||
if (WIN32)
|
||||
set (RUNTIME_FILES
|
||||
${RUNTIME_FILES}
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/dbghelp.dll"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/libmysql.dll"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pcre3.dll"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/zlib1.dll"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tools/charserv.bat"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tools/logserv.bat"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tools/mapserv.bat"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tools/runserver.bat"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tools/serv.bat"
|
||||
)
|
||||
endif(WIN32)
|
||||
|
||||
set( RUNTIME_DIRECTORIES
|
||||
"conf"
|
||||
"db"
|
||||
"doc"
|
||||
"log"
|
||||
"npc"
|
||||
"sql-files"
|
||||
"tools"
|
||||
)
|
||||
if( INSTALL_TO_SOURCE )# skip, already in the source dir
|
||||
else()
|
||||
if( INSTALL_COMPONENT_RUNTIME )
|
||||
install( FILES ${RUNTIME_FILES}
|
||||
DESTINATION "."
|
||||
COMPONENT Runtime_base )
|
||||
foreach( DIR IN ITEMS ${RUNTIME_DIRECTORIES} )
|
||||
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${DIR}/" )
|
||||
install( DIRECTORY "${DIR}/"
|
||||
DESTINATION "${DIR}"
|
||||
COMPONENT Runtime_base
|
||||
PATTERN ${SVN_FOLDER_PATTERN} EXCLUDE
|
||||
PATTERN "conf/import-tmpl" EXCLUDE )
|
||||
else()
|
||||
# create empty directory
|
||||
install( CODE "file(MAKE_DIRECTORY \"\${ENV}\${CMAKE_INSTALL_PREFIX}/${DIR}\")"
|
||||
COMPONENT Runtime_base )
|
||||
endif()
|
||||
endforeach()
|
||||
endif( INSTALL_COMPONENT_RUNTIME )
|
||||
if( INSTALL_COMPONENT_DEVELOPMENT )
|
||||
install( FILES ${DEVELOPMENT_FILES}
|
||||
DESTINATION "."
|
||||
COMPONENT Development_base )
|
||||
foreach( DIR IN ITEMS ${DEVELOPMENT_DIRECTORIES} )
|
||||
install( DIRECTORY "${DIR}/"
|
||||
DESTINATION "${DIR}"
|
||||
COMPONENT Development_base
|
||||
PATTERN ${SVN_FOLDER_PATTERN} EXCLUDE )
|
||||
endforeach()
|
||||
endif( INSTALL_COMPONENT_DEVELOPMENT )
|
||||
endif()
|
||||
if( INSTALL_COMPONENT_RUNTIME )
|
||||
# templates
|
||||
set( _TEMPLATES
|
||||
"conf/import-tmpl" "conf/import"
|
||||
"conf/msg_conf/import-tmpl" "conf/msg_conf/import"
|
||||
"db/import-tmpl" "db/import"
|
||||
)
|
||||
set( INSTALL_TEMPLATES_FILE "${CMAKE_CURRENT_BINARY_DIR}/InstallTemplates.cmake" )
|
||||
file( WRITE "${INSTALL_TEMPLATES_FILE}"
|
||||
"macro( INSTALL_TEMPLATE _SRC _DST )\n"
|
||||
" set( SRC \"${CMAKE_CURRENT_SOURCE_DIR}/\${_SRC}\" )\n"
|
||||
" set( DST \"\${CMAKE_INSTALL_PREFIX}/\${_DST}\" )\n"
|
||||
" if( EXISTS \"\${DST}\" )\n"
|
||||
" message( \"-- Already exists: \${DST}\" )\n"
|
||||
" else()\n"
|
||||
" message( \"-- Installing template: \${DST}\" )\n"
|
||||
" execute_process( COMMAND \"${CMAKE_COMMAND}\" -E copy \"\${SRC}\" \"\${DST}\" )\n"
|
||||
" endif()\n"
|
||||
"endmacro()\n"
|
||||
)
|
||||
while( _TEMPLATES )
|
||||
list( GET _TEMPLATES 0 _SRC )
|
||||
list( GET _TEMPLATES 1 _DST )
|
||||
list( REMOVE_AT _TEMPLATES 0 1 )
|
||||
if( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_SRC}" )
|
||||
file( GLOB _PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${_SRC}/*" )
|
||||
foreach( _PATH IN ITEMS ${_PATHS} )
|
||||
string( REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/${_SRC}/" "" _PATH "${_PATH}" )
|
||||
if( NOT "${_PATH}" MATCHES "${SVN_FOLDER_PATTERN}" )
|
||||
list( APPEND _TEMPLATES "${_SRC}/${_PATH}" "${_DST}/${_PATH}" )
|
||||
endif()
|
||||
endforeach()
|
||||
else()
|
||||
file( APPEND "${INSTALL_TEMPLATES_FILE}" "INSTALL_TEMPLATE( \"${_SRC}\" \"${_DST}\" )\n" )
|
||||
endif()
|
||||
endwhile()
|
||||
install( SCRIPT "${INSTALL_TEMPLATES_FILE}"
|
||||
COMPONENT Runtime_templates )
|
||||
endif( INSTALL_COMPONENT_RUNTIME )
|
||||
|
||||
|
||||
#
|
||||
# sources
|
||||
#
|
||||
set( TARGET_LIST CACHE INTERNAL "" )
|
||||
add_subdirectory(3rdparty)
|
||||
add_subdirectory(src)
|
||||
|
||||
|
||||
#####################################################################
|
||||
# final checks and warnings
|
||||
#
|
||||
|
||||
list( LENGTH TARGET_LIST _LEN )
|
||||
if( _LEN EQUAL 0 )
|
||||
message( FATAL_ERROR "no targets available" )
|
||||
endif()
|
||||
message( STATUS "Available targets:" )
|
||||
foreach( _TARGET IN ITEMS ${TARGET_LIST} )
|
||||
message( STATUS "\t${_TARGET}" )
|
||||
endforeach()
|
||||
|
||||
@ -1,29 +1,16 @@
|
||||
|
||||
#
|
||||
# setup and static libraries
|
||||
#
|
||||
|
||||
set(RA_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH
|
||||
"rathena include directory"
|
||||
)
|
||||
mark_as_advanced(RA_INCLUDE_DIRS)
|
||||
|
||||
|
||||
|
||||
add_subdirectory(common)
|
||||
if( HAVE_common )
|
||||
option( BUILD_SERVERS "build server executables" ON )
|
||||
else()
|
||||
message( STATUS "Disabled server targets (requires common)" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# targets
|
||||
#
|
||||
add_subdirectory(login)
|
||||
add_subdirectory(char)
|
||||
add_subdirectory(map)
|
||||
add_subdirectory(web)
|
||||
|
||||
add_subdirectory(tool)
|
||||
|
||||
# add_subdirectory( tool )
|
||||
|
||||
|
||||
@ -1,40 +1,52 @@
|
||||
#
|
||||
# setup
|
||||
#
|
||||
set( CHAR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
|
||||
add_executable(char-server)
|
||||
|
||||
target_sources(char-server PRIVATE
|
||||
"char.cpp"
|
||||
"char_clif.cpp"
|
||||
"char_cnslif.cpp"
|
||||
"char_logif.cpp"
|
||||
"char_mapif.cpp"
|
||||
"int_achievement.cpp"
|
||||
"int_auction.cpp"
|
||||
"int_clan.cpp"
|
||||
"int_elemental.cpp"
|
||||
"int_guild.cpp"
|
||||
"int_homun.cpp"
|
||||
"int_mail.cpp"
|
||||
"int_mercenary.cpp"
|
||||
"int_party.cpp"
|
||||
"int_pet.cpp"
|
||||
"int_quest.cpp"
|
||||
"int_storage.cpp"
|
||||
"inter.cpp"
|
||||
)
|
||||
|
||||
#
|
||||
# char server
|
||||
#
|
||||
if( BUILD_SERVERS )
|
||||
message( STATUS "Creating target char-server" )
|
||||
file(GLOB CHAR_HEADERS ${CHAR_SOURCE_DIR}/*.hpp)
|
||||
file(GLOB CHAR_SOURCES_CXX ${CHAR_SOURCE_DIR}/*.cpp)
|
||||
set(CHAR_SOURCES ${CHAR_SOURCES_C} ${CHAR_SOURCES_CXX})
|
||||
#message( STATUS "CHAR_SOURCES="${CHAR_SOURCES})
|
||||
set( DEPENDENCIES common )
|
||||
set( LIBRARIES ${GLOBAL_LIBRARIES} )
|
||||
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS} ${RA_INCLUDE_DIRS} )
|
||||
set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS}" )
|
||||
set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} ${CHAR_HEADERS} ${CHAR_SOURCES} )
|
||||
source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} )
|
||||
source_group( char FILES ${CHAR_HEADERS} ${CHAR_SOURCES} )
|
||||
include_directories( ${INCLUDE_DIRS} )
|
||||
if(WIN32)
|
||||
target_sources(char-server PRIVATE
|
||||
"char_clif.hpp"
|
||||
"char_cnslif.hpp"
|
||||
"char.hpp"
|
||||
"char_logif.hpp"
|
||||
"char_mapif.hpp"
|
||||
"int_achievement.hpp"
|
||||
"int_auction.hpp"
|
||||
"int_clan.hpp"
|
||||
"int_elemental.hpp"
|
||||
"inter.hpp"
|
||||
"int_guild.hpp"
|
||||
"int_homun.hpp"
|
||||
"int_mail.hpp"
|
||||
"int_mercenary.hpp"
|
||||
"int_party.hpp"
|
||||
"int_pet.hpp"
|
||||
"int_quest.hpp"
|
||||
"int_storage.hpp"
|
||||
"packets.hpp"
|
||||
)
|
||||
|
||||
#message( STATUS "char-server SOURCE_FILES=${SOURCE_FILES}")
|
||||
add_executable( char-server ${SOURCE_FILES} )
|
||||
#message( STATUS "char-server LIBRARIES=${LIBRARIES}, DEPENDENCIES=${DEPENDENCIES} DEFINITIONS=${DEFINITIONS}")
|
||||
add_dependencies( char-server ${DEPENDENCIES} )
|
||||
target_link_libraries( char-server ${LIBRARIES} ${DEPENDENCIES} )
|
||||
set_target_properties( char-server PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
|
||||
set_target_properties(char-server PROPERTIES FOLDER "Servers")
|
||||
endif()
|
||||
|
||||
if( INSTALL_COMPONENT_RUNTIME )
|
||||
cpack_add_component( Runtime_charserver DESCRIPTION "char-server" DISPLAY_NAME "char-server" GROUP Runtime )
|
||||
install( TARGETS char-server
|
||||
DESTINATION "."
|
||||
COMPONENT Runtime_charserver )
|
||||
endif( INSTALL_COMPONENT_RUNTIME )
|
||||
set( TARGET_LIST ${TARGET_LIST} char-server CACHE INTERNAL "" )
|
||||
message( STATUS "Creating target char-server - done" )
|
||||
endif( BUILD_SERVERS )
|
||||
target_link_libraries(char-server PUBLIC
|
||||
common
|
||||
)
|
||||
|
||||
@ -1,191 +1,203 @@
|
||||
include(CheckCSourceRuns)
|
||||
|
||||
#
|
||||
# Create version.hpp
|
||||
# Test monotonic clock
|
||||
#
|
||||
message( STATUS "Creating version.hpp" )
|
||||
if(GIT_VERSION)
|
||||
# those 2 was done in parent to produce this
|
||||
#include(GetGitVersion)
|
||||
#get_git_version()
|
||||
string(SUBSTRING ${GIT_VERSION} 0 10 SHORT_GIT_VERSION)
|
||||
string(SUBSTRING ${GIT_HEAD_VERSION} 0 10 SHORT_GIT_HEAD_VERSION)
|
||||
string(CONCAT GIT_STR_VERSIONS ${SHORT_GIT_VERSION} "_" ${SHORT_GIT_HEAD_VERSION})
|
||||
#message( STATUS "git version=${GIT_STR_VERSIONS}" )
|
||||
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/version.hpp
|
||||
"#ifndef SVNVERSION\n#define SVNVERSION ${GIT_STR_VERSIONS}\n#endif\n" )
|
||||
elseif( SVNVERSION )
|
||||
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/version.hpp
|
||||
"#ifndef SVNVERSION\n#define SVNVERSION ${SVNVERSION}\n#endif\n" )
|
||||
# CLOCK_MONOTONIC clock for clock_gettime
|
||||
# Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix
|
||||
# compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD
|
||||
# >= 5.1.0, which does not have the posix defines (ref. r11983)) would be
|
||||
# checked but some systems define them even when they do not support it
|
||||
# (ref. bugreport:1003).
|
||||
#
|
||||
message(STATUS "Check for monotonic clock")
|
||||
find_library(RT_LIBRARY rt)# (optional, rt on Debian)
|
||||
mark_as_advanced(RT_LIBRARY)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} ${RT_LIBRARY})
|
||||
file(READ "${CMAKE_SOURCE_DIR}/3rdparty/cmake/tests/HAVE_MONOTONIC_CLOCK.c" _SOURCE)
|
||||
CHECK_C_SOURCE_RUNS("${_SOURCE}" HAVE_MONOTONIC_CLOCK)
|
||||
if(HAVE_MONOTONIC_CLOCK)
|
||||
message(STATUS "Check for monotonic clock - yes")
|
||||
set(MONOTONIC_CLOCK_LIBRARIES ${RT_LIBRARY})
|
||||
set(MONOTONIC_CLOCK_DEFINITIONS "-DHAVE_MONOTONIC_CLOCK")
|
||||
else()
|
||||
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/version.hpp "" )
|
||||
message(STATUS "Check for monotonic clock - no")
|
||||
endif()
|
||||
set( GLOBAL_INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "" )
|
||||
set( SVNVERSION ${SVNVERSION}
|
||||
CACHE STRING "SVN version of the source code" )
|
||||
if( INSTALL_COMPONENT_DEVELOPMENT )
|
||||
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/version.hpp
|
||||
DESTINATION "src/common"
|
||||
COMPONENT Development_base )
|
||||
endif( INSTALL_COMPONENT_DEVELOPMENT )
|
||||
message( STATUS "Creating version.hpp - done" )
|
||||
|
||||
set( COMMON_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
CACHE PATH "common source directory" )
|
||||
#message( STATUS "DEBUG COMMON_SOURCE_DIR=${COMMON_SOURCE_DIR}" )
|
||||
mark_as_advanced( COMMON_SOURCE_DIR )
|
||||
# Check ENABLE_MEMORY option
|
||||
if(ENABLE_MEMORY STREQUAL "system")
|
||||
# use the normal system functions
|
||||
else()
|
||||
message(STATUS "Feature not implemented, defaulting to system")
|
||||
endif()
|
||||
|
||||
|
||||
add_library(minicore EXCLUDE_FROM_ALL)
|
||||
add_library(common)
|
||||
# add_library(core-tools)
|
||||
add_library(common-win INTERFACE)
|
||||
|
||||
#####################################################################
|
||||
# setup
|
||||
#
|
||||
if(WIN32)
|
||||
set( PROJECT_LIBS Ws2_32.lib )
|
||||
target_link_libraries(common-win INTERFACE "ws2_32.lib")
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS)
|
||||
target_compile_definitions(common-win INTERFACE
|
||||
_WINSOCK_DEPRECATED_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE)
|
||||
endif()
|
||||
|
||||
set( COMMON_ADDITIONALL_CPP "${COMMON_SOURCE_DIR}/winapi.cpp" )
|
||||
|
||||
set( COMMON_ADDITIONALL_HPP "${COMMON_SOURCE_DIR}/winapi.hpp" )
|
||||
endif()
|
||||
|
||||
set( COMMON_ALL_HEADERS
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/version.hpp"
|
||||
"${COMMON_SOURCE_DIR}/cbasetypes.hpp"
|
||||
"${COMMON_SOURCE_DIR}/mmo.hpp"
|
||||
target_sources(common-win INTERFACE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/winapi.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/winapi.hpp"
|
||||
)
|
||||
|
||||
add_library(minicore)
|
||||
target_link_libraries(minicore PUBLIC common-win)
|
||||
target_link_libraries(common PUBLIC common-win)
|
||||
endif()
|
||||
|
||||
target_sources(minicore PRIVATE
|
||||
"${COMMON_SOURCE_DIR}/core.cpp"
|
||||
"${COMMON_SOURCE_DIR}/malloc.cpp"
|
||||
"${COMMON_SOURCE_DIR}/showmsg.cpp"
|
||||
"${COMMON_SOURCE_DIR}/strlib.cpp"
|
||||
${LIBCONFIG_SOURCES} # needed by showmsg.cpp
|
||||
${COMMON_ADDITIONALL_CPP} # needed by Windows
|
||||
"core.cpp"
|
||||
"database.cpp"
|
||||
"des.cpp"
|
||||
"grfio.cpp"
|
||||
"malloc.cpp"
|
||||
"nullpo.cpp"
|
||||
"showmsg.cpp"
|
||||
"strlib.cpp"
|
||||
"utils.cpp"
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
target_sources(minicore PRIVATE
|
||||
"cbasetypes.hpp"
|
||||
"core.hpp"
|
||||
"database.hpp"
|
||||
"des.hpp"
|
||||
"grfio.hpp"
|
||||
"malloc.hpp"
|
||||
"nullpo.hpp"
|
||||
"showmsg.hpp"
|
||||
"strlib.hpp"
|
||||
"utils.hpp"
|
||||
)
|
||||
set_target_properties(minicore PROPERTIES FOLDER "Core")
|
||||
endif()
|
||||
|
||||
target_compile_definitions(minicore PRIVATE
|
||||
"-DMINICORE"
|
||||
${MONOTONIC_CLOCK_DEFINITIONS}
|
||||
)
|
||||
|
||||
target_include_directories(minicore PUBLIC
|
||||
${COMMON_SOURCE_DIR}
|
||||
${LIBCONFIG_INCLUDE_DIRS}
|
||||
${COMMON_ADDITIONALL_HPP} # needed by Windows
|
||||
"${RA_INCLUDE_DIRS}"
|
||||
"${ZLIB_INCLUDE_DIRS}"
|
||||
)
|
||||
|
||||
target_link_libraries(minicore PUBLIC
|
||||
${MONOTONIC_CLOCK_LIBRARIES}
|
||||
libconfig
|
||||
ryml
|
||||
${ZLIB_LIBRARIES}
|
||||
yaml-cpp
|
||||
)
|
||||
|
||||
target_sources(common PRIVATE
|
||||
"cli.cpp"
|
||||
"conf.cpp"
|
||||
"core.cpp"
|
||||
"database.cpp"
|
||||
"db.cpp"
|
||||
"des.cpp"
|
||||
"ers.cpp"
|
||||
"grfio.cpp"
|
||||
"malloc.cpp"
|
||||
"mapindex.cpp"
|
||||
"md5calc.cpp"
|
||||
"msg_conf.cpp"
|
||||
"nullpo.cpp"
|
||||
"random.cpp"
|
||||
"showmsg.cpp"
|
||||
"socket.cpp"
|
||||
"sql.cpp"
|
||||
"strlib.cpp"
|
||||
"timer.cpp"
|
||||
"utils.cpp"
|
||||
"utilities.cpp"
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
target_sources(common PRIVATE
|
||||
"cbasetypes.hpp"
|
||||
"cli.hpp"
|
||||
"conf.hpp"
|
||||
"core.hpp"
|
||||
"database.hpp"
|
||||
"db.hpp"
|
||||
"des.hpp"
|
||||
"ers.hpp"
|
||||
"grfio.hpp"
|
||||
"malloc.hpp"
|
||||
"mapindex.hpp"
|
||||
"md5calc.hpp"
|
||||
"mmo.hpp"
|
||||
"msg_conf.hpp"
|
||||
"nullpo.hpp"
|
||||
"random.hpp"
|
||||
"showmsg.hpp"
|
||||
"socket.hpp"
|
||||
"sql.hpp"
|
||||
"strlib.hpp"
|
||||
"timer.hpp"
|
||||
"utilities.hpp"
|
||||
"utils.hpp"
|
||||
)
|
||||
set_target_properties(common PROPERTIES FOLDER "Core")
|
||||
endif()
|
||||
|
||||
# defines just for common
|
||||
target_compile_definitions(common PRIVATE ${MONOTONIC_CLOCK_DEFINITIONS})
|
||||
|
||||
if(ENABLE_RDTSC)
|
||||
target_compile_definitions(common PRIVATE "-DENABLE_RDTSC")
|
||||
endif()
|
||||
|
||||
|
||||
if(ENABLE_MEMMGR)
|
||||
target_compile_definitions(common PRIVATE "-DUSE_MEMMGR")
|
||||
else()
|
||||
target_compile_definitions(common PRIVATE "-DNO_MEMMGR")
|
||||
endif()
|
||||
|
||||
# Propagated defines
|
||||
target_compile_definitions(common PUBLIC "-DPACKETVER=${PACKETVER}")
|
||||
|
||||
if(ENABLE_PRERENEWAL)
|
||||
target_compile_definitions(common PUBLIC "-DPRERE")
|
||||
endif()
|
||||
|
||||
if(ENABLE_EXTRA_DEBUG_CODE)
|
||||
target_compile_definitions(common PUBLIC "-DDEBUG")
|
||||
endif()
|
||||
|
||||
if(ENABLE_EXTRA_BUILDBOT_CODE)
|
||||
target_compile_definitions(common PUBLIC "-DBUILDBOT")
|
||||
endif()
|
||||
|
||||
target_include_directories(common PUBLIC
|
||||
"${MYSQL_INCLUDE_DIRS}"
|
||||
"${ZLIB_INCLUDE_DIRS}"
|
||||
"${RA_INCLUDE_DIRS}"
|
||||
)
|
||||
|
||||
target_link_libraries(common PUBLIC
|
||||
${MONOTONIC_CLOCK_LIBRARIES}
|
||||
libconfig
|
||||
ryml
|
||||
${MYSQL_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
)
|
||||
|
||||
|
||||
target_compile_definitions(minicore PRIVATE "-DMINICORE" ${LIBCONFIG_DEFINITIONS})
|
||||
|
||||
#
|
||||
# common_base
|
||||
#
|
||||
if( WITH_ZLIB )
|
||||
message( STATUS "Creating target common_base" )
|
||||
set( COMMON_BASE_HEADERS
|
||||
${COMMON_ALL_HEADERS}
|
||||
"${COMMON_SOURCE_DIR}/conf.hpp"
|
||||
"${COMMON_SOURCE_DIR}/core.hpp"
|
||||
"${COMMON_SOURCE_DIR}/database.hpp"
|
||||
"${COMMON_SOURCE_DIR}/db.hpp"
|
||||
"${COMMON_SOURCE_DIR}/des.hpp"
|
||||
"${COMMON_SOURCE_DIR}/ers.hpp"
|
||||
"${COMMON_SOURCE_DIR}/grfio.hpp"
|
||||
"${COMMON_SOURCE_DIR}/malloc.hpp"
|
||||
"${COMMON_SOURCE_DIR}/mapindex.hpp"
|
||||
"${COMMON_SOURCE_DIR}/md5calc.hpp"
|
||||
"${COMMON_SOURCE_DIR}/nullpo.hpp"
|
||||
"${COMMON_SOURCE_DIR}/random.hpp"
|
||||
"${COMMON_SOURCE_DIR}/showmsg.hpp"
|
||||
"${COMMON_SOURCE_DIR}/socket.hpp"
|
||||
"${COMMON_SOURCE_DIR}/strlib.hpp"
|
||||
"${COMMON_SOURCE_DIR}/timer.hpp"
|
||||
"${COMMON_SOURCE_DIR}/utils.hpp"
|
||||
"${COMMON_SOURCE_DIR}/msg_conf.hpp"
|
||||
"${COMMON_SOURCE_DIR}/cli.hpp"
|
||||
"${COMMON_SOURCE_DIR}/utilities.hpp"
|
||||
${LIBCONFIG_HEADERS} # needed by conf.hpp/showmsg.hpp
|
||||
${COMMON_ADDITIONALL_HPP} # needed by Windows
|
||||
CACHE INTERNAL "common_base headers" )
|
||||
set( COMMON_BASE_SOURCES
|
||||
"${COMMON_SOURCE_DIR}/conf.cpp"
|
||||
"${COMMON_SOURCE_DIR}/core.cpp"
|
||||
"${COMMON_SOURCE_DIR}/database.cpp"
|
||||
"${COMMON_SOURCE_DIR}/db.cpp"
|
||||
"${COMMON_SOURCE_DIR}/des.cpp"
|
||||
"${COMMON_SOURCE_DIR}/ers.cpp"
|
||||
"${COMMON_SOURCE_DIR}/grfio.cpp"
|
||||
"${COMMON_SOURCE_DIR}/malloc.cpp"
|
||||
"${COMMON_SOURCE_DIR}/mapindex.cpp"
|
||||
"${COMMON_SOURCE_DIR}/md5calc.cpp"
|
||||
"${COMMON_SOURCE_DIR}/nullpo.cpp"
|
||||
"${COMMON_SOURCE_DIR}/random.cpp"
|
||||
"${COMMON_SOURCE_DIR}/showmsg.cpp"
|
||||
"${COMMON_SOURCE_DIR}/socket.cpp"
|
||||
"${COMMON_SOURCE_DIR}/strlib.cpp"
|
||||
"${COMMON_SOURCE_DIR}/timer.cpp"
|
||||
"${COMMON_SOURCE_DIR}/utils.cpp"
|
||||
"${COMMON_SOURCE_DIR}/msg_conf.cpp"
|
||||
"${COMMON_SOURCE_DIR}/cli.cpp"
|
||||
"${COMMON_SOURCE_DIR}/utilities.cpp"
|
||||
${LIBCONFIG_SOURCES} # needed by conf.cpp/showmsg.cpp
|
||||
${COMMON_ADDITIONALL_CPP} # needed by Windows
|
||||
CACHE INTERNAL "common_base sources" )
|
||||
set( COMMON_BASE_INCLUDE_DIRS
|
||||
${LIBCONFIG_INCLUDE_DIRS}
|
||||
${YAML_INCLUDE_DIRS}
|
||||
CACHE INTERNAL "common_base include dirs" )
|
||||
set( COMMON_BASE_DEFINITIONS
|
||||
${LIBCONFIG_DEFINITIONS}
|
||||
CACHE INTERNAL "common_base definitions" )
|
||||
set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} yaml-cpp ryml )
|
||||
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${RA_INCLUDE_DIRS} ${YAML_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS} )
|
||||
set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS}" )
|
||||
set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_BASE_SOURCES} )
|
||||
source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_BASE_SOURCES} )
|
||||
|
||||
add_library( common_base ${SOURCE_FILES} )
|
||||
#message( STATUS "common_base LIBRARIES=${LIBRARIES}, DEFINITIONS=${DEFINITIONS}")
|
||||
target_link_libraries( common_base ${LIBRARIES} )
|
||||
set_target_properties( common_base PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
|
||||
include_directories( ${INCLUDE_DIRS} )
|
||||
|
||||
set( HAVE_common_base ON CACHE INTERNAL "" )
|
||||
set( TARGET_LIST ${TARGET_LIST} common_base CACHE INTERNAL "" )
|
||||
message( STATUS "Creating target common_base - done" )
|
||||
else()
|
||||
message( STATUS "Skipping target common_base (requires ZLIB)" )
|
||||
unset( HAVE_common_base CACHE )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# common
|
||||
#
|
||||
if( HAVE_common_base AND WITH_MYSQL )
|
||||
message( STATUS "Creating target common" )
|
||||
set( COMMON_HEADERS
|
||||
${COMMON_ALL_HEADERS}
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/sql.hpp"
|
||||
CACHE INTERNAL "common headers" )
|
||||
set( COMMON_SOURCES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/sql.cpp"
|
||||
CACHE INTERNAL "common sources" )
|
||||
set( DEPENDENCIES common_base yaml-cpp ryml )
|
||||
set( LIBRARIES ${GLOBAL_LIBRARIES} ${MYSQL_LIBRARIES} )
|
||||
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIRS} )
|
||||
set( DEFINITIONS "${GLOBAL_DEFINITIONS}" )
|
||||
set( SOURCE_FILES ${COMMON_HEADERS} ${COMMON_SOURCES} )
|
||||
source_group( common FILES ${COMMON_HEADERS} ${COMMON_SOURCES} )
|
||||
|
||||
add_library( common ${SOURCE_FILES} )
|
||||
#message( STATUS "common LIBRARIES=${LIBRARIES}, DEPENDENCIES=${DEPENDENCIES} DEFINITIONS=${DEFINITIONS}")
|
||||
add_dependencies( common ${DEPENDENCIES} )
|
||||
target_link_libraries( common ${LIBRARIES} ${DEPENDENCIES} )
|
||||
set_target_properties( common PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
|
||||
include_directories( ${INCLUDE_DIRS} ${YAML_INCLUDE_DIRS} )
|
||||
|
||||
set( HAVE_common ON CACHE INTERNAL "" )
|
||||
set( TARGET_LIST ${TARGET_LIST} common CACHE INTERNAL "" )
|
||||
message( STATUS "Creating target common - done" )
|
||||
else()
|
||||
message( FATAL_ERROR "Stopping target common (requires common_base and MYSQL)" )
|
||||
if(ENABLE_PROFILER STREQUAL "gprof")
|
||||
target_compile_options(common PUBLIC "-pg")
|
||||
target_link_libraries(common PUBLIC "-pg")
|
||||
endif()
|
||||
|
||||
@ -1,35 +1,29 @@
|
||||
#
|
||||
# setup
|
||||
#
|
||||
set( LOGIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
|
||||
add_executable(login-server)
|
||||
|
||||
# login server
|
||||
#
|
||||
if( BUILD_SERVERS )
|
||||
message( STATUS "Creating target login-server" )
|
||||
file(GLOB LOGIN_HEADERS ${LOGIN_SOURCE_DIR}/*.hpp)
|
||||
file(GLOB LOGIN_SOURCES_CXX ${LOGIN_SOURCE_DIR}/*.cpp)
|
||||
set(LOGIN_SOURCES ${LOGIN_SOURCES_C} ${LOGIN_SOURCES_CXX})
|
||||
#message( STATUS "LOGIN_SOURCES="${LOGIN_SOURCES})
|
||||
set( DEPENDENCIES common )
|
||||
set( LIBRARIES ${GLOBAL_LIBRARIES} )
|
||||
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS} ${RA_INCLUDE_DIRS} )
|
||||
set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS} -DWITH_SQL" )
|
||||
set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} ${LOGIN_HEADERS} ${LOGIN_SOURCES} )
|
||||
source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} )
|
||||
source_group( login FILES ${LOGIN_HEADERS} ${LOGIN_SOURCES} )
|
||||
include_directories( ${INCLUDE_DIRS} )
|
||||
target_sources(login-server PRIVATE
|
||||
"account.cpp"
|
||||
"ipban.cpp"
|
||||
"login.cpp"
|
||||
"loginchrif.cpp"
|
||||
"loginclif.cpp"
|
||||
"logincnslif.cpp"
|
||||
"loginlog.cpp"
|
||||
)
|
||||
|
||||
add_executable( login-server ${SOURCE_FILES} )
|
||||
add_dependencies( login-server ${DEPENDENCIES} )
|
||||
target_link_libraries( login-server ${LIBRARIES} ${DEPENDENCIES} )
|
||||
set_target_properties( login-server PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
|
||||
if( INSTALL_COMPONENT_RUNTIME )
|
||||
cpack_add_component( Runtime_loginserver DESCRIPTION "login-server" DISPLAY_NAME "login-server" GROUP Runtime )
|
||||
install( TARGETS login-server
|
||||
DESTINATION "."
|
||||
COMPONENT Runtime_loginserver )
|
||||
endif( INSTALL_COMPONENT_RUNTIME )
|
||||
set( TARGET_LIST ${TARGET_LIST} login-server CACHE INTERNAL "" )
|
||||
message( STATUS "Creating target login-server - done" )
|
||||
endif( BUILD_SERVERS )
|
||||
if(WIN32)
|
||||
target_sources(login-server PRIVATE
|
||||
"account.hpp"
|
||||
"ipban.hpp"
|
||||
"loginchrif.hpp"
|
||||
"loginclif.hpp"
|
||||
"logincnslif.hpp"
|
||||
"login.hpp"
|
||||
"loginlog.hpp"
|
||||
)
|
||||
|
||||
set_target_properties(login-server PROPERTIES FOLDER "Servers")
|
||||
endif()
|
||||
|
||||
target_link_libraries(login-server PUBLIC
|
||||
common
|
||||
)
|
||||
|
||||
@ -1,45 +1,125 @@
|
||||
#
|
||||
# setup
|
||||
#
|
||||
set( MAP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
|
||||
set(MAP_SOURCES
|
||||
"achievement.cpp"
|
||||
"atcommand.cpp"
|
||||
"battle.cpp"
|
||||
"battleground.cpp"
|
||||
"buyingstore.cpp"
|
||||
"cashshop.cpp"
|
||||
"channel.cpp"
|
||||
"chat.cpp"
|
||||
"chrif.cpp"
|
||||
"clan.cpp"
|
||||
"clif.cpp"
|
||||
"date.cpp"
|
||||
"duel.cpp"
|
||||
"elemental.cpp"
|
||||
"guild.cpp"
|
||||
"homunculus.cpp"
|
||||
"instance.cpp"
|
||||
"intif.cpp"
|
||||
"itemdb.cpp"
|
||||
"log.cpp"
|
||||
"mail.cpp"
|
||||
"map.cpp"
|
||||
"mapreg.cpp"
|
||||
"mercenary.cpp"
|
||||
"mob.cpp"
|
||||
"navi.cpp"
|
||||
"npc.cpp"
|
||||
"npc_chat.cpp"
|
||||
"party.cpp"
|
||||
"path.cpp"
|
||||
"pc.cpp"
|
||||
"pc_groups.cpp"
|
||||
"pet.cpp"
|
||||
"quest.cpp"
|
||||
"script.cpp"
|
||||
"searchstore.cpp"
|
||||
"skill.cpp"
|
||||
"status.cpp"
|
||||
"storage.cpp"
|
||||
"trade.cpp"
|
||||
"unit.cpp"
|
||||
"vending.cpp"
|
||||
)
|
||||
|
||||
set(MAP_HEADERS
|
||||
"achievement.hpp"
|
||||
"atcommand.hpp"
|
||||
"battleground.hpp"
|
||||
"battle.hpp"
|
||||
"buyingstore.hpp"
|
||||
"cashshop.hpp"
|
||||
"channel.hpp"
|
||||
"chat.hpp"
|
||||
"chrif.hpp"
|
||||
"clan.hpp"
|
||||
"clif.hpp"
|
||||
"clif_obfuscation.hpp"
|
||||
"clif_packetdb.hpp"
|
||||
"clif_shuffle.hpp"
|
||||
"date.hpp"
|
||||
"duel.hpp"
|
||||
"elemental.hpp"
|
||||
"guild.hpp"
|
||||
"homunculus.hpp"
|
||||
"instance.hpp"
|
||||
"intif.hpp"
|
||||
"itemdb.hpp"
|
||||
"log.hpp"
|
||||
"mail.hpp"
|
||||
"map.hpp"
|
||||
"mapreg.hpp"
|
||||
"mercenary.hpp"
|
||||
"mob.hpp"
|
||||
"navi.hpp"
|
||||
"npc.hpp"
|
||||
"packets.hpp"
|
||||
"packets_struct.hpp"
|
||||
"party.hpp"
|
||||
"path.hpp"
|
||||
"pc_groups.hpp"
|
||||
"pc.hpp"
|
||||
"pet.hpp"
|
||||
"quest.hpp"
|
||||
"script_constants.hpp"
|
||||
"script.hpp"
|
||||
"searchstore.hpp"
|
||||
"skill.hpp"
|
||||
"status.hpp"
|
||||
"storage.hpp"
|
||||
"trade.hpp"
|
||||
"unit.hpp"
|
||||
"vending.hpp"
|
||||
)
|
||||
|
||||
#
|
||||
# map server
|
||||
#
|
||||
if( BUILD_SERVERS )
|
||||
message( STATUS "Creating target map-server" )
|
||||
file(GLOB MAP_HEADERS ${MAP_SOURCE_DIR}/*.hpp)
|
||||
file(GLOB MAP_SOURCES ${MAP_SOURCE_DIR}/*.cpp)
|
||||
set( DEPENDENCIES common ryml)
|
||||
set( LIBRARIES ${GLOBAL_LIBRARIES})
|
||||
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS} ${RA_INCLUDE_DIRS} )
|
||||
set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS}" )
|
||||
if( WITH_PCRE )
|
||||
message( STATUS "Enabled PCRE code" )
|
||||
set( LIBRARIES ${LIBRARIES} ${PCRE_LIBRARIES} )
|
||||
set( INCLUDE_DIRS ${INCLUDE_DIRS} ${PCRE_INCLUDE_DIRS} )
|
||||
set( DEFINITIONS "${DEFINITIONS} -DPCRE_SUPPORT" )
|
||||
else()
|
||||
message( STATUS "Disabled PCRE code" )
|
||||
add_executable(map-server)
|
||||
|
||||
target_sources(map-server PRIVATE ${MAP_SOURCES})
|
||||
|
||||
if(WIN32)
|
||||
target_sources(map-server PRIVATE ${MAP_HEADERS})
|
||||
set_target_properties(map-server PROPERTIES FOLDER "Servers")
|
||||
endif()
|
||||
set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} ${MAP_HEADERS} ${MAP_SOURCES} )
|
||||
source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} )
|
||||
source_group( map FILES ${MAP_HEADERS} ${MAP_SOURCES} )
|
||||
include_directories( ${INCLUDE_DIRS} )
|
||||
|
||||
#message( STATUS "map-server SOURCE_FILES=${SOURCE_FILES}")
|
||||
add_executable( map-server ${SOURCE_FILES} )
|
||||
#message( STATUS "map-server LIBRARIES=${LIBRARIES}, DEPENDENCIES=${DEPENDENCIES} DEFINITIONS=${DEFINITIONS}")
|
||||
add_dependencies( map-server ${DEPENDENCIES} )
|
||||
target_link_libraries( map-server ${LIBRARIES} ${DEPENDENCIES} )
|
||||
set_target_properties( map-server PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
|
||||
if( INSTALL_COMPONENT_RUNTIME )
|
||||
cpack_add_component( Runtime_mapserver DESCRIPTION "map-server" DISPLAY_NAME "map-server" GROUP Runtime )
|
||||
install( TARGETS map-server
|
||||
DESTINATION "."
|
||||
COMPONENT Runtime_mapserver )
|
||||
endif( INSTALL_COMPONENT_RUNTIME )
|
||||
set( TARGET_LIST ${TARGET_LIST} map-server CACHE INTERNAL "" )
|
||||
message( STATUS "Creating target map-server - done" )
|
||||
endif( BUILD_SERVERS )
|
||||
target_link_libraries(map-server PUBLIC common)
|
||||
|
||||
|
||||
# map-server-generator
|
||||
add_executable(map-server-generator)
|
||||
|
||||
target_sources(map-server-generator PRIVATE ${MAP_SOURCES})
|
||||
|
||||
if(WIN32)
|
||||
target_sources(map-server-generator PRIVATE ${MAP_HEADERS})
|
||||
set_target_properties(map-server-generator PROPERTIES FOLDER "Tools")
|
||||
endif()
|
||||
|
||||
set_target_properties(map-server-generator PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||
|
||||
target_compile_definitions(map-server-generator PUBLIC "-DMAP_GENERATOR")
|
||||
|
||||
target_link_libraries(map-server-generator PUBLIC
|
||||
common
|
||||
json
|
||||
)
|
||||
|
||||
@ -1,80 +1,39 @@
|
||||
|
||||
# Define the tools interface library, all tools will inherit properties
|
||||
|
||||
add_library(tools INTERFACE)
|
||||
target_include_directories(tools INTERFACE
|
||||
${YAML_INCLUDE_DIRS}
|
||||
${ZLIB_INCLUDE_DIRS}
|
||||
${RA_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_sources(tools INTERFACE
|
||||
"${COMMON_SOURCE_DIR}/utils.cpp"
|
||||
"${COMMON_SOURCE_DIR}/des.cpp"
|
||||
"${COMMON_SOURCE_DIR}/grfio.cpp"
|
||||
"${COMMON_SOURCE_DIR}/nullpo.cpp"
|
||||
"${COMMON_SOURCE_DIR}/database.cpp"
|
||||
)
|
||||
|
||||
target_compile_definitions(tools INTERFACE
|
||||
"MINICORE"
|
||||
)
|
||||
|
||||
target_link_libraries(tools INTERFACE
|
||||
${GLOBAL_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
yaml-cpp
|
||||
ryml
|
||||
minicore
|
||||
)
|
||||
|
||||
# mapcache
|
||||
message( STATUS "Creating target mapcache" )
|
||||
add_executable(mapcache)
|
||||
target_link_libraries(mapcache PRIVATE tools)
|
||||
target_link_libraries(mapcache PRIVATE minicore)
|
||||
target_sources(mapcache PRIVATE "mapcache.cpp")
|
||||
set_target_properties(mapcache PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||
if(WIN32)
|
||||
set_target_properties(mapcache PROPERTIES FOLDER "Tools")
|
||||
endif()
|
||||
|
||||
|
||||
# csv2yaml
|
||||
message( STATUS "Creating target csv2yaml" )
|
||||
add_executable(csv2yaml)
|
||||
target_link_libraries(csv2yaml PRIVATE tools)
|
||||
target_link_libraries(csv2yaml PRIVATE minicore)
|
||||
target_sources(csv2yaml PRIVATE "csv2yaml.cpp")
|
||||
set_target_properties(csv2yaml PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||
if(WIN32)
|
||||
set_target_properties(csv2yaml PROPERTIES FOLDER "Tools")
|
||||
target_sources(csv2yaml PRIVATE
|
||||
"csv2yaml.hpp"
|
||||
"yaml.hpp"
|
||||
)
|
||||
endif()
|
||||
|
||||
# yaml2sql
|
||||
message( STATUS "Creating target yaml2sql" )
|
||||
add_executable(yaml2sql)
|
||||
target_link_libraries(yaml2sql PRIVATE tools)
|
||||
target_link_libraries(yaml2sql PRIVATE minicore)
|
||||
target_sources(yaml2sql PRIVATE "yaml2sql.cpp")
|
||||
set_target_properties(yaml2sql PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||
if(WIN32)
|
||||
set_target_properties(yaml2sql PROPERTIES FOLDER "Tools")
|
||||
endif()
|
||||
|
||||
# yamlupgrade
|
||||
message( STATUS "Creating target yamlupgrade" )
|
||||
add_executable(yamlupgrade)
|
||||
target_link_libraries(yamlupgrade PRIVATE tools)
|
||||
target_link_libraries(yamlupgrade PRIVATE minicore)
|
||||
target_sources(yamlupgrade PRIVATE "yamlupgrade.cpp")
|
||||
|
||||
set( TARGET_LIST ${TARGET_LIST} mapcache csv2yaml yaml2sql yamlupgrade CACHE INTERNAL "" )
|
||||
|
||||
if( INSTALL_COMPONENT_RUNTIME )
|
||||
cpack_add_component( Runtime_mapcache DESCRIPTION "mapcache generator" DISPLAY_NAME "mapcache" GROUP Runtime )
|
||||
install( TARGETS mapcache
|
||||
DESTINATION "."
|
||||
COMPONENT Runtime_mapcache
|
||||
set_target_properties(yamlupgrade PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||
if(WIN32)
|
||||
set_target_properties(yamlupgrade PROPERTIES FOLDER "Tools")
|
||||
target_sources(yamlupgrade PRIVATE
|
||||
"yamlupgrade.hpp"
|
||||
"yaml.hpp"
|
||||
)
|
||||
cpack_add_component( Runtime_csv2yaml DESCRIPTION "yaml converter" DISPLAY_NAME "csv2yaml" GROUP Runtime )
|
||||
install( TARGETS csv2yaml
|
||||
DESTINATION "."
|
||||
COMPONENT Runtime_csv2yaml
|
||||
)
|
||||
cpack_add_component( Runtime_yaml2sql DESCRIPTION "sql converter" DISPLAY_NAME "yaml2sql" GROUP Runtime )
|
||||
install( TARGETS yaml2sql
|
||||
DESTINATION "."
|
||||
COMPONENT Runtime_yaml2sql
|
||||
)
|
||||
cpack_add_component( Runtime_yamlupgrade DESCRIPTION "yaml upgrader" DISPLAY_NAME "yamlupgrade" GROUP Runtime )
|
||||
install( TARGETS yamlupgrade
|
||||
DESTINATION "."
|
||||
COMPONENT Runtime_yamlupgrade
|
||||
)
|
||||
install (TARGETS )
|
||||
endif( INSTALL_COMPONENT_RUNTIME )
|
||||
endif()
|
||||
|
||||
@ -1,41 +1,42 @@
|
||||
#
|
||||
# setup
|
||||
#
|
||||
set( WEB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
|
||||
add_executable(web-server)
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
#
|
||||
# web server
|
||||
#
|
||||
if ( NOT ENABLE_WEB_SERVER )
|
||||
return()
|
||||
endif ( NOT ENABLE_WEB_SERVER )
|
||||
target_sources(web-server PRIVATE
|
||||
"auth.cpp"
|
||||
"auth.hpp"
|
||||
"charconfig_controller.cpp"
|
||||
"emblem_controller.cpp"
|
||||
"merchantstore_controller.cpp"
|
||||
"partybooking_controller.cpp"
|
||||
"sqllock.cpp"
|
||||
"userconfig_controller.cpp"
|
||||
"web.cpp"
|
||||
"webutils.cpp"
|
||||
)
|
||||
|
||||
if( BUILD_SERVERS AND ENABLE_WEB_SERVER )
|
||||
message( STATUS "Creating target web-server" )
|
||||
file(GLOB WEB_HEADERS ${WEB_SOURCE_DIR}/*.hpp)
|
||||
file(GLOB WEB_SOURCES ${WEB_SOURCE_DIR}/*.cpp)
|
||||
set( DEPENDENCIES common yaml-cpp httplib)
|
||||
set( LIBRARIES ${GLOBAL_LIBRARIES})
|
||||
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS} ${HTTPLIB_INCLUDE_DIRS} ${JSON_INCLUDE_DIRS} ${RA_INCLUDE_DIRS} )
|
||||
set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS}" )
|
||||
set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} ${WEB_HEADERS} ${WEB_SOURCES} )
|
||||
source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} )
|
||||
source_group( web FILES ${WEB_HEADERS} ${WEB_SOURCES} )
|
||||
include_directories( ${INCLUDE_DIRS} )
|
||||
if(WIN32)
|
||||
target_sources(web-server PRIVATE
|
||||
"auth.hpp"
|
||||
"charconfig_controller.hpp"
|
||||
"emblem_controller.hpp"
|
||||
"http.hpp"
|
||||
"merchantstore_controller.hpp"
|
||||
"partybooking_controller.hpp"
|
||||
"sqllock.hpp"
|
||||
"userconfig_controller.hpp"
|
||||
"webcnslif.hpp"
|
||||
"web.hpp"
|
||||
"webutils.hpp"
|
||||
)
|
||||
|
||||
#message( STATUS "web-server SOURCE_FILES=${SOURCE_FILES}")
|
||||
add_executable( web-server ${SOURCE_FILES} )
|
||||
#message( STATUS "web-server LIBRARIES=${LIBRARIES}, DEPENDENCIES=${DEPENDENCIES} DEFINITIONS=${DEFINITIONS}")
|
||||
add_dependencies( web-server ${DEPENDENCIES} )
|
||||
target_link_libraries( web-server ${LIBRARIES} ${DEPENDENCIES} )
|
||||
set_target_properties( web-server PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
|
||||
if( INSTALL_COMPONENT_RUNTIME )
|
||||
cpack_add_component( Runtime_webserver DESCRIPTION "web-server" DISPLAY_NAME "web-server" GROUP Runtime )
|
||||
install( TARGETS web-server
|
||||
DESTINATION "."
|
||||
COMPONENT Runtime_webserver )
|
||||
endif( INSTALL_COMPONENT_RUNTIME )
|
||||
set( TARGET_LIST ${TARGET_LIST} web-server CACHE INTERNAL "" )
|
||||
message( STATUS "Creating target web-server - done" )
|
||||
endif( BUILD_SERVERS AND ENABLE_WEB_SERVER)
|
||||
set_target_properties(web-server PROPERTIES FOLDER "Servers")
|
||||
endif()
|
||||
|
||||
target_link_libraries(web-server PUBLIC
|
||||
common
|
||||
httplib
|
||||
Threads::Threads
|
||||
json
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user