[CMake] Adding cross-compiler support to CMake ...
Alexander Neundorf
a.neundorf-work at gmx.net
Fri Sep 8 15:31:33 EDT 2006
Hi,
Von: "William A. Hoffman" <billlist at nycap.rr.com>
...
> The trouble is that in the case of 2, when you build
> some sort of code generation executable as part of the build and run it
> during
> the build, it has to be built for the host or local machine.
Exactly.
Just imagine somebody might want to cross-compile KDE...
...and I'm afraid that day will come.
But apart from that, two other things.
I'm using cmake daily for cross-compiling for an embedded target (eCos). There no configure tests (TRY_RUN/TRY_COMPILE) are required. The compiler are named arm-elf-gcc or powerpc-eabi-gcc, i.e. only a two-part prefix.
Basically all I do is:
SET(CMAKE_COMPILER_IS_GNUCXX 1)
SET(CMAKE_CXX_COMPILER "arm-elf-c++")
SET(CMAKE_C_COMPILER "arm-elf-gcc")
SET(CMAKE_AR "arm-elf-ar")
SET(CMAKE_RANLIB "arm-elf-ranlib")
and adjust the link command:
SET(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <CMAKE_CXX_LINK_FLAGS> <OBJECTS> -o <TARGET> -nostdlib -nostartfiles -L${CMAKE_CURRENT_SOURCE_DIR}/ecos/install/lib -Ttarget.ld")
This works even per-directory.
On this platform e.g. no dynamic linking exists, so many things are much more simple.
I almost have the impression that just setting a "toolchain-prefix" (e.g. "arm-elf-" goes already a long way.
Just my 2 cent.
Alex
--
"Feel free" – 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
More information about the CMake
mailing list