# toolchain.cmake
# 指定系统类型
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

set(TOOLCHAIN_PATH /opt/arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu/bin)

# 指定交叉编译器
set(CMAKE_C_COMPILER ${TOOLCHAIN_PATH}/aarch64-none-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PATH}/aarch64-none-linux-gnu-g++)
# set(CMAKE_AR ${TOOLCHAIN_PATH}/aarch64-none-linux-gnu-ar)
# set(CMAKE_LINKER ${TOOLCHAIN_PATH}/aarch64-none-linux-gnu-ld)
# set(CMAKE_STRIP ${TOOLCHAIN_PATH}/aarch64-none-linux-gnu-strip)
# set(CMAKE_RANLIB ${TOOLCHAIN_PATH}/aarch64-none-linux-gnu-ranlib)

# 指定 sysroot（可选，若工具链内置则不需要）
# set(CMAKE_SYSROOT /opt/aarch64-linux-gnu/sysroot)

# 告诉 CMake 搜索头文件和库时的优先级
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)