2026-01-16 10:13:40 +01:00
|
|
|
# Require the latest CMake version.
|
|
|
|
|
cmake_minimum_required(VERSION 4.2.1)
|
|
|
|
|
|
|
|
|
|
project(archipelago)
|
|
|
|
|
|
|
|
|
|
# ExternalContent, the better FetchContent and ExternalProject. Even beats CPM because it isn't written to be fancy!
|
|
|
|
|
include(cmake/externalcontent/ExternalContent.cmake)
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------#
|
|
|
|
|
# Options
|
|
|
|
|
#--------------------------------------------------------------------------------#
|
|
|
|
|
|
2026-01-16 20:14:55 +01:00
|
|
|
set(CACHE{ENABLE_SSL} TYPE BOOL HELP "Enable SSL support via wolfSSL?" VALUE ON)
|
|
|
|
|
|
2026-01-16 10:13:40 +01:00
|
|
|
#--------------------------------------------------------------------------------#
|
|
|
|
|
# Libraries
|
|
|
|
|
#--------------------------------------------------------------------------------#
|
|
|
|
|
|
|
|
|
|
if(TRUE) # ASIO (Standalone)
|
|
|
|
|
ExternalContent(
|
|
|
|
|
NAME "asio"
|
|
|
|
|
DOWNLOAD_URL "https://altushost-swe.dl.sourceforge.net/project/asio/asio/1.36.0%20%28Stable%29/asio-1.36.0.zip?viasf=1"
|
2026-01-16 20:14:55 +01:00
|
|
|
DOWNLOAD_FILE "asio-1.36.0.zip"
|
2026-01-16 10:13:40 +01:00
|
|
|
DOWNLOAD_HASH "SHA512;6D867F6C63BC259110E00726D0DD38090F5E55EE01EEFF94A3590B1351967FD7E19EE8F7601A197723FA072CEA8F29D00A7C60A8E97D441CE3D931EE1A098F06"
|
|
|
|
|
SKIP_CONFIGURE
|
|
|
|
|
SKIP_BUILD
|
|
|
|
|
SKIP_INSTALL
|
|
|
|
|
)
|
2026-01-16 20:14:55 +01:00
|
|
|
if(NOT TARGET asio)
|
|
|
|
|
add_library("asio" INTERFACE)
|
|
|
|
|
file(GLOB_RECURSE _FILES FOLLOW_SYMLINKS CONFIGURE_DEPENDS "${asio_SOURCE_PATH}/include/*")
|
|
|
|
|
source_group(TREE "${asio_SOURCE_PATH}/include" PREFIX "" FILES ${_FILES})
|
|
|
|
|
target_sources("asio"
|
|
|
|
|
PRIVATE ${_FILES}
|
|
|
|
|
)
|
|
|
|
|
target_include_directories("asio"
|
|
|
|
|
INTERFACE "${asio_SOURCE_PATH}/include"
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
if(NOT TARGET boost::asio)
|
|
|
|
|
add_library("boost::asio" ALIAS "asio")
|
|
|
|
|
endif()
|
2026-01-16 10:13:40 +01:00
|
|
|
endif()
|
|
|
|
|
|
2026-01-16 20:14:55 +01:00
|
|
|
if(TRUE) # nlohmann's JSON
|
|
|
|
|
ExternalContent(
|
|
|
|
|
NAME "nlohmann_json"
|
|
|
|
|
GIT_URL "https://github.com/nlohmann/json.git"
|
|
|
|
|
GIT_REF "v3.12.0"
|
|
|
|
|
GIT_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules
|
|
|
|
|
GIT_CHECKOUT_OPTIONS --recurse-submodules
|
|
|
|
|
CONFIGURE_OPTIONS -D JSON_BuildTests:BOOL=OFF -D JSON_CI:BOOL=OFF -D JSON_MultipleHeaders:BOOL=OFF
|
|
|
|
|
SKIP_BUILD
|
|
|
|
|
)
|
|
|
|
|
find_package("nlohmann_json" REQUIRED CONFIG
|
|
|
|
|
PATHS "${nlohmann_json_INSTALL_PATH}"
|
|
|
|
|
)
|
|
|
|
|
endif()
|
2026-01-16 10:13:40 +01:00
|
|
|
|
2026-01-16 20:14:55 +01:00
|
|
|
if(TRUE) # badaix's JSONRPC++
|
|
|
|
|
ExternalContent(
|
|
|
|
|
NAME "jsonrpcpp"
|
|
|
|
|
GIT_URL "https://github.com/badaix/jsonrpcpp.git"
|
|
|
|
|
GIT_REF "v1.4.0"
|
|
|
|
|
GIT_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules
|
|
|
|
|
GIT_CHECKOUT_OPTIONS --recurse-submodules
|
|
|
|
|
CONFIGURE_ARGS -D BUILD_EXAMPLE:BOOL=OFF -D BUILD_TESTS:BOOL=OFF -D CATCH_INSTALL_DOCS:BOOL=OFF -D CATCH_INSTALL_EXTRAS:BOOL=ON
|
|
|
|
|
BUILD_ARGS --parallel --config Release --clean-first
|
|
|
|
|
)
|
2026-01-16 10:13:40 +01:00
|
|
|
|
2026-01-16 20:14:55 +01:00
|
|
|
# This doesn't have a proper CMake module yet.
|
|
|
|
|
if(NOT TARGET jsonrpcpp)
|
|
|
|
|
add_library("jsonrpcpp" INTERFACE)
|
|
|
|
|
file(GLOB_RECURSE _FILES FOLLOW_SYMLINKS CONFIGURE_DEPENDS "${badaix-jsonrpc_SOURCE_PATH}/include/*")
|
|
|
|
|
source_group(TREE "${badaix-jsonrpc_SOURCE_PATH}/include" PREFIX "" FILES ${_FILES})
|
|
|
|
|
target_sources("jsonrpcpp"
|
|
|
|
|
PRIVATE ${_FILES}
|
|
|
|
|
)
|
|
|
|
|
target_include_directories("jsonrpcpp"
|
|
|
|
|
INTERFACE "${jsonrpcpp}/include"
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
if(NOT TARGET badaix::jsonrpcpp)
|
|
|
|
|
add_library("badaix::jsonrpcpp" ALIAS "jsonrpcpp")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
2026-01-16 10:13:40 +01:00
|
|
|
|
2026-01-16 20:14:55 +01:00
|
|
|
if(TRUE) # WebSocket++
|
|
|
|
|
ExternalContent(
|
|
|
|
|
NAME "websocketpp"
|
|
|
|
|
GIT_URL "https://github.com/xaymar/websocketpp.git"
|
|
|
|
|
GIT_REF "patch-modern-cpp-and-asio"
|
|
|
|
|
GIT_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules
|
|
|
|
|
GIT_CHECKOUT_OPTIONS --recurse-submodules
|
|
|
|
|
CONFIGURE_ARGS -D ENABLE_CPP11:BOOL=ON -D BUILD_EXAMPLES:BOOL=OFF -D BUILD_TESTS:BOOL=OFF -D USE_ASIO_STANDALONE:BOOL=ON
|
|
|
|
|
BUILD_ARGS --parallel --config Release
|
|
|
|
|
)
|
|
|
|
|
find_package("websocketpp" REQUIRED CONFIG
|
|
|
|
|
PATHS "${websocketpp_INSTALL_PATH}"
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(ENABLE_SSL) # wolfssl
|
|
|
|
|
ExternalContent(
|
|
|
|
|
NAME "wolfssl"
|
|
|
|
|
GIT_URL "https://github.com/wolfSSL/wolfssl.git"
|
|
|
|
|
GIT_REF "v5.8.4-stable"
|
|
|
|
|
GIT_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules
|
|
|
|
|
GIT_CHECKOUT_OPTIONS --recurse-submodules
|
|
|
|
|
CONFIGURE_ARGS -D BUILD_SHARED_LIBS:BOOL=OFF -D CMAKE_BUILD_TYPE:STRING=RelWithDebInfo -D WOLFSSL_CRYPT_TESTS:BOOL=OFF -D WOLFSSL_EXAMPLES:BOOL=OFF
|
|
|
|
|
BUILD_ARGS --parallel --config Release --clean-first
|
|
|
|
|
)
|
|
|
|
|
find_package("wolfssl" REQUIRED CONFIG
|
|
|
|
|
PATHS "${wolfssl_INSTALL_PATH}"
|
|
|
|
|
)
|
|
|
|
|
endif()
|
2026-01-16 10:13:40 +01:00
|
|
|
|
2026-01-16 21:00:58 +01:00
|
|
|
if(TRUE) # Database support
|
|
|
|
|
# PostGreSQL
|
|
|
|
|
find_package("libpqxx" OPTIONAL)
|
|
|
|
|
# MariaDB
|
|
|
|
|
find_package("libmariadb" OPTIONAL)
|
|
|
|
|
endif()
|
|
|
|
|
|
2026-01-16 10:13:40 +01:00
|
|
|
#--------------------------------------------------------------------------------#
|
|
|
|
|
# Project
|
|
|
|
|
#--------------------------------------------------------------------------------#
|
|
|
|
|
|
|
|
|
|
file(GLOB_RECURSE _INCLUDE FOLLOW_SYMLINKS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/pub/*")
|
|
|
|
|
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/pub" PREFIX "Public" FILES ${_INCLUDE})
|
|
|
|
|
|
|
|
|
|
file(GLOB_RECURSE _SOURCE FOLLOW_SYMLINKS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/priv/*")
|
|
|
|
|
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/priv" PREFIX "Private" FILES ${_SOURCE})
|
|
|
|
|
|
|
|
|
|
add_executable("room-server")
|
|
|
|
|
|
|
|
|
|
target_sources("room-server"
|
|
|
|
|
PRIVATE
|
|
|
|
|
${_SOURCE}
|
|
|
|
|
PUBLIC
|
|
|
|
|
${_INCLUDE}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
target_include_directories("room-server"
|
|
|
|
|
PRIVATE
|
|
|
|
|
"priv"
|
|
|
|
|
"pub/apsr"
|
|
|
|
|
PUBLIC
|
|
|
|
|
"pub"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
target_link_libraries("room-server"
|
|
|
|
|
PRIVATE
|
2026-01-16 20:14:55 +01:00
|
|
|
wolfSSL
|
|
|
|
|
nlohmann_json::nlohmann_json
|
|
|
|
|
badaix::jsonrpcpp
|
|
|
|
|
websocketpp::websocketpp
|
2026-01-16 10:13:40 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set_target_properties("room-server" PROPERTIES
|
|
|
|
|
# Always generate position independent code.
|
|
|
|
|
POSITION_INDEPENDENT_CODE ON
|
|
|
|
|
|
|
|
|
|
# Set C++ Standard and Extensions
|
|
|
|
|
C_STANDARD 17
|
|
|
|
|
C_STANDARD_REQUIRED ON
|
|
|
|
|
CXX_STANDARD 20
|
|
|
|
|
CXX_STANDARD_REQUIRED ON
|
|
|
|
|
CXX_EXTENSIONS OFF
|
|
|
|
|
|
|
|
|
|
# Remove prefix from generated files.
|
|
|
|
|
PREFIX ""
|
|
|
|
|
IMPORT_PREFIX ""
|
|
|
|
|
|
|
|
|
|
# Never treat warnings as errors.
|
|
|
|
|
COMPILE_WARNING_AS_ERROR OFF
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
|
# Disable/Enable a ton of things.
|
|
|
|
|
target_compile_definitions("room-server" PRIVATE
|
|
|
|
|
# Microsoft Visual C++
|
|
|
|
|
_CRT_SECURE_NO_WARNINGS
|
|
|
|
|
_ENABLE_EXTENDED_ALIGNED_STORAGE
|
|
|
|
|
|
|
|
|
|
# Windows version target
|
|
|
|
|
_WIN32_WINNT=0x0A00
|
|
|
|
|
)
|
|
|
|
|
endif()
|