与 CMake 交叉编译时的 Makefile 生成器规范 [英] Makefile generator specification at cross compilation with CMake

查看:25
本文介绍了与 CMake 交叉编译时的 Makefile 生成器规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两件事想不通.(1)使用CMake-GUI时,可以指定makefile生成器.我将使用 Debian Linux 为 Raspberry PI 进行交叉编译.我找不到相关的生成器.我必须选择哪种发电机?我有 toolchain-rpi.cmake 如下.

I have two things I can't figure out. (1)When using CMake-GUI, we can specify makefile generator. I am going to cross compile for Raspberry PI with Debian Linux. I can't find the relevant generator. Which generator I have to choose? I have toolchain-rpi.cmake as follow.

INCLUDE(CMakeForceCompiler)

SET(CMAKE_SYSTEM_NAME Linux) # this one is important
SET(CMAKE_SYSTEM_VERSION 1)  # this one not so much

SET(CMAKE_C_COMPILER   $ENV{RPI_CC}/bin/arm-bcm2708hardfp-linux-gnueabi-gcc)
SET(CMAKE_CXX_COMPILER $ENV{RPI_CC}/bin/arm-bcm2708hardfp-linux-gnueabi-g++)
SET(CMAKE_AR           $ENV{RPI_CC}/bin/arm-bcm2708hardfp-linux-gnueabi-ar)
SET(CMAKE_LINKER       $ENV{RPI_CC}/bin/arm-bcm2708hardfp-linux-gnueabi-ld)
SET(CMAKE_NM           $ENV{RPI_CC}/bin/arm-bcm2708hardfp-linux-gnueabi-nm)
SET(CMAKE_OBJCOPY      $ENV{RPI_CC}/bin/arm-bcm2708hardfp-linux-gnueabi-objcopy)
SET(CMAKE_OBJDUMP      $ENV{RPI_CC}/bin/arm-bcm2708hardfp-linux-gnueabi-objdump)
SET(CMAKE_STRIP        $ENV{RPI_CC}/bin/arm-bcm2708hardfp-linux-gnueabi-strip)
SET(CMAKE_RANLIB       $ENV{RPI_CC}/bin/arm-bcm2708hardfp-linux-gnueabi-tanlib)

# where is the target environment 
SET(CMAKE_FIND_ROOT_PATH  $ENV{RPI_CC}/arm-bcm2708hardfp-linux-gnueabi)

# search for programs in the build host directories
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)

(2) 当我在 Windows7 的命令窗口中运行 cmake 时,它​​默认为 Visual Studio 10 编译(我没有选择任何选项,它在默认情况下发生)作为 --Building for: Visual Studio10.如何更改它以构建 Debian Linux?谢谢

(2) When I run cmake at command window at Windows7, it is compiling for Visual Studio 10 in default (I don't choose any option and it happens in default) as -- Building for: Visual Studio 10. How can I change it to build for Debian Linux? Thanks

推荐答案

(根据 http://www.cmake.org/Wiki/CMake_Cross_Compiling)

您需要一个 工具链文件,并且您必须通过以下方式指示 CMake 使用它定义 CMake 变量 CMAKE_TOOLCHAIN_FILE.

You need a toolchain file, and you must instruct CMake to use it, by defining the CMake variable CMAKE_TOOLCHAIN_FILE.

此外,如果您想使用该工具链进行构建,您的 CMake 生成器必须是Unix Makefile".这意味着构建工具将是 make 而不是 Visual Studio.因为我不确定 CMake 是否可以制作使用 gcc 交叉编译器的 Visual Studio 项目.

What is more, if you want to build using that toolchain, your CMake generator must be "Unix Makefile". That means that the build tool will be make instead of Visual Studio. Because I am unsure that CMake can make a Visual Studio project that uses the gcc cross-compiler.

这篇关于与 CMake 交叉编译时的 Makefile 生成器规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆