cmake与ccache交叉编译时ar和strip不正确

时间:2013-04-10 10:32:21

标签: cmake cross-compiling ccache

我交叉编译了一个项目女巫ccache:

cmake -G"Unix Makefiles" \
      -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_TOOLCHAIN_FILE=mips64el-toolchain.cmake

以下是mips64el-toolchain.cmake:

SET (CMAKE_SYSTEM_NAME Linux)
SET (CMAKE_SYSTEM_PROCESSOR mips64el)

SET (CMAKE_C_COMPILER ccache mips64el-n64-linux-gnu-gcc)
SET (CMAKE_CXX_COMPILER ccache mips64el-n64-linux-gnu-g++)

# here is the target environment located
SET (CMAKE_FIND_ROOT_PATH 
     $ENV{HOME}/x-tools/mips64el-n64-linux-gnu/mips64el-n64-linux-gnu/sysroot)

# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

但我发现CMakeCache.txt中的值不正确:

CMAKE_AR:FILEPATH=/usr/bin/ar
CMAKE_STRIP:FILEPATH=/usr/bin/strip

ar和strip不是交叉编译器。

如何正确设置?

一周前,我发现这是一个cmake的错误并已修复

  • 模块/ CMakeDetermineCCompiler.cmake
  • 模块/ CMakeDetermineCXXCompiler.cmake

有关详情,请参阅

https://launchpad.net/~likemartinma/+archive/devel

1 个答案:

答案 0 :(得分:2)

尝试设置CMAKE_AR设置ar {和CMAKE_STRIPCMAKE_TOOLCHAIN_FILE中的条带设置。

我正在其中一个项目中使用CMAKE_AR来设置正确的ar,因为平台有来自不同供应商的多个ar