[CMake] Toolchains and CMAKE_FORCE_C_COMPILER in 3.5

Thibault Genessay tibogens at gmail.com
Tue Feb 9 09:10:00 EST 2016


Hi,

I'm a long time user of CMake (and huge fan of it) but newly registered on
this list, so please forgive me if I have missed something regarding the
new 3.5 series.

I use CMake with the GCC ARM Embedded compiler (
https://launchpad.net/gcc-arm-embedded) to cross-compile my project
(Windows host, STM32 target, MinGW binutils). Like many users (all?) I had
to create a toolchain file because CMake doesn't support this
compiler/setup out of the box. I have taken inspiration from the many
Google hits and had a working setup until 3.5. This setup relied on the
CMAKE_FORCE_<lang>_COMPILER macros.

I installed 3.5 and the build broke, CMake complaining that this macro was
deprecated and should not be used because of the many improvements on the
compiler detection side. OK, so I removed the offending lines, simply
setting the CMAKE_C_COMPILER variable to the compiler's executable ... and
suddenly I remember why I did use this FORCE hack in the first place: CMake
tells me my compiler is broken because it cannot compile a test program
(undefined symbol: _exit). This is somehow correct, as I compile for bare
metal and I am providing the _exit function in my code. This is a
misunderstanding the CMAKE_FORCE_C_COMPILER works around by simply saying
"believe me, this compiler works".

Now I am left without many options: I can't use the FORCE hack, and I can't
convince CMake my compiler is OK. I am very open to redesign my toolchain
file, or use a stock one from CMake, or whatever this takes, but I simply
do not know how to proceed. Actually, I feel my current toolchain file,
although functional, is not "clean" but never had enough time to do it. Now
that it's a blocking issue, I do have time :)

I rolled back to 3.4 and things work so I'm safe for now. But I would be
very glad if somebody knew more about this specific problem, or this
compiler, or toolchain file writing in general. I would love to write a
"stock" toolchain file for this compiler but I simply do not know enough
(nor I can find enough up-to-date documentation).

Thanks for reading,
Cheers

Thibault
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160209/0cfaa5de/attachment.html>


More information about the CMake mailing list