参考连接:
Ubuntu下VsCode+CMake 交叉编译
VSCode与CMake搭配使用之基本配置
VSCode与CMake搭配使用之交叉编译

step1:
Ctrl+Shift+p打开VSCode的指令面板,然后输入cmake:q ;
在窗口搜索:“ >CMake:Edit user-loacl CMake kits ”会打开一个cmake-tools-kits.json的文件.
如果搜索不到这个文件,先把cmake :quick start 执行一遍再说。

在文件末尾添加自己的工具链信息如下:

[
  {
    "name": "GCC 11.4.0 x86_64-linux-gnu",
    "compilers": {
      "C": "/usr/bin/gcc",
      "CXX": "/usr/bin/g++"
    },
    "isTrusted": true
  },
  {
    "name": "arm_corss_compiler_for_lockfox",
    "toolchainFile": "/home/qiao/Desktop/my_test/toolchain.cmake"
  }

]

会调用这个交叉编译链设置的文件:
toolchainFile 文件:

### toolchain.cmake ###
# this is required
SET(CMAKE_SYSTEM_NAME Linux)

# specify the cross compiler
SET(CMAKE_C_COMPILER   /home/qiao/Desktop/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc)
SET(CMAKE_CXX_COMPILER /home/qiao/Desktop/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-g++)

# where is the target environment
SET(CMAKE_FIND_ROOT_PATH  /build_env/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/)

# search for programs in the build host directories (not necessary)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

重新设置交叉编译工具:

这个时候由于默认的是x86的GCC:
执行CMake:Reset CMake Tools …
Ubuntu下VsCode+CMake 交叉编译-LMLPHP

01-14 22:30