[CMake] Cross Compiling

Alexander Neundorf a.neundorf-work at gmx.net
Mon Jan 4 13:15:40 EST 2010


Hi,

On Monday 04 January 2010, Daniel Stonier wrote:
> The more I use cmake, the more I find it difficult to bend in to shape to
> cross compile. The original design doesn't seem to be designed for anything
> more than windows-linux or linux-windows cross compiles.

No. It is tested for 
* x86 Linux to ARM/MIPS/PPC Linux
* x86 Linux to x86 Windows
* x86 Windows to x86 Linux 
(not sure I tested also x86 Windows to ARM/MIPS/PPC Linux)
* x86 Linux to 16bit uC without OS
* x86 Linux to ARM/PPC eCos
* x86 Linux to PPC CNK

> Some things I'm having to currently work around by creating my own
> cross-compiling set of modules. My host is an amd64 linux and my target is
> an arm linux.
>
> - You can't set CMAKE_SYSTEM_NAME to anything useful other than Linux,
> which of course doesn't trigger the cross-compile variable CROSS_COMPILING
> because the host is the same.

See my other mail. You need to preset CMAKE_SYSTEM_NAME.

> - There is no distinction between install prefixes for the target and the
> host. Sometimes I'd like to put various build tools on the host system at
> the same time as libs and binaries on the target root.

In CMake one build tree uses one toolchain. So in one build tree you can only 
create executable which run either for the target, of for the host, not both 
in one go.
So if you need first to create host build tools, and later on use them for the 
actual cross compile, you need two build trees. I would recommend to "export" 
the executable and "import" them again in the cross build.

If this is not your problem, but really just the install location, you can set 
the install location of every install() command separately, this is 
completely independent from the cross compiling support.

> - Debian packaging in cpack will only ever put things in /usr, regardless
> of cross-compiles or different CMAKE_INSTALL_PREFIX. Refer again to above
> comment.

What is the connection between Debian and cpack and the cross compiling ?
Can you please explain ?

> Having some useful autotools install style variables (--prefix and
> --exec-prefix), someway of utilising of proper gnu tuples (e.g.
> arm-unknown-linux-gnueabi) would make things alot easier.

Can you please elaborate on this ?

Alex


More information about the CMake mailing list