2025-03-08 01:50:39 +08:00
|
|
|
cmake_minimum_required(VERSION 3.10)
|
2025-03-08 22:49:19 +08:00
|
|
|
project(MCP VERSION 2024.11.05 LANGUAGES CXX)
|
2025-03-08 01:50:39 +08:00
|
|
|
|
2025-03-09 15:45:09 +08:00
|
|
|
|
2025-03-08 01:50:39 +08:00
|
|
|
# Set C++ standard
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
|
|
# Find required packages
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
2025-03-09 15:45:09 +08:00
|
|
|
option(MCP_SSL "Enable SSL support" OFF)
|
|
|
|
|
|
|
|
if(MCP_SSL)
|
|
|
|
find_package(OpenSSL 3.0.0 COMPONENTS Crypto SSL REQUIRED)
|
|
|
|
include_directories(${OPENSSL_INCLUDE_DIR}) # before including cpp-httplib to avoid OpenSSL with lower version included
|
|
|
|
message(STATUS "OpenSSL include directory: ${OPENSSL_INCLUDE_DIR}")
|
|
|
|
add_compile_definitions(MCP_SSL CPPHTTPLIB_OPENSSL_SUPPORT)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common)
|
2025-03-08 01:50:39 +08:00
|
|
|
|
2025-03-09 15:45:09 +08:00
|
|
|
# Add MCP library
|
2025-03-08 01:50:39 +08:00
|
|
|
add_subdirectory(src)
|
|
|
|
|
2025-03-09 15:45:09 +08:00
|
|
|
# Add examples
|
2025-03-08 01:50:39 +08:00
|
|
|
add_subdirectory(examples)
|
2025-03-08 23:44:34 +08:00
|
|
|
|
2025-03-09 15:45:09 +08:00
|
|
|
# Add test directory
|
2025-03-08 23:44:34 +08:00
|
|
|
option(MCP_BUILD_TESTS "Build the tests" ON)
|
|
|
|
if(MCP_BUILD_TESTS)
|
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(test)
|
|
|
|
|
2025-03-09 15:45:09 +08:00
|
|
|
# Add custom test target
|
2025-03-08 23:44:34 +08:00
|
|
|
add_custom_target(run_tests
|
|
|
|
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
|
|
|
|
COMMENT "Running MCP tests..."
|
|
|
|
)
|
|
|
|
endif()
|