IF(UNIX)
# CROSS COMPILATION! ON/OFF
#SET(CMAKE_C_COMPILER /home/username/projects/buildroot/output/host/usr/bin/arm-linux-gcc)
#SET(CMAKE_CXX_COMPILER /home/username/projects/buildroot/output/host/usr/bin/arm-linux-g++)
#SET(CMAKE_C_COMPILER /home/username/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi-gcc)
#SET(CMAKE_CXX_COMPILER /home/username/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi-g++)
这就是我现在所做的交叉编译。我想添加选项来运行它:
make CROSS_COMPILE=~/projects/buildroot/output/host/usr/bin/arm-linux-
如果我不将 CROSS_COMPILE 路径设置为 make(而不是 cmake),则它必须使用系统默认值,因此 cmake 必须将此选项路径设置为 makefile。我怎样才能做到呢?
最佳答案
Buildroot 为您生成一个 CMake 工具链文件。根据您的 Buildroot,它可能直接位于 output
目录中,或位于 output/host/usr/share/buildroot
中。该文件名为 toolchainfile.cmake
。然后要构建您的 CMake 应用程序,请执行以下操作:
cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/buildroot/output/host/usr/share/buildroot/toolchainfile.cmake
该文件包含交叉编译器路径、pkg-config 环境变量、头文件和库位置等的所有定义。
关于makefile - 将选项传递给 cmake 以供将来交叉编译的选项 (CROSS_COMPILE),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10549924/