修改 CMakeLists.txt 和打包脚本

This commit is contained in:
Tian jianyong 2024-12-20 14:01:55 +08:00
parent 02bfe8e90c
commit cba55fcbd9
3 changed files with 30 additions and 10 deletions

View File

@ -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
)

View File

@ -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

View File

@ -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..."