diff --git a/.cursorignore b/.cursorignore new file mode 100644 index 0000000..f90de47 --- /dev/null +++ b/.cursorignore @@ -0,0 +1,3 @@ +# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv) +.cursorignore +build/ diff --git a/.cursorrules b/.cursorrules index faafd38..6e92ca3 100644 --- a/.cursorrules +++ b/.cursorrules @@ -27,4 +27,14 @@ 5. 文档结构 - 章节层次分明 - 内容组织有序 - - 格式统一一致 \ No newline at end of file + - 格式统一一致 + +请遵循如下 C++ 规范: +- 使用 C++17 标准 +- 使用 CMake 3.14 及以上版本 +- 使用 nlohmann_json 3.11.3 版本 +- 使用 FetchContent 管理第三方库 +- 使用 Google Test 进行单元测试 +- 使用 Google Mock 进行单元测试 +- 使用 Google Benchmark 进行性能测试 +- 在头文件中定义函数,在源文件中实现函数 diff --git a/CMakeLists.txt b/CMakeLists.txt index aa353c8..78860c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,26 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.14...3.27) # 设置 CMake 策略 cmake_policy(SET CMP0074 NEW) # 使用 _ROOT 变量 cmake_policy(SET CMP0167 NEW) # 使用新的 Boost 查找模块 +cmake_policy(SET CMP0135 NEW) # 设置解压时间戳行为 project(airport_collision_avoidance) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) 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) @@ -24,7 +37,7 @@ find_package(Boost REQUIRED COMPONENTS system) include(FetchContent) FetchContent_Declare( 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) @@ -63,7 +76,7 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/tests") FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG release-1.12.1 + GIT_TAG v1.15.2 ) FetchContent_MakeAvailable(googletest) enable_testing()