cpp-mcp/CMakeLists.txt

57 lines
1.6 KiB
CMake
Raw Permalink Normal View History

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-14 15:53:58 +08:00
set(CMAKE_WARN_UNUSED_CLI YES)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if (NOT XCODE AND NOT MSVC AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
option(BUILD_SHARED_LIBS "build shared libraries" ${BUILD_SHARED_LIBS_DEFAULT})
if (WIN32)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
endif()
if (MSVC)
add_compile_options("$<$<COMPILE_LANGUAGE:C>:/utf-8>")
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/utf-8>")
add_compile_options("$<$<COMPILE_LANGUAGE:C>:/bigobj>")
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/bigobj>")
endif()
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-17 15:50:12 +08:00
option(MCP_BUILD_TESTS "Build the tests" OFF)
2025-03-08 23:44:34 +08:00
if(MCP_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()