Initial code with ExternalContent download for third-party content

This commit is contained in:
Xaymar
2026-01-16 10:13:40 +01:00
parent 5fb62fe449
commit 256f40ace0
7 changed files with 286 additions and 0 deletions
+132
View File
@@ -0,0 +1,132 @@
# 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
#--------------------------------------------------------------------------------#
#--------------------------------------------------------------------------------#
# 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"
DOWNLOAD_HASH "SHA512;6D867F6C63BC259110E00726D0DD38090F5E55EE01EEFF94A3590B1351967FD7E19EE8F7601A197723FA072CEA8F29D00A7C60A8E97D441CE3D931EE1A098F06"
SKIP_CONFIGURE
SKIP_BUILD
SKIP_INSTALL
)
endif()
# badaix's JSONRPC++
ExternalContent(
NAME "badaix-jsonrpc"
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 CATCH_INSTALL_DOCS:BOOL=OFF -D CATCH_INSTALL_EXTRAS:BOOL=ON
BUILD_ARGS
)
# 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
)
# 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
)
# WebSocket++
ExternalContent(
NAME "zaphoyd-websocketpp"
GIT_URL "https://github.com/amini-allight/websocketpp.git"
GIT_REF "develop"
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
)
#--------------------------------------------------------------------------------#
# 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
# wolfSSL
# nlohmann_json::nlohmann_json
# badaix::jsonrpc
# zaphoyd::websocketpp
)
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()
+38
View File
@@ -0,0 +1,38 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 4,
"minor": 2,
"patch": 1
},
"configurePresets": [
{
"name": "default",
"displayName": "Default",
"description": "Default",
"binaryDir": "${sourceDir}/build/",
"installDir": "${sourceDir}/distrib/",
"cacheVariables": {
"CMAKE_VERBOSE_MAKEFILE": "ON",
"CMAKE_INTERPROCEDURAL_OPTIMIZATION": "ON"
},
"hidden": false
}
],
"buildPresets": [
{
"configurePreset": "default",
"name": "default-debug",
"description": "",
"displayName": "Debug",
"configuration": "Debug"
},
{
"configurePreset": "default",
"name": "default-release",
"description": "",
"displayName": "Release",
"configuration": "Release"
}
]
}
Submodule cmake/externalcontent added at 2669af35a8
+27
View File
@@ -0,0 +1,27 @@
/** 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.
**/
#include <filesystem>
#include <string>
#include "manager.hpp"
#include <windows.h>
int main(int _argc, char** _argv)
{
// Launch the manager part of the app.
apsr::manager manager{};
return manager.run(_argc, _argv);
}
+37
View File
@@ -0,0 +1,37 @@
/** 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.
**/
#include "manager.hpp"
nlohmann::json::object default_config{
};
apsr::manager::~manager()
{
}
apsr::manager::manager()
{
_client.set_user_agent("Archipelago Room Server");
}
int32_t apsr::manager::run(int argc, char** argv)
{
// Spawn threads to handle all ASIO workload.
//!TODO: Make this a command line or environment option.
return 0;
}
+39
View File
@@ -0,0 +1,39 @@
/** 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.
**/
#include <cinttypes>
#include <list>
#include <thread>
// JSON and JSON-RPC 2.0
#include <nlohmann/json.hpp>
#include <badaix/jsonrpcpp.hpp>
// WebSocket Client
#include <websocketpp/config/asio_no_tls_client.hpp>
#include <websocketpp/client.hpp>
namespace apsr {
class manager {
std::string _host_url;
websocketpp::client<websocketpp::config::asio_client> _client;
public:
~manager();
manager();
public:
int32_t run(int argc, char** argv);
};
} // namespace apsr
+12
View File
@@ -0,0 +1,12 @@
/** 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.
**/