[CMake] how to find out the compiler ID of a compiler which doesn't link

Alexander Neundorf a.neundorf-work at gmx.net
Tue Feb 23 13:23:02 EST 2010


On Monday 22 February 2010, Brad King wrote:
> Alexander Neundorf wrote:
> > Hi,
> >
> > it seems the IAR C/C++ compiler for AVR cannot generate executables, but
> > only object files, and the linker has to be called explcitely on the
> > generated object files:
> > ftp://ftp.iar.se/WWWfiles/avr32/guides/ocavr32.pdf
> >
> > Which says:
> > iccavr32 myfile.c
> > xlink myfile.r82 -s __program_start -f lnkavr32.xcl
> >
> > Can this be made to work with the compiler ID detection in cmake via
> > compiling a source file or is the only chance to use the new
> > CMAKE_DETERMINE_COMPILER_ID_VENDOR() function ?
>
> It doesn't have to link.  We can parse the compiler id out of object files.
> Look at lines in CMakeDetermineCCompiler that set
>
>   CMAKE_C_COMPILER_ID_TEST_FLAGS
>
> We already try compiling with just "-c" to get an object file.  Add the
> equivalent flag for this compiler if necessary.  Basically we just try
> with no flag, and then with each of the flags listed in this variable.
> After each build we scan all files for the compiler id.  If the object
> file is there it should work.

This is for the AIR compiler, and it produces an IAR .r90 file.
CMake tries to find the string in that file, but doesn't find it.

Here (http://public.kitware.com/Bug/view.php?id=10176) such a file is attached 
(main.r90), and now I actually found the text in it :-)
http://public.kitware.com/Bug/file_download.php?file_id=2896&type=bug

Near the end there is the "Hello world", but mixed with "6"s. Very strange.

Alex


More information about the CMake mailing list