From c7c76c3933bbce564461ebebc76428591081e850 Mon Sep 17 00:00:00 2001 From: Tian jianyong <11429339@qq.com> Date: Thu, 6 Feb 2025 17:31:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20CMakeLists.txt=20=E6=96=87?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E5=A2=9E=E5=8A=A0=20Boost=20=E7=9A=84=20rege?= =?UTF-8?q?x=20=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37d619a..1b3af3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,9 +6,8 @@ if(NOT APPLE) set(CMAKE_CXX_COMPILER "/opt/rh/devtoolset-11/root/usr/bin/g++") endif() -# 设置 CMake 策略 -cmake_policy(SET CMP0074 NEW) # 使用 _ROOT 变量 -cmake_policy(SET CMP0167 NEW) # 使用新的 Boost 查找机制 +# 设置 CMake 策略(移除非必要的新策略) +cmake_policy(SET CMP0074 NEW) # 保留必要的包根目录策略 # 包含 FetchContent 模块 include(FetchContent) @@ -51,6 +50,12 @@ else() set(BOOST_ROOT "/opt/homebrew/Cellar/boost/1.87.0") set(BOOST_LIBRARYDIR "/opt/homebrew/Cellar/boost/1.87.0/lib") endif() + +# 设置 CMake 策略(在 find_package(Boost) 前添加) +if(POLICY CMP0167) + cmake_policy(SET CMP0167 OLD) # 强制使用传统 FindBoost 模块 +endif() + find_package(Boost 1.69.0 REQUIRED COMPONENTS system filesystem @@ -58,6 +63,7 @@ find_package(Boost 1.69.0 REQUIRED COMPONENTS chrono date_time atomic + regex # 添加缺失的 regex 组件 ) # 添加 libcurl @@ -121,6 +127,7 @@ target_link_libraries(${PROJECT_NAME}_lib nlohmann_json::nlohmann_json CURL::libcurl Threads::Threads + -pthread # 添加显式 pthread 链接选项 ) # 创建主可执行文件