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
- Modules/CMakeDetermineCCompiler.cmake
- Modules/CMakeDetermineCXXCompiler.cmake
For the details, please see also