build: CMake superbuild for game/login/querymanager + line-ending policy

This commit is contained in:
code.lyoko 2026-11-13 10:20:14 -06:00
parent aaea698c99
commit 4df7057642
3 changed files with 178 additions and 0 deletions

71
src/game/CMakeLists.txt Normal file
View file

@ -0,0 +1,71 @@
cmake_minimum_required(VERSION 3.16)
project(game LANGUAGES CXX)
# 28 objects from the original Makefile in the same order
add_executable(game
src/main.cc
src/communication.cc
src/config.cc
src/connections.cc
src/cract.cc
src/crcombat.cc
src/crmain.cc
src/crnonpl.cc
src/crplayer.cc
src/crskill.cc
src/crypto.cc
src/houses.cc
src/info.cc
src/magic.cc
src/map.cc
src/moveuse.cc
src/objects.cc
src/operate.cc
src/query.cc
src/reader.cc
src/receiving.cc
src/script.cc
src/sending.cc
src/shm.cc
src/strings.cc
src/threads.cc
src/time.cc
src/utils.cc
src/writer.cc
)
target_include_directories(game PRIVATE src)
# Flags del Makefile original (CFLAGS)
target_compile_options(game PRIVATE
-fno-strict-aliasing
-pedantic
-Wall -Wextra
-Wno-deprecated-declarations
-Wno-unused-parameter
-Wno-format-truncation
)
# Original Makefile defines: OS/arch (TIBIA722 inherits from the superbuild,
# replacing the sed over CFLAGS that was done before)
target_compile_definitions(game PRIVATE
OS_LINUX=1
ARCH_X64=1
$<$<CONFIG:Debug>:ENABLE_ASSERTIONS=1>
)
set_target_properties(game PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
# LFLAGS: -lrt -lcrypto -pthread
target_link_libraries(game PRIVATE
rt
crypto
pthread
)
install(TARGETS game RUNTIME DESTINATION bin)

43
src/login/CMakeLists.txt Normal file
View file

@ -0,0 +1,43 @@
cmake_minimum_required(VERSION 3.16)
project(login LANGUAGES CXX)
find_package(OpenSSL REQUIRED) # -lcrypto
find_package(Threads REQUIRED) # -pthread
add_executable(login
src/main.cc
src/crypto.cc
src/connections.cc
src/query.cc
src/status.cc
)
target_include_directories(login PRIVATE SRC)
# Original Makefile flags
target_compile_options(login PRIVATE
-fno-strict-aliasing
-Wno-deprecated-declarations
-pedantic -Wall -Wextra
)
# C++11 (Original standard used for the build)
set_target_properties(login PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
# ENABLE_ASSERTIONS in Debug builds (Makefile DEBUG=1 equivalent)
target_compile_definitions(login PRIVATE
$<$<CONFIG:Debug>:ENABLE_ASSERTIONS=1>
)
target_link_libraries(login PRIVATE
crypto
pthread
)
install(TARGETS login RUNTIME DESTINATION bin)

View file

@ -0,0 +1,64 @@
cmake_minimum_required(VERSION 3.16)
project(querymanager LANGUAGES C CXX)
set(QM_DATABASE "sqlite" CACHE STRING "DB backend: sqlite | mariadb | mysql")
set_property(CACHE QM_DATABASE PROPERTY STRINGS sqlite postgres mariadb)
if(NOT QM_DATABASE MATCHES "^(sqlite|postgres|mariadb)$")
message(FATAL_ERROR "QM_DATABASE not supported: $(QM_DATABASE)")
endif()
# Common objects (querymanager.hh its the header)
set(QM_COMMON
src/querymanager.cc
src/connections.cc
src/hostcache.cc
src/query.cc
src/sha256.cc
)
add_executable(querymanager ${QM_COMMON})
if(QM_DATABASE STREQUAL "sqlite")
target_sources(querymanager PRIVATE
src/database_sqlite.cc
src/sqlite3.c
)
target_compile_definitions(querymanager PRIVATE DATABASE_SQLITE=1)
elseif(QM_DATABASE STREQUAL "postgres")
target_sources(querymanager PRIVATE src/database_postgres.cc)
target_compile_definitions(querymanager PRIVATE DATABASE_POSTGRESQL=1)
target_compile_definitions(querymanager PRIVATE usr/include/postgresql)
target_link_libraries(querymanager PRIVATE pq)
elseif(QM_DATABASE STREQUAL "mariadb")
target_sources(querymanager PRIVATE src/database_mariadb.cc)
target_compile_definitions(querymanager PRIVATE DATABASE_MARIADB=1)
target_include_directories(querymanager PRIVATE /usr/include/mariadb)
target_link_libraries(querymanager PRIVATE mariadb)
endif()
target_include_directories(querymanager PRIVATE src)
# Original Makefile Flags
target_compile_options(querymanager PRIVATE
-fno-strict-aliasing
-pedantic
-Wall
-Wextra
)
set_target_properties(querymanager PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
target_compile_definitions(querymanager PRIVATE
$<$<CONFIG:Debug>:ENABLE_ASSERTIONS=1>
)
target_link_libraries(querymanager PRIVATE pthread)
install(TARGETS querymanager RUNTIME DESTINATION bin)