Files
2026-08-29 20:24:11 +08:00

145 lines
6.4 KiB
CMake

include("${CMAKE_CURRENT_LIST_DIR}/../web_server/cmake/rely.cmake")
set(Aethera_MCP_dependencies
global::drogon
global::pfr
)
rcl_add_dependency_action_targets(Aethera_MCP_env ${Aethera_MCP_dependencies})
set_target_properties(Aethera_MCP_env PROPERTIES FOLDER Aethera_MCP)
library_get_missing_with_rely(Aethera_MCP_dependencies_missing
${Aethera_MCP_dependencies})
if (Aethera_MCP_dependencies_missing)
rcl_log_append(${CMAKE_CURRENT_LIST_LINE}
"[FATAL_ERROR] Aethera_MCP dependencies\n${Aethera_MCP_dependencies_missing}\n are not installed. Build Aethera_MCP_env first")
return()
endif ()
rcl_load_dependency_environment(${Aethera_MCP_dependencies})
find_package(Drogon CONFIG REQUIRED)
if (NOT TARGET Aethera_render_2D)
rcl_log_append(${CMAKE_CURRENT_LIST_LINE}
"[FATAL_ERROR] Aethera_MCP requires Aethera_render_2D")
return()
endif ()
if (NOT TARGET Aethera_render_3D)
rcl_log_append(${CMAKE_CURRENT_LIST_LINE}
"[FATAL_ERROR] Aethera_MCP requires Aethera_render_3D")
return()
endif ()
if (NOT TARGET structive::property_core)
set(Aethera_MCP_saved_build_testing "${BUILD_TESTING}")
set(BUILD_TESTING OFF)
set(STRUCTIVE_BUILD_EXAMPLES OFF)
set(STRUCTIVE_BUILD_TESTS OFF)
set(STRUCTIVE_INSTALL OFF)
add_subdirectory(
"${CMAKE_CURRENT_LIST_DIR}/../third_party/Structive"
"${CMAKE_CURRENT_BINARY_DIR}/third_party/Structive"
EXCLUDE_FROM_ALL)
set(BUILD_TESTING "${Aethera_MCP_saved_build_testing}")
unset(Aethera_MCP_saved_build_testing)
endif ()
set(Aethera_MCP_core_dir "${CMAKE_CURRENT_LIST_DIR}/core")
append_glob_source(Aethera_MCP_core_sources "${Aethera_MCP_core_dir}")
add_library(Aethera_MCP_Core STATIC ${Aethera_MCP_core_sources})
target_include_directories(Aethera_MCP_Core PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/..>"
"$<BUILD_INTERFACE:${EXTERNAL_DIR}/source/pfr/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../web_server/third_party/include>")
target_compile_features(Aethera_MCP_Core PUBLIC cxx_std_23)
target_compile_definitions(Aethera_MCP_Core PUBLIC NOMINMAX)
target_link_libraries(Aethera_MCP_Core PUBLIC
Aethera_render_2D
Aethera_render_3D
structive::property_core)
add_executable(Aethera_MCP_Server
"${CMAKE_CURRENT_LIST_DIR}/server/main.cpp"
"${CMAKE_CURRENT_LIST_DIR}/server/Mcp_Server.cpp"
"${CMAKE_CURRENT_LIST_DIR}/server/Mcp_Server.hpp")
target_link_libraries(Aethera_MCP_Server PRIVATE
Aethera_MCP_Core
Drogon::Drogon
TBB::tbbmalloc_proxy)
if (MSVC)
target_compile_options(Aethera_MCP_Core PRIVATE /utf-8 /bigobj)
target_compile_options(Aethera_MCP_Server PRIVATE /utf-8 /bigobj)
target_link_options(Aethera_MCP_Server PRIVATE "/INCLUDE:__TBB_malloc_proxy")
add_custom_command(TARGET Aethera_MCP_Server POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"$<TARGET_FILE:TBB::tbbmalloc>"
"$<TARGET_FILE:TBB::tbbmalloc_proxy>"
"$<TARGET_FILE_DIR:Aethera_MCP_Server>"
COMMENT "Deploying the scalable allocator runtime for Aethera MCP"
VERBATIM)
endif ()
if (Aethera_BUILD_TESTS)
find_package(benchmark CONFIG REQUIRED)
add_executable(Aethera_MCP_Protocol_Type_Tests
"${CMAKE_CURRENT_LIST_DIR}/tests/Protocol_Type_Tests.cpp")
target_link_libraries(Aethera_MCP_Protocol_Type_Tests PRIVATE
Aethera_MCP_Core
GTest::gtest_main)
if (MSVC)
target_compile_options(Aethera_MCP_Protocol_Type_Tests PRIVATE
/utf-8 /bigobj)
endif ()
add_test(NAME Aethera_MCP_Protocol_Type_Tests
COMMAND Aethera_MCP_Protocol_Type_Tests)
set_tests_properties(Aethera_MCP_Protocol_Type_Tests PROPERTIES
LABELS "Aethera_MCP")
add_executable(Aethera_MCP_Benchmarks
"${CMAKE_CURRENT_LIST_DIR}/tests/Control_Path_Benchmarks.cpp")
target_link_libraries(Aethera_MCP_Benchmarks PRIVATE
Aethera_MCP_Core
benchmark::benchmark
TBB::tbbmalloc_proxy)
renderive_stage_render_3D_runtime(Aethera_MCP_Benchmarks)
if (MSVC)
target_compile_options(Aethera_MCP_Benchmarks PRIVATE
/utf-8 /bigobj)
target_link_options(Aethera_MCP_Benchmarks PRIVATE
"/INCLUDE:__TBB_malloc_proxy")
add_custom_command(TARGET Aethera_MCP_Benchmarks POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"$<TARGET_FILE:TBB::tbbmalloc>"
"$<TARGET_FILE:TBB::tbbmalloc_proxy>"
"$<TARGET_FILE_DIR:Aethera_MCP_Benchmarks>"
VERBATIM)
endif ()
add_custom_target(Aethera_MCP_benchmark
COMMAND Aethera_MCP_Benchmarks
--benchmark_min_time=1s
--benchmark_repetitions=3
--benchmark_report_aggregates_only=true
DEPENDS Aethera_MCP_Benchmarks
USES_TERMINAL)
add_executable(Aethera_MCP_Event_Latency_Benchmarks
"${CMAKE_CURRENT_LIST_DIR}/tests/Event_Latency_Benchmarks.cpp")
target_link_libraries(Aethera_MCP_Event_Latency_Benchmarks PRIVATE
Aethera_MCP_Core
benchmark::benchmark
TBB::tbbmalloc_proxy)
renderive_stage_render_3D_runtime(Aethera_MCP_Event_Latency_Benchmarks)
if (MSVC)
target_compile_options(Aethera_MCP_Event_Latency_Benchmarks PRIVATE
/utf-8 /bigobj)
target_link_options(Aethera_MCP_Event_Latency_Benchmarks PRIVATE
"/INCLUDE:__TBB_malloc_proxy")
add_custom_command(TARGET Aethera_MCP_Event_Latency_Benchmarks POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"$<TARGET_FILE:TBB::tbbmalloc>"
"$<TARGET_FILE:TBB::tbbmalloc_proxy>"
"$<TARGET_FILE_DIR:Aethera_MCP_Event_Latency_Benchmarks>"
VERBATIM)
endif ()
add_custom_target(Aethera_MCP_event_latency_benchmark
COMMAND Aethera_MCP_Event_Latency_Benchmarks
--aethera_event_samples=12
DEPENDS Aethera_MCP_Event_Latency_Benchmarks
USES_TERMINAL)
add_custom_target(Aethera_MCP_check
COMMAND "${CMAKE_CTEST_COMMAND}"
--test-dir "${CMAKE_BINARY_DIR}"
-C "$<CONFIG>" -L "^Aethera_MCP$" --output-on-failure
DEPENDS Aethera_MCP_Protocol_Type_Tests
USES_TERMINAL)
endif ()