Latest work

This commit is contained in:
Xaymar
2026-01-18 07:37:00 +01:00
parent fd8a1b8541
commit 18709cde46
3 changed files with 89 additions and 78 deletions
+88 -77
View File
@@ -1,8 +1,22 @@
# Copyright 2025-2026 Narta Xaymar Dirks <info@xaymar.com>
#
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Require the latest CMake version.
cmake_minimum_required(VERSION 4.2.1)
project(archipelago)
cmake_host_system_information(RESULT _JOBS QUERY NUMBER_OF_LOGICAL_CORES)
# ExternalContent, the better FetchContent and ExternalProject. Even beats CPM because it isn't written to be fancy!
include(cmake/externalcontent/ExternalContent.cmake)
@@ -30,27 +44,13 @@ endif()
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"
DOWNLOAD_FILE "asio-1.36.0.zip"
DOWNLOAD_HASH "SHA512;6D867F6C63BC259110E00726D0DD38090F5E55EE01EEFF94A3590B1351967FD7E19EE8F7601A197723FA072CEA8F29D00A7C60A8E97D441CE3D931EE1A098F06"
SKIP_CONFIGURE
GIT_URL "https://github.com/xaymar/asio"
GIT_REF "root"
SKIP_BUILD
SKIP_INSTALL
)
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()
find_package(asio REQUIRED CONFIG
PATHS "${asio_INSTALL_PATH}"
)
endif()
if(TRUE) # nlohmann's JSON
@@ -58,7 +58,7 @@ if(TRUE) # nlohmann's JSON
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_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules --shallow-submodules -j ${_JOBS}
GIT_CHECKOUT_OPTIONS --recurse-submodules
CONFIGURE_OPTIONS -D JSON_BuildTests:BOOL=OFF -D JSON_CI:BOOL=OFF -D JSON_MultipleHeaders:BOOL=OFF
SKIP_BUILD
@@ -68,6 +68,56 @@ if(TRUE) # nlohmann's JSON
)
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 --shallow-submodules -j ${_JOBS}
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()
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 --shallow-submodules -j ${_JOBS}
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
# Try and fix C++11 support.
CONFIGURE_ARGS -D "CMAKE_CPP_COMPILER_FLAGS=-D_WEBSOCKETPP_CPP11_STL_" -D "CMAKE_CPP_COMPILER_FLAGS=-D_WEBSOCKETPP_CPP11_STL_"
# Optional: SSL support.
CONFIGURE_ARGS -D OPENSSL_INCLUDE_DIR:STRING="${wolfssl_INSTALL_PATH}/include" -D OPENSSL_LIBRARIES:STRING="${wolfssl_INSTALL_PATH}/lib/wolfssl.lib" -D OPENSSL_VERSION:STRING="5.8.4" -D OPENSSL_FOUND:BOOL=ON
BUILD_ARGS --parallel --config Release
)
find_package("websocketpp" REQUIRED CONFIG
PATHS "${websocketpp_INSTALL_PATH}"
)
endif()
if(ENABLE_COMPRESSION) # Compression support
# zlib-ng - zlib, but for modern systems
ExternalContent(
NAME "zlib-ng"
GIT_URL "https://github.com/zlib-ng/zlib-ng.git"
GIT_REF "2.3.2"
GIT_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules --shallow-submodules -j ${_JOBS}
GIT_CHECKOUT_OPTIONS --recurse-submodules
CONFIGURE_ARGS -D BUILD_SHARED_LIBS:BOOL=OFF -D CMAKE_C_STANDARD:STRING=17 -D BUILD_TESTING:BOOL=OFF -D WITH_GTEST:BOOL=OFF -D WITH_FUZZERS:BOOL=OFF -D WITH_BENCHMARKS:BOOL=OFF -D WITH_BENCHMARK_APPS:BOOL=OFF -D INSTALL_UTILS:BOOL=OFF
BUILD_ARGS --parallel --config Release --clean-first
)
find_package("zlib-ng" REQUIRED CONFIG
PATHS "${zlib-ng_INSTALL_PATH}"
)
endif()
if(TRUE) # badaix's JSONRPC++
#!TODO: Replace with our own, this implementation isn't compliant with C++ standards at all.
@@ -87,23 +137,19 @@ if(TRUE) # badaix's JSONRPC++
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_CLONE_OPTIONS --depth 1 --no-single-branch --recurse-submodules --shallow-submodules -j ${_JOBS}
GIT_CHECKOUT_OPTIONS --recurse-submodules
PATCH_FUNCTION jsonrpcpp_patch
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
SKIP_BUILD # Not necessary
SKIP_INSTALL # Not necessary
)
# 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 "${jsonrpcpp_SOURCE_PATH}/include/*")
source_group(TREE "${jsonrpcpp_SOURCE_PATH}/include" PREFIX "" FILES ${_FILES})
target_sources("jsonrpcpp"
PRIVATE ${_FILES}
)
add_library("jsonrpcpp" INTERFACE IMPORTED)
target_include_directories("jsonrpcpp"
INTERFACE "${jsonrpcpp_INSTALL_PATH}/include"
INTERFACE "${jsonrpcpp_SOURCE_PATH}/include"
)
target_link_libraries("jsonrpcpp"
INTERFACE "nlohmann_json::nlohmann_json"
@@ -114,52 +160,6 @@ if(TRUE) # badaix's JSONRPC++
endif()
endif()
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()
if(ENABLE_COMPRESSION) # Compression support
# zlib-ng - zlib, but for modern systems
ExternalContent(
NAME "zlib-ng"
GIT_URL "https://github.com/zlib-ng/zlib-ng.git"
GIT_REF "2.3.2"
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_C_STANDARD:STRING=17 -D BUILD_TESTING:BOOL=OFF -D WITH_GTEST:BOOL=OFF -D WITH_FUZZERS:BOOL=OFF -D WITH_BENCHMARKS:BOOL=OFF -D WITH_BENCHMARK_APPS:BOOL=OFF -D INSTALL_UTILS:BOOL=OFF
BUILD_ARGS --parallel --config Release --clean-first
)
find_package("zlib-ng" REQUIRED CONFIG
PATHS "${zlib-ng_INSTALL_PATH}"
)
endif()
#--------------------------------------------------------------------------------#
# Project
#--------------------------------------------------------------------------------#
@@ -190,10 +190,15 @@ target_include_directories("room-server"
target_link_libraries("room-server"
PRIVATE
wolfSSL
# I/O
asio::asio
# Transport
websocketpp::websocketpp
# Compression
zlib-ng::zlib
# Messaging
nlohmann_json::nlohmann_json
badaix::jsonrpcpp
websocketpp::websocketpp
zlib-ng::zlib
)
set_target_properties("room-server" PROPERTIES
@@ -215,6 +220,12 @@ set_target_properties("room-server" PROPERTIES
COMPILE_WARNING_AS_ERROR OFF
)
target_compile_definitions("room-server"
PRIVATE
ASIO_STANDALONE
_WEBSOCKETPP_CPP11_STL_
)
if(WIN32)
# Disable/Enable a ton of things.
target_compile_definitions("room-server" PRIVATE