[CMake] CMake 2.6.0 cross-compile: 1st time failed, 2nd time passed

ning mailxiening at gmail.com
Wed Aug 6 20:40:17 EDT 2008


Hi Alex

2008/8/7 Alexander Neundorf <a.neundorf-work at gmx.net>:
> 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.
I see, I'll try to add such a MyCompilerSettings.cmake file to make both
CMakeLists.txt and toolchain file clean.
>
> Alex
>
Thank you.
ning


More information about the CMake mailing list