有时会有将cmake工程移植到另一台主机的需求,如何移植,以此做记录:
首先在目的主机的环境上安装相应的工具链,安装cmake, vscode,vscode安装插件cmake, cmake tools
1. 将工程拷贝到目标主机上,删除原有工程的build目录。
2. 配置编译工具链,vscode下,ctrl + shift + p, 输入cmake edit ,选择user-local Cmake kits
在弹出的cmake-tools-kits.json文件中添加编译工具链的路径
[ { "name": "GCC 9.3.0", "compilers": { "C": "/bin/gcc-9", "CXX": "/bin/g++-9" } }, { "name": "GCC for c89 9.3.0", "compilers": { "C": "/bin/c89-gcc" } }, { "name": "GCC for c99 9.3.0", "compilers": { "C": "/bin/c99-gcc" } }, { "name": "GCC for x86_64-linux-gnu 9.3.0", "compilers": { "C": "/bin/x86_64-linux-gnu-gcc-9", "CXX": "/bin/x86_64-linux-gnu-g++-9" } } ]
添加:
{ "name": "GCC for aarch64-himix100-linux 6.3.0", "compilers": { "C": "/opt/hisi-linux/x86-arm/aarch64-himix100-linux/bin/aarch64-himix100-linux-gcc-6.3.0", "CXX": "/opt/hisi-linux/x86-arm/aarch64-himix100-linux/bin/aarch64-himix100-linux-g++" } }, { "name": "GCC for arm-none-eabi 4.9.3", "compilers": { "C": "/opt/hisi-linux/x86-arm/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-gcc-4.9.3", "CXX": "/opt/hisi-linux/x86-arm/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-g++" } },
配置 ctrl + shift +p ,输入:cmake configure, 点击,就会自动生成build目录,在build目录重新make就可以。