更新依赖库到最新版本,C++ 标准升级到 C++20

This commit is contained in:
Tian jianyong 2024-11-17 01:37:34 +08:00
parent d6c709a89b
commit fe626858f0
3 changed files with 31 additions and 5 deletions

3
.cursorignore Normal file
View File

@ -0,0 +1,3 @@
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)
.cursorignore
build/

View File

@ -27,4 +27,14 @@
5. 文档结构 5. 文档结构
- 章节层次分明 - 章节层次分明
- 内容组织有序 - 内容组织有序
- 格式统一一致 - 格式统一一致
请遵循如下 C++ 规范:
- 使用 C++17 标准
- 使用 CMake 3.14 及以上版本
- 使用 nlohmann_json 3.11.3 版本
- 使用 FetchContent 管理第三方库
- 使用 Google Test 进行单元测试
- 使用 Google Mock 进行单元测试
- 使用 Google Benchmark 进行性能测试
- 在头文件中定义函数,在源文件中实现函数

View File

@ -1,13 +1,26 @@
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.14...3.27)
# CMake # CMake
cmake_policy(SET CMP0074 NEW) # 使 <PackageName>_ROOT cmake_policy(SET CMP0074 NEW) # 使 <PackageName>_ROOT
cmake_policy(SET CMP0167 NEW) # 使 Boost cmake_policy(SET CMP0167 NEW) # 使 Boost
cmake_policy(SET CMP0135 NEW) #
project(airport_collision_avoidance) project(airport_collision_avoidance)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
#
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0)
message(FATAL_ERROR "GCC 版本需要 >= 10.0 以支持 C++20")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0)
message(FATAL_ERROR "Clang 版本需要 >= 13.0 以支持 C++20")
endif()
endif()
# #
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@ -24,7 +37,7 @@ find_package(Boost REQUIRED COMPONENTS system)
include(FetchContent) include(FetchContent)
FetchContent_Declare( FetchContent_Declare(
json json
URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz
) )
FetchContent_MakeAvailable(json) FetchContent_MakeAvailable(json)
@ -63,7 +76,7 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/tests")
FetchContent_Declare( FetchContent_Declare(
googletest googletest
GIT_REPOSITORY https://github.com/google/googletest.git GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1 GIT_TAG v1.15.2
) )
FetchContent_MakeAvailable(googletest) FetchContent_MakeAvailable(googletest)
enable_testing() enable_testing()