From 91a4f8a9fd89d0e1fde9ac80d15a504d8b5721b8 Mon Sep 17 00:00:00 2001 From: zhenyan121 <3367366583@qq.com> Date: Thu, 25 Dec 2025 18:48:54 +0800 Subject: [PATCH] Added Boost.Asio --- CMakeLists.txt | 13 ++++++++++--- cmake/SDL.cmake | 7 +------ cmake/ThirdParty.cmake | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 cmake/ThirdParty.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c3c29e..815a7cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$") -# ========== 引入 SDL 构建脚本 ========== +include(${CMAKE_SOURCE_DIR}/cmake/ThirdParty.cmake) include(${CMAKE_SOURCE_DIR}/cmake/SDL.cmake) # ========== 源码 ========== @@ -51,8 +51,15 @@ set(SOURCE_FILES add_executable(${PROJECT_NAME} ${SOURCE_FILES}) -target_include_directories(${PROJECT_NAME} - PRIVATE ${CMAKE_SOURCE_DIR}/src +target_include_directories(${PROJECT_NAME} PRIVATE + ${CMAKE_SOURCE_DIR}/src + ${asio_SOURCE_DIR}/asio/include + +) + +target_compile_definitions(${PROJECT_NAME} PRIVATE + ASIO_STANDALONE + ) target_link_libraries(${PROJECT_NAME} diff --git a/cmake/SDL.cmake b/cmake/SDL.cmake index 7f21b79..22b7334 100644 --- a/cmake/SDL.cmake +++ b/cmake/SDL.cmake @@ -37,10 +37,5 @@ FetchContent_Declare( FetchContent_MakeAvailable(SDL3_image) -FetchContent_Declare( - nlohmann_json - GIT_REPOSITORY https://github.com/nlohmann/json.git - GIT_TAG v3.12.0 -) -FetchContent_MakeAvailable(nlohmann_json) \ No newline at end of file + diff --git a/cmake/ThirdParty.cmake b/cmake/ThirdParty.cmake new file mode 100644 index 0000000..c196ff7 --- /dev/null +++ b/cmake/ThirdParty.cmake @@ -0,0 +1,16 @@ +include(FetchContent) + +FetchContent_Declare( + nlohmann_json + GIT_REPOSITORY https://github.com/nlohmann/json.git + GIT_TAG v3.12.0 +) + +FetchContent_MakeAvailable(nlohmann_json) + +FetchContent_Declare( + asio + GIT_REPOSITORY https://github.com/chriskohlhoff/asio.git + GIT_TAG asio-1-36-0 # 指定一个稳定版本标签 +) +FetchContent_MakeAvailable(asio) \ No newline at end of file