Makefile generator specification at cross compilat

2019-02-20 20:57发布

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) 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

1条回答
ゆ 、 Hurt°
2楼-- · 2019-02-20 21:18

(According to the documentation at http://www.cmake.org/Wiki/CMake_Cross_Compiling)

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

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.

查看更多
登录 后发表回答