Files
EchoionCore/CMakeLists.txt
T
faumarayandClaude Opus 4.8 aedd3e1692 Expose Core as a Void::Plugin (C ABI + v2 state), additive
Add a CorePlugin adapter (IS-A Void::Plugin::IPlugin and IS-A Core, hence
Api::ICoreInterface) and export the void_plugin_* C ABI from Export.cpp:
create/destroy/info plus the v2 state protocol (serialize/deserialize routed
through Core's already-Void::Json prepareForHotReload/restoreAfterHotReload).
The host recovers the bot interface by dynamic_cast-ing the IPlugin* back to
ICoreInterface*.

Additive: the legacy CreateCore/DestroyCore exports stay, so the current
dylib CoreLoader keeps working while the host migrates to
Void::Plugin::PluginManager. Verified via a dlopen smoke test (symbols
resolve; info/version correct; create/serialize/deserialize/destroy safe on
an uninitialized Core). The live hot-reload + state-survival test under
TeamSpeak is the remaining gate for the host-side loader swap. Link
Void::Plugin.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 21:40:42 +03:00

183 lines
5.1 KiB
CMake

cmake_minimum_required(VERSION 4.0.0)
project(EchoionCore VERSION 1.0.0 LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CMAKE_CXX_STANDARD 26)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_definitions(-DECHOION_API_EXPORT)
file(GLOB_RECURSE CORE_SOURCES
CONFIGURE_DEPENDS
"src/**.cpp"
)
add_library(EchoionCore SHARED ${CORE_SOURCES})
add_library(Echoion::Core ALIAS EchoionCore)
target_include_directories(EchoionCore PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../EchoionApi/include/echoion/api/config>
$<INSTALL_INTERFACE:include>
)
# Core uses all API modules
target_link_libraries(EchoionCore PUBLIC
Echoion::ApiBase
Echoion::ApiAudio
Echoion::ApiTrack
Echoion::ApiNetwork
Echoion::ApiPlugin
Echoion::ApiConfig
Echoion::ApiRpc
Echoion::ApiYouTube
Echoion::ApiLogger
Echoion::ApiEventBus
Echoion::ApiDatabase
Echoion::ApiOpaque
Echoion::ApiPluginInterface
Echoion::ApiCoreInterface
Echoion::ApiUtils
)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET
libavformat
libavcodec
libswresample
libavutil
)
CPMAddPackage(
NAME quickjs
GITHUB_REPOSITORY quickjs-ng/quickjs
GIT_TAG v0.11.0
)
# quickjs-ng v0.11.0 compiles its C sources with -Werror, which trips newer GCC
# diagnostics (e.g. -Wmaybe-uninitialized / -Wdiscarded-qualifiers under GCC 16+).
# It is a vendored third-party dependency, so relax -Werror on every target it
# defines (qjs, qjsc, qjs-libc, ...) rather than guessing target names.
if(quickjs_SOURCE_DIR)
get_property(_qjs_targets DIRECTORY "${quickjs_SOURCE_DIR}"
PROPERTY BUILDSYSTEM_TARGETS)
foreach(_qjs_target ${_qjs_targets})
get_target_property(_qjs_type ${_qjs_target} TYPE)
if(NOT _qjs_type STREQUAL "INTERFACE_LIBRARY")
target_compile_options(${_qjs_target} PRIVATE -Wno-error)
endif()
endforeach()
endif()
set(AddBoost.cmake_VERSION 3.7.3)
CPMAddPackage(
NAME AddBoost.cmake
VERSION "${AddBoost.cmake_VERSION}"
URL "https://github.com/Arniiiii/AddBoost.cmake/archive/refs/tags/${AddBoost.cmake_VERSION}.tar.gz"
)
set(TRY_BOOST_VERSION "1.90.0")
set(BOOST_MY_OPTIONS "BOOST_ENABLE_PYTHON ON;")
set(BOOST_NOT_HEADER_ONLY_COMPONENTS_THAT_YOU_NEED "thread;system")
set(BOOST_HEADER_ONLY_COMPONENTS_THAT_YOU_NEED "asio;beast;uuid;container;cobalt;url")
add_boost(
TRY_BOOST_VERSION BOOST_HEADER_ONLY_COMPONENTS_THAT_YOU_NEED
BOOST_NOT_HEADER_ONLY_COMPONENTS_THAT_YOU_NEED EchoionCore
)
find_package(Threads REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(SQLite3 REQUIRED)
find_package(TBB REQUIRED)
target_link_libraries(EchoionCore
PUBLIC
PkgConfig::LIBAV
TBB::tbb
SQLite::SQLite3
# VoidLibrary modules (migration target — replacing in-house infra)
Void::Data
Void::Functional
Void::System
Void::Log
Void::Async
Void::Containers
Void::Resilience
Void::Text
Void::Time
Void::Math
Void::Net
Void::Sqlite
Void::Service
Void::Plugin
PRIVATE
Threads::Threads
qjs
Boost::beast
Boost::url
Boost::asio
OpenSSL::SSL
OpenSSL::Crypto
)
if(MSVC)
target_compile_options(EchoionCore PRIVATE /W4 /WX-)
target_compile_definitions(EchoionCore PRIVATE _CRT_SECURE_NO_WARNINGS)
else()
target_compile_options(EchoionCore PRIVATE -Wall -Wextra -Wpedantic)
endif()
set_target_properties(EchoionCore PROPERTIES
OUTPUT_NAME "Echoion"
PREFIX ""
SUFFIX ".ts"
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
)
# Export EchoionCore
target_include_directories(EchoionCore PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
install(TARGETS EchoionCore
EXPORT EchoionCoreTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include
)
install(EXPORT EchoionCoreTargets
FILE EchoionCoreTargets.cmake
NAMESPACE Echoion::
DESTINATION lib/cmake/EchoionCore
)
# Package config files
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/EchoionCoreConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/EchoionCoreConfig.cmake"
"include(\"\${CMAKE_CURRENT_LIST_DIR}/EchoionCoreTargets.cmake\")
include(CMakeFindDependencyMacro)
find_dependency(EchoionApi)
")
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/EchoionCoreConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/EchoionCoreConfigVersion.cmake"
DESTINATION lib/cmake/EchoionCore
)
option(BUNDLE_FFMPEG "Bundle FFmpeg libraries with installation" OFF)
if(BUNDLE_FFMPEG)
include(cmake/BundleFFmpeg.cmake)
bundle_ffmpeg_libraries(EchoionCore)
endif()