On Tuesday 05 August 2008, ning wrote:
> Hi, all
>
> Just for other cmake newbies, like me, who run into cross-compiler that
> is not able to build a simple program by default without special flags.
> When I go on reading the wiki
> http://www.cmake.org/Wiki/CMake_Cross_Compiling
> I found that I should use CMakeForceCompiler module to bypass build
> of cmTryCompileExec. It works for me now.

You need two special flags, if I see correctly ?
> > SET(CMAKE_C_FLAGS       "--sysroot=${SYSROOT_PATH} -mfloat-abi=softfp")
> > SET(CMAKE_C_COMPILER    "arm-wrs-linux-gnueabi-gcc")

And these both are really required for building just the most basic 
executable ?
Currently cmake supports 1 additional extra argument, then you could do it 
like this:
SET(CMAKE_C_COMPILER  arm-wrs-linux-gnueabi-gcc "--sysroot=${SYSROOT_PATH}")

You can try if you get this working for you.



> 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).

Alex
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to