Files
ROSS/CMakeLists.txt
T
ThomasandClaude Sonnet 5 1998bf4273 Strip dead Windows-only code paths, add LTO/march build flags, seed default GM account
Removes now-unreachable #ifdef _WIN32 branches across Common/ and the three
server binaries (all builds are Linux-only), deletes the entirely unused
SEH exception-handling shim and an orphaned vendored MySQL client header.
Enables LTO and -march=x86-64-v2 in Release builds for a small free perf win.

Also seeds a default GM account (gmadmin/changeme) via
database sql files/gm_account.sql so a fresh deploy has something to log
into the web admin panel with, switches the MariaDB data directory from a
Docker named volume to a host bind mount for visibility/backup, and expands
the README with a fuller Docker deployment walkthrough.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-10 15:42:36 +02:00

162 lines
5.5 KiB
CMake

cmake_minimum_required(VERSION 3.16)
project(ROSEServers CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
find_package(Threads REQUIRED)
# MariaDB/MySQL client library and headers (provided by the distro, e.g.
# libmariadb-dev). Falls back to pkg-config if the CMake package isn't found.
find_path(MYSQL_INCLUDE_DIR
NAMES mysql.h
PATH_SUFFIXES mysql mariadb
)
find_library(MYSQL_LIBRARY
NAMES mariadb mysqlclient
)
if(NOT MYSQL_INCLUDE_DIR OR NOT MYSQL_LIBRARY)
find_package(PkgConfig REQUIRED)
pkg_check_modules(MYSQL REQUIRED libmariadb)
endif()
add_compile_options(
-Wno-write-strings
-Wno-narrowing
# This 2006-era codebase relies throughout on signed-integer overflow
# wrapping (packet/crypto bit twiddling). That's UB in C++; at -O2/-O3
# GCC exploits it and miscompiles (observed: GenerateCryptTables SIGSEGV
# in Release builds only). -fwrapv makes overflow well-defined instead
# of auditing every arithmetic expression in the tree.
-fwrapv
# x86-64-v2 (SSE4.2/POPCNT baseline, ~2009+ CPUs) is safe for any real
# deployment target and gets a bit more codegen than the generic x86-64
# baseline GCC defaults to.
-march=x86-64-v2
-include "${CMAKE_SOURCE_DIR}/Src/Common/compat.h"
)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
# Link-time optimization: lets GCC inline/optimize across the many small
# .cpp translation units instead of only within each one.
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_ERROR)
if(IPO_SUPPORTED AND CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
endif()
set(COMMON_SOURCES
"Src/Common/config.cpp"
"Src/Common/database/database.cpp"
"Src/Common/globals.cpp"
"Src/Common/log.cpp"
"Src/Common/rosecrypt.cpp"
"Src/Common/SocketBase.cpp"
"Src/Common/SocketClient.cpp"
"Src/Common/SocketServer.cpp"
)
set(COMMON_INCLUDES
"${CMAKE_SOURCE_DIR}/Src/Common"
"${CMAKE_SOURCE_DIR}/Src/Common/database"
${MYSQL_INCLUDE_DIR}
${MYSQL_INCLUDE_DIRS}
)
set(COMMON_LIBS
Threads::Threads
${MYSQL_LIBRARY}
${MYSQL_LIBRARIES}
)
# ---------------------------------------------------------------------------
# Login Server
# ---------------------------------------------------------------------------
add_executable(loginserver
${COMMON_SOURCES}
"Src/Login Server/extrafunction.cpp"
"Src/Login Server/loginclient.cpp"
"Src/Login Server/loginpackets.cpp"
"Src/Login Server/loginserver.cpp"
"Src/Login Server/main.cpp"
"Src/Login Server/signal.cpp"
)
target_include_directories(loginserver PRIVATE ${COMMON_INCLUDES} "${CMAKE_SOURCE_DIR}/Src/Login Server")
target_link_libraries(loginserver PRIVATE ${COMMON_LIBS})
# ---------------------------------------------------------------------------
# Char Server
# ---------------------------------------------------------------------------
add_executable(charserver
${COMMON_SOURCES}
"Src/Char Server/charclient.cpp"
"Src/Char Server/charpackets.cpp"
"Src/Char Server/charserver.cpp"
"Src/Char Server/clan.cpp"
"Src/Char Server/community.cpp"
"Src/Char Server/extrafunctions.cpp"
"Src/Char Server/main.cpp"
"Src/Char Server/signal.cpp"
)
target_include_directories(charserver PRIVATE ${COMMON_INCLUDES} "${CMAKE_SOURCE_DIR}/Src/Char Server")
target_link_libraries(charserver PRIVATE ${COMMON_LIBS})
# ---------------------------------------------------------------------------
# World Server
# ---------------------------------------------------------------------------
add_executable(worldserver
${COMMON_SOURCES}
"Src/World Server/aip/AiActions.cpp"
"Src/World Server/aip/AiConditions.cpp"
"Src/World Server/aip/Aip.cpp"
"Src/World Server/battle.cpp"
"Src/World Server/Buff.cpp"
"Src/World Server/character.cpp"
"Src/World Server/charevent.cpp"
"Src/World Server/charfunctions.cpp"
"Src/World Server/charstats.cpp"
"Src/World Server/clan.cpp"
"Src/World Server/extrafunctions.cpp"
"Src/World Server/gmcmds.cpp"
"Src/World Server/itemdata.cpp"
"Src/World Server/main.cpp"
"Src/World Server/MainProcess.cpp"
"Src/World Server/mapfunctions.cpp"
"Src/World Server/Monster.cpp"
"Src/World Server/MonsterDamage.cpp"
"Src/World Server/MonsterEvents.cpp"
"Src/World Server/monsterfunctions.cpp"
"Src/World Server/MonsterStats.cpp"
"Src/World Server/Party.cpp"
"Src/World Server/partyfunctions.cpp"
"Src/World Server/player.cpp"
"Src/World Server/playerdata.cpp"
"Src/World Server/playerfunctions.cpp"
"Src/World Server/playerquest.cpp"
"Src/World Server/playerstats.cpp"
"Src/World Server/quest/QuestActions.cpp"
"Src/World Server/quest/QuestConditions.cpp"
"Src/World Server/quest/Quests.cpp"
"Src/World Server/ServerFunctions.cpp"
"Src/World Server/Signal.cpp"
"Src/World Server/startup.cpp"
"Src/World Server/stbhandler.cpp"
"Src/World Server/stb_manager.cpp"
"Src/World Server/stlhandler.cpp"
"Src/World Server/strhashing.cpp"
"Src/World Server/worldmap.cpp"
"Src/World Server/WorldMonster.cpp"
"Src/World Server/worldpackets.cpp"
"Src/World Server/Worldprocess.cpp"
"Src/World Server/worldserver.cpp"
)
target_include_directories(worldserver PRIVATE ${COMMON_INCLUDES} "${CMAKE_SOURCE_DIR}/Src/World Server")
target_link_libraries(worldserver PRIVATE ${COMMON_LIBS})
install(TARGETS loginserver charserver worldserver RUNTIME DESTINATION bin)