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

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

问题描述

我有两件事情,我不能弄清楚。
(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)

命令窗口在Windows7,它是编译为Visual Studio 10在默认情况下(我不选择任何选项,它发生在默认情况下) - 构建为:Visual Studio 10 。如何更改它为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.

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

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