# 包含交叉编译工具链
include(cross.cmake)

# 设置CMake的最低版本要求
cmake_minimum_required(VERSION 3.5.0)

# 设置 C++ 标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -pthread -Wall -march=loongarch64 -mtune=loongarch64 -ffast-math -funroll-loops -fomit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wall")

# 定义项目名称和版本
project(smartcar_demo2 VERSION 0.1.0 LANGUAGES C CXX)

# OpenCV 设备端路径
set(OpenCV_DIR /mnt/d/PPPProgram/smartcar/opencv_device/lib/cmake/opencv4)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
message(STATUS "OpenCV Include Directories: ${OpenCV_INCLUDE_DIRS}")

# 项目头文件路径
include_directories(src)
include_directories(lib)

# 收集 src 下所有 .cpp (自动发现)
aux_source_directory(src DIR_SRCS)

# 排除暂不使用的模块（源文件保留）
#   vl53l0x.cpp   — 激光测距, 硬件未接
#   zebra_detect.cpp — 经典斑马线检测, 已由 nanodet 模型替代
list(FILTER DIR_SRCS EXCLUDE REGEX "(vl53l0x\\.cpp|zebra_detect\\.cpp)")

# 静态库 + 主程序
add_library(common_lib STATIC ${DIR_SRCS})
add_subdirectory(main)
