find_package(LibXml2 REQUIRED) find_package(PhysFS REQUIRED) find_package(ZLIB REQUIRED) find_package(SigC++ REQUIRED) find_package(RapidJSON REQUIRED) if(CMAKE_COMPILER_IS_GNUCXX) # Help getting compilation warnings set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") if(WIN32) # This includes enough debug information to get something useful from Dr. # Mingw while keeping binary size down. Almost useless with gdb, though. set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -ggdb0 -gstabs2") endif() endif() if(POLICY CMP0015) cmake_policy(SET CMP0015 OLD) endif() if(ENABLE_EXTERNAL_ENET) include_directories(${ENet_INCLUDE_DIR}) set(OPTIONAL_LIBRARIES ${OPTIONAL_LIBRARIES} ${ENet_LIBRARY}) else(ENABLE_EXTERNAL_ENET) include_directories("../libs/enet/include") link_directories("../libs/enet") set(INTERNAL_LIBRARIES enet) endif(ENABLE_EXTERNAL_ENET) # enable rc-handling with mingw most likely this part can be kicked out with # some later cmake version if(MINGW) find_path(MINGW_INCLUDE_DIR windows.h $ENV{INCLUDE}) if(MINGW_INCLUDE_DIR) message(STATUS "Found mingw headers: ${MINGW_INCLUDE_DIR}") include_directories(${MINGW_INCLUDE_DIR}) else() message(FATAL_ERROR "Unable to find mingw headers. Required for windres") endif() set(CMAKE_RC_COMPILER_INIT windres) enable_language(RC) set(CMAKE_RC_COMPILE_OBJECT " -O coff -o ") endif() set(FLAGS "${FLAGS} -DPACKAGE_VERSION=\\\"${VERSION}\\\"") set(FLAGS "${FLAGS} -DPKG_DATADIR=\\\"${PKG_DATADIR}/\\\"") set(FLAGS "${FLAGS} -DLOCALEDIR=\\\"${LOCALEDIR}/\\\"") set(FLAGS "${FLAGS} -std=c++17") set(FLAGS "${FLAGS} -Woverloaded-virtual") # Prevent clashes with icu namespace set(FLAGS "${FLAGS} -DU_USING_ICU_NAMESPACE=0") # If the Sqlite option is enabled... if(WITH_SQLITE) find_package(Sqlite3 REQUIRED) include_directories(${SQLITE3_INCLUDE_DIR}) set(FLAGS "${FLAGS} -DSQLITE_SUPPORT") set(OPTIONAL_LIBRARIES ${OPTIONAL_LIBRARIES} ${SQLITE3_LIBRARIES}) endif(WITH_SQLITE) # If the MySQL option is enabled... if(WITH_MYSQL) find_package(MySQL REQUIRED) include_directories(${MYSQL_INCLUDE_DIR}) set(FLAGS "${FLAGS} -DMYSQL_SUPPORT") set(OPTIONAL_LIBRARIES ${OPTIONAL_LIBRARIES} ${MYSQL_LIBRARIES}) endif() # If the postgreSQL option is enabled... if(WITH_POSTGRESQL) find_package(PostgreSQL REQUIRED) include_directories(${POSTGRESQL_INCLUDE_DIR}) set(FLAGS "${FLAGS} -DPOSTGRESQL_SUPPORT") set(OPTIONAL_LIBRARIES ${OPTIONAL_LIBRARIES} ${POSTGRESQL_LIBRARIES}) endif() # If the Lua scripting language support is enabled... if(ENABLE_LUA) find_package(Lua REQUIRED) include_directories(${LUA_INCLUDE_DIR}) set(FLAGS "${FLAGS} -DBUILD_LUA") set(OPTIONAL_LIBRARIES ${OPTIONAL_LIBRARIES} ${LUA_LIBRARIES}) endif() if(CMAKE_BUILD_TYPE) string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) if(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug OR CMAKE_BUILD_TYPE_TOLOWER MATCHES relwithdebinfo) set(FLAGS "${FLAGS} -DDEBUG") endif() endif() if(WIN32) set(EXTRA_LIBRARIES ws2_32 winmm) # GDI APIs Rectangle clashes with tmwserv classes set(FLAGS "${FLAGS} -DNOGDI") elseif(CMAKE_SYSTEM_NAME STREQUAL SunOS) # explicit linking to libintl is required on Solaris set(EXTRA_LIBRARIES intl) endif() include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${PHYSFS_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} ${SIGC++_INCLUDE_DIR} ${SIGC++Config_INCLUDE_DIR}) # Fix some stuff that gets not hidden by mainline modules mark_as_advanced(PHYSFS_INCLUDE_DIR) mark_as_advanced(PHYSFS_LIBRARY) set(SRCS common/configuration.h common/configuration.cpp common/defines.h common/inventorydata.h common/manaserv_protocol.h common/resourcemanager.h common/resourcemanager.cpp net/bandwidth.h net/bandwidth.cpp net/connection.h net/connection.cpp net/connectionhandler.h net/connectionhandler.cpp net/messagein.h net/messagein.cpp net/messageout.h net/messageout.cpp net/netcomputer.h net/netcomputer.cpp utils/logger.h utils/logger.cpp utils/point.h utils/processorutils.h utils/processorutils.cpp utils/string.h utils/string.cpp utils/stringfilter.h utils/stringfilter.cpp utils/timer.h utils/timer.cpp utils/tokencollector.h utils/tokencollector.cpp utils/tokendispenser.h utils/tokendispenser.cpp utils/xml.h utils/xml.cpp) set(SRCS_MANASERVACCOUNT account-server/main-account.cpp account-server/account.h account-server/account.cpp account-server/accountclient.h account-server/accountclient.cpp account-server/accounthandler.h account-server/accounthandler.cpp account-server/character.h account-server/character.cpp account-server/flooritem.h account-server/mapmanager.h account-server/mapmanager.cpp account-server/serverhandler.h account-server/serverhandler.cpp account-server/storage.h account-server/storage.cpp chat-server/chathandler.h chat-server/chathandler.cpp chat-server/chatclient.h chat-server/chatchannel.h chat-server/chatchannel.cpp chat-server/chatchannelmanager.h chat-server/chatchannelmanager.cpp chat-server/guild.h chat-server/guild.cpp chat-server/guildhandler.cpp chat-server/guildmanager.h chat-server/guildmanager.cpp chat-server/party.cpp chat-server/party.h chat-server/partyhandler.cpp chat-server/post.cpp chat-server/post.h dal/dalexcept.h dal/dataprovider.h dal/dataprovider.cpp dal/dataproviderfactory.h dal/dataproviderfactory.cpp dal/recordset.h dal/recordset.cpp utils/functors.h utils/sha256.h utils/sha256.cpp utils/throwerror.h utils/time.h) set(SRCS_MANASERVGAME game-server/main-game.cpp common/permissionmanager.h common/permissionmanager.cpp game-server/abilitycomponent.cpp game-server/abilitycomponent.h game-server/abilitymanager.cpp game-server/abilitymanager.h game-server/accountconnection.h game-server/accountconnection.cpp game-server/actorcomponent.h game-server/actorcomponent.cpp game-server/attribute.h game-server/attribute.cpp game-server/attributemanager.h game-server/attributemanager.cpp game-server/being.h game-server/being.cpp game-server/buysell.h game-server/buysell.cpp game-server/charactercomponent.h game-server/charactercomponent.cpp game-server/collisiondetection.h game-server/collisiondetection.cpp game-server/commandhandler.cpp game-server/commandhandler.h game-server/component.h game-server/effect.h game-server/effect.cpp game-server/emotemanager.h game-server/emotemanager.cpp game-server/entity.h game-server/entity.cpp game-server/gamehandler.h game-server/gamehandler.cpp game-server/inventory.h game-server/inventory.cpp game-server/item.h game-server/item.cpp game-server/itemmanager.h game-server/itemmanager.cpp game-server/map.h game-server/map.cpp game-server/mapcomposite.h game-server/mapcomposite.cpp game-server/mapmanager.h game-server/mapmanager.cpp game-server/mapreader.h game-server/mapreader.cpp game-server/monster.h game-server/monster.cpp game-server/monstermanager.h game-server/monstermanager.cpp game-server/npc.h game-server/npc.cpp game-server/postman.h game-server/quest.h game-server/quest.cpp game-server/settingsmanager.h game-server/settingsmanager.cpp game-server/spawnareacomponent.h game-server/spawnareacomponent.cpp game-server/state.h game-server/state.cpp game-server/statuseffect.h game-server/statuseffect.cpp game-server/statusmanager.h game-server/statusmanager.cpp game-server/timeout.h game-server/timeout.cpp game-server/trade.h game-server/trade.cpp game-server/triggerareacomponent.h game-server/triggerareacomponent.cpp scripting/script.h scripting/script.cpp scripting/scriptmanager.h scripting/scriptmanager.cpp utils/base64.h utils/base64.cpp utils/mathutils.h utils/mathutils.cpp utils/speedconv.h utils/speedconv.cpp utils/zlib.h utils/zlib.cpp) if(WIN32) set(SRCS_MANASERVACCOUNT ${SRCS_MANASERVACCOUNT} manaserv-account.rc) set(SRCS_MANASERVGAME ${SRCS_MANASERVGAME} manaserv-game.rc) endif() if(WITH_MYSQL) set(SRCS_MANASERVACCOUNT ${SRCS_MANASERVACCOUNT} dal/mysqldataprovider.h dal/mysqldataprovider.cpp) endif() if(WITH_POSTGRESQL) set(SRCS_MANASERVACCOUNT ${SRCS_MANASERVACCOUNT} dal/pqdataprovider.h dal/pqdataprovider.cpp) endif() if(WITH_SQLITE) set(SRCS_MANASERVACCOUNT ${SRCS_MANASERVACCOUNT} dal/sqlitedataprovider.h dal/sqlitedataprovider.cpp) endif() if(ENABLE_LUA) set(SRCS_MANASERVGAME ${SRCS_MANASERVGAME} scripting/lua.cpp scripting/luascript.cpp scripting/luascript.h scripting/luautil.cpp scripting/luautil.h) endif() set(PROGRAMS manaserv-account manaserv-game) add_executable(manaserv-game WIN32 ${SRCS} ${SRCS_MANASERVGAME}) add_executable(manaserv-account WIN32 ${SRCS} ${SRCS_MANASERVACCOUNT}) target_include_directories(manaserv-account SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/libs/uWebSockets/src ${CMAKE_SOURCE_DIR}/libs/uWebSockets/uSockets/src ${RAPIDJSON_INCLUDE_DIRS}) target_link_libraries(manaserv-account ${CMAKE_SOURCE_DIR}/libs/uWebSockets/uSockets/uSockets.a) foreach(program ${PROGRAMS}) target_link_libraries( ${program} ${INTERNAL_LIBRARIES} ${PHYSFS_LIBRARY} ${LIBXML2_LIBRARIES} ${ZLIB_LIBRARIES} ${SIGC++_LIBRARIES} ${OPTIONAL_LIBRARIES} ${EXTRA_LIBRARIES}) install(TARGETS ${program} RUNTIME DESTINATION ${PKG_BINDIR}) endforeach(program) if(CMAKE_SYSTEM_NAME STREQUAL SunOS) # we expect the SMCgtxt package to be present on Solaris; the Solaris gettext # is not API-compatible to GNU gettext set_target_properties(manaserv-account PROPERTIES LINK_FLAGS "-L/usr/local/lib") set_target_properties(manaserv-game PROPERTIES LINK_FLAGS "-L/usr/local/lib") endif() set_target_properties(manaserv-account PROPERTIES COMPILE_FLAGS "${FLAGS}") set_target_properties(manaserv-game PROPERTIES COMPILE_FLAGS "${FLAGS}") install(DIRECTORY sql DESTINATION ${PKG_DATADIR})