修改 CMakeLists.txt 和打包脚本
This commit is contained in:
parent
02bfe8e90c
commit
cba55fcbd9
@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 3.14...3.27)
|
||||
# 设置 CMake 策略
|
||||
cmake_policy(SET CMP0074 NEW) # 使用 <PackageName>_ROOT 变量
|
||||
|
||||
# 包含 FetchContent 模块
|
||||
include(FetchContent)
|
||||
|
||||
project(airport_collision_avoidance)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
@ -34,13 +37,19 @@ find_package(Boost REQUIRED COMPONENTS system filesystem thread)
|
||||
# 添加 libcurl
|
||||
find_package(CURL REQUIRED)
|
||||
|
||||
# 添加 nlohmann_json
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
json
|
||||
URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz
|
||||
)
|
||||
FetchContent_MakeAvailable(json)
|
||||
# 添加 JSON 库
|
||||
if(APPLE)
|
||||
# macOS 使用 Homebrew 安装的 nlohmann_json
|
||||
find_package(nlohmann_json 3.11.3 REQUIRED)
|
||||
set(JSON_TARGET nlohmann_json::nlohmann_json)
|
||||
else()
|
||||
# CentOS 使用系统安装的 json-devel
|
||||
set(JSON_INCLUDE_DIR "/usr/include/json")
|
||||
if(NOT EXISTS ${JSON_INCLUDE_DIR})
|
||||
message(FATAL_ERROR "json-devel not found. Please install: yum install -y json-devel")
|
||||
endif()
|
||||
set(JSON_TARGET "")
|
||||
endif()
|
||||
|
||||
# 源文件列表
|
||||
set(LIB_SOURCES
|
||||
@ -69,12 +78,13 @@ target_include_directories(${PROJECT_NAME}_lib
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${CURL_INCLUDE_DIRS}
|
||||
$<$<NOT:$<PLATFORM_ID:Darwin>>:${JSON_INCLUDE_DIR}> # 仅在非 macOS 系统添加
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}_lib
|
||||
PUBLIC
|
||||
Boost::system
|
||||
nlohmann_json::nlohmann_json
|
||||
${JSON_TARGET}
|
||||
CURL::libcurl
|
||||
)
|
||||
|
||||
|
||||
@ -13,4 +13,10 @@
|
||||
13|sudo yum install -y devtoolset-7-gcc devtoolset-7-gcc-c++
|
||||
14|
|
||||
15|# 启用 GCC 7
|
||||
16|scl enable devtoolset-7 bash
|
||||
16|scl enable devtoolset-7 bash
|
||||
17|
|
||||
18|# 确保已启用 EPEL 仓库
|
||||
19|sudo yum install -y epel-release
|
||||
20|
|
||||
21|# 安装 nlohmann-json-devel
|
||||
22|sudo yum install -y nlohmann-json-devel
|
||||
@ -48,7 +48,11 @@ fi
|
||||
log_info "Installing build dependencies..."
|
||||
sudo yum groupinstall -y "Development Tools"
|
||||
sudo yum install -y epel-release
|
||||
sudo yum install -y cmake3 boost-devel openssl-devel nlohmann-json-devel python3-devel libcurl-devel
|
||||
sudo yum install -y cmake3 boost-devel openssl-devel python3-devel libcurl-devel
|
||||
|
||||
# Install nlohmann-json from EPEL
|
||||
log_info "Installing nlohmann-json..."
|
||||
sudo yum install -y nlohmann-json-devel
|
||||
|
||||
# Install GCC 7
|
||||
log_info "Installing GCC 7..."
|
||||
|
||||
Loading…
Reference in New Issue
Block a user