humanus.cpp/CMakeLists.txt

62 lines
2.0 KiB
CMake
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

cmake_minimum_required(VERSION 3.10)
project(humanus.cpp VERSION 0.1.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# 查找OpenSSL库尝试查找3.0.0版本,但如果找不到,也接受其他版本
find_package(OpenSSL REQUIRED)
if(OPENSSL_FOUND)
message(STATUS "OpenSSL found: ${OPENSSL_VERSION}")
message(STATUS "OpenSSL include directory: ${OPENSSL_INCLUDE_DIR}")
message(STATUS "OpenSSL libraries: ${OPENSSL_LIBRARIES}")
include_directories(${OPENSSL_INCLUDE_DIR})
add_compile_definitions(CPPHTTPLIB_OPENSSL_SUPPORT)
else()
message(FATAL_ERROR "OpenSSL not found. Please install OpenSSL development libraries.")
endif()
# 查找Python库
find_package(Python3 COMPONENTS Development)
if(Python3_FOUND)
message(STATUS "Python3 found: ${Python3_VERSION}")
message(STATUS "Python3 include directory: ${Python3_INCLUDE_DIRS}")
message(STATUS "Python3 libraries: ${Python3_LIBRARIES}")
include_directories(${Python3_INCLUDE_DIRS})
add_compile_definitions(PYTHON_FOUND)
else()
message(WARNING "Python3 development libraries not found. Python interpreter will not be available.")
endif()
# 添加MCP库
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/mcp)
# 添加服务器组件
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/server)
# 添加包含目录
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/mcp/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/mcp/common)
# 查找必要的包
find_package(Threads REQUIRED)
# 添加源文件
file(GLOB_RECURSE SOURCES
"src/*.cpp"
"src/*.cc"
)
# 添加可执行文件
add_executable(humanus_cpp ${SOURCES} main.cpp)
# 链接库
target_link_libraries(humanus_cpp PRIVATE Threads::Threads mcp server ${OPENSSL_LIBRARIES})
if(Python3_FOUND)
target_link_libraries(humanus_cpp PRIVATE ${Python3_LIBRARIES})
endif()
# 安装目标
install(TARGETS humanus_cpp DESTINATION bin)