Like
Like

Reputation: 1536

Incorrect ar and strip when cmake cross-compiling with ccache

I cross-compiled one project witch ccache:

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

The following is 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)

But I found the incorrect values in CMakeCache.txt:

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

ar and strip are not the cross-compiler ones.

How to set them correctly?

A weeks ago, I found it was a bug of cmake and fixed in

For the details, please see also

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

Upvotes: 3

Views: 2585

Answers (1)

bikram990
bikram990

Reputation: 1115

Try setting CMAKE_AR for setting ar and CMAKE_STRIP for strip in CMAKE_TOOLCHAIN_FILE.

I'm using CMAKE_AR in one of my projects to set proper ar as Platform was having multiple ar from different vendors.

Upvotes: 2

Related Questions