[CMake] More than one C Compiler in a Project

Alexander Neundorf a.neundorf-work at gmx.net
Tue Dec 8 12:43:28 EST 2009


On Tuesday 08 December 2009, Rüdiger Ranft wrote:
> Hi all,
>
> I need to use two different C compilers in a project, because this
> project consists of both PC software and micro controller firmware. Is
> there a way to use cmake to generate Makefiles which call different
> compilers, (or to hard-code a second one, since the PC software can be
> developed with diferent compilers, but the MC software is fixed to one
> special vendor-provided)?

In general this is not supported (since all test results in CMakeCache.txt 
etc. are invalid for the other compiler).
But if you know what you are doing, it should be possible to just set the 
COMPILE-variables in the subdirectory where the sources for your 
microcontroller are manually to how they should look like for this compiler.
try_compile() tests etc. will not work properly there.
This is basically what is done in cmake/Modules/UseEcos.cmake, but this is 
already a few years old and today I consider this actually a hack.

Alex


More information about the CMake mailing list