From 16d94a174a65c2f7780706ffdedf4118df240301 Mon Sep 17 00:00:00 2001 From: faumaray Date: Tue, 28 Jul 2026 22:45:54 +0300 Subject: [PATCH] Build independently with EchoionApi SDK --- CMakeLists.txt | 47 ++++++++++++++++++++++++++++++++++++------- src/InternalStore.cpp | 4 +++- src/Plugin.cpp | 4 +++- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee30567..0666629 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,17 +1,50 @@ -set(_internal_sources - "${CMAKE_CURRENT_SOURCE_DIR}/../common/src/Common.cpp" - src/InternalStore.cpp) +cmake_minimum_required(VERSION 4.0.0) +if(NOT DEFINED ECHOION_PRODUCT_VERSION) + set(ECHOION_PRODUCT_VERSION 2.0.0) +endif() +project(EchoionPluginUrlShortenerInternal + VERSION "${ECHOION_PRODUCT_VERSION}" LANGUAGES CXX) + +include(GNUInstallDirs) + +if(PROJECT_IS_TOP_LEVEL) + file(DOWNLOAD + https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.40.8/CPM.cmake + "${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake" + EXPECTED_HASH + SHA256=78ba32abdf798bc616bab7c73aac32a17bbd7b06ad9e26a6add69de8f3ae4791) + include("${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake") + CPMAddPackage( + NAME Void + GIT_REPOSITORY https://git.faumaray.ru/void/voidlibrary.git + GIT_TAG main + OPTIONS "VOID_ENABLE_TESTING OFF") + CPMAddPackage( + NAME EchoionApi + GIT_REPOSITORY https://git.faumaray.ru/void/echoionapi.git + GIT_TAG main) + option(BUILD_TESTS "Build component tests" ON) + if(BUILD_TESTS) + enable_testing() + endif() +endif() + +find_package(OpenSSL REQUIRED COMPONENTS Crypto) +find_package(Threads REQUIRED) + +set(ECHOION_URL_SHORTENER_INTERNAL_VERSION "${PROJECT_VERSION}") +set(_internal_sources src/InternalStore.cpp) add_library(EchoionUrlShortenerInternalPlugin MODULE ${_internal_sources} src/Plugin.cpp) target_include_directories(EchoionUrlShortenerInternalPlugin PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/include" - "${CMAKE_CURRENT_SOURCE_DIR}/../common/include") + "${CMAKE_CURRENT_SOURCE_DIR}/include") target_compile_features(EchoionUrlShortenerInternalPlugin PRIVATE cxx_std_26) target_link_libraries(EchoionUrlShortenerInternalPlugin PRIVATE Echoion::ApiPlugin Echoion::ApiConfig + Echoion::ApiPluginSdk Void::ShortUrl Void::Data Void::Net @@ -48,11 +81,11 @@ if(BUILD_TESTS) ${_internal_sources} tests/InternalStoreTests.cpp) target_include_directories(echoion_url_shortener_internal_tests PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/include" - "${CMAKE_CURRENT_SOURCE_DIR}/../common/include") + "${CMAKE_CURRENT_SOURCE_DIR}/include") target_compile_features(echoion_url_shortener_internal_tests PRIVATE cxx_std_26) target_link_libraries(echoion_url_shortener_internal_tests PRIVATE + Echoion::ApiPluginSdk Void::Data Void::Net Void::Text Void::Sqlite Void::Crypto OpenSSL::Crypto Threads::Threads) add_test(NAME echoion_url_shortener_internal_tests diff --git a/src/InternalStore.cpp b/src/InternalStore.cpp index 8dfed9a..cf596f5 100644 --- a/src/InternalStore.cpp +++ b/src/InternalStore.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include @@ -12,6 +12,8 @@ namespace Echoion::Plugins::ShortUrl { + using namespace Echoion::Api::Plugin::ShortUrl; + namespace { constexpr std::string_view kAlphabet = diff --git a/src/Plugin.cpp b/src/Plugin.cpp index 6b17477..96f64fa 100644 --- a/src/Plugin.cpp +++ b/src/Plugin.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -18,6 +18,8 @@ namespace Echoion::Plugins::ShortUrl { + using namespace Echoion::Api::Plugin::ShortUrl; + namespace { constexpr std::string_view kPluginId{"url-shortener-internal"};