[CMake] Location of ar and ld during cross-compilation

Alexander Neundorf a.neundorf-work at gmx.net
Mon Apr 20 15:54:46 EDT 2009


On Monday 20 April 2009, Denis Scherbakov wrote:
> I have a set of cross-compilers and toolchain files for them. Our binutils
> are separated from gcc. Say:
>
> /cross/path/binutils/bin
> /cross/path/gcc/bin
>
> As I understood from CMakeFindBinUtils.cmake script, it looks for binutils
> only in /cross/path/gcc/bin, and ignores CMAKE_FIND_ROOT_PATH completely.

FIND_PROGRAM(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar 
             HINTS ${_CMAKE_TOOLCHAIN_LOCATION})

This means first it checks in ${_CMAKE_TOOLCHAIN_LOCATION}, and after that in 
the standard directories.
CMAKE_FIND_ROOT_PATH should be considered, as it is by default, i.e. first the 
directories in CMAKE_FIND_ROOT_PATH, after that the ones without 
CMAKE_FIND_ROOT_PATH.
But in general CMAKE_FIND_ROOT_PATH is supposed to point to the target 
environment, i.e. libs, headers and data files for the target. The cross 
compiler itself not necessarily belongs to this.

How does your CMAKE_FIND_ROOT_PATH look like ?

> Q1: Is it a bug or intended feature?

I'm tending towards "feature".

> Q2: Is there a way to specify location of AR and others in a toolchain
> file?

If you set CMAKE_PREFIX_PATH to /cross/path/binutils/ it should be found.
Or you could just set CMAKE_AR etc. directly in the toolchain file, this 
should also keep FIND_PROGRAM() from searching it again.

Alex


More information about the CMake mailing list