[CMake] how to find out the compiler ID of a compiler which doesn't link
Brad King
brad.king at kitware.com
Mon Feb 22 16:36:29 EST 2010
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.
-Brad
More information about the CMake
mailing list