[CMake] CMake 2.6.0 cross-compile: 1st time failed, 2nd time passed
Alexander Neundorf
a.neundorf-work at gmx.net
Wed Aug 6 17:03:46 EDT 2008
On Wednesday 06 August 2008, ning wrote:
> Hi, Alex
>
...
> I removed force compiler inclusion from CMAKE_TOOLCHAIN_FILE and
> "if (CMAKE_CROSSCOMPILING)" clause from CMakeLists.txt to try
> set(CMAKE_C_COMPILER
> "arm-wrs-linux-gnueabi-gcc"
> "--sysroot=${SYSROOT_PATH} -mfloat-abi=softfp")
> It works well.
Nice to hear :-)
> >> One note: It looks like CMAKE_C_FLAGS should not be set in
> >> cross-tools.cmake which is assigned to -DCMAKE_TOOLCHAIN_FILE
> >> in command line. CMAKE_C_FLAGS for cross compiler should
> >> be surrounded by "if (CMAKE_CROSSCOMPILING)...endif" in
> >> CMakeLists.txt.
> >
> > Yes, if you set compiler flags or similar things in CMakeLists.txt you
> > should always put this in appropriate IF() statements, so they are only
> > executed for the compiler they are intended for (not only when cross
> > compiling, e.g. you also need different flags whether you are using gcc
> > or msvc).
>
> Actually I would like to put cross-compiler specific flags in
> CMAKE_TOOLCHAIN_FILE,
No, the toolchain file should be very small and only contain the stuff
required for cross compiling.
E.g. somebody could try to build the project for ARM under qemu. Then he
doesn't need the toolchain file. But he should still get the correct settings
for his compiler.
You could create a file MyCompilerSettings.cmake (or something like this) in
your source tree and include this in the toplevel CMakeLists.txt, so it stays
nicely separated.
Alex
More information about the CMake
mailing list