[CMake] build using separate compiler,assembler,linker

Alex mail_cmake at eden.home.dyndns.org
Tue Feb 7 15:03:03 EST 2012


Hi all,
Since some days I’m trying to build a toolchain for crosscompiling but 
I stuck so far while trying to execute a buildprocess with two stages. 
According to a makefile I use as template, the processing looks as follows:

Given some .c sourcefiles the makefile executes:

Invoking: Compiler
CTC.EXE mcs0.c –I… --Flags… -o MCS0.src

Invoking: Assembler
ASTC.EXE MCS0.src –Flags… -o MCS0.o

Invoking: Linker
LTC.EXE MCS0.o … librt.a … -I –Flags… -L… 

I create a toolchain file and also some platform configuration for 
compiler and assembler. However I have in particular a problem to invoke the assembler. 
That is, when calling add_executable with the c-files as arguments the src-files 
are generated. But these files are fed to the linker without the intermediate 
step to build the object files. Of course the linker says ‘unknown file format’.
 
I have tried to provide an assembler configuration that is enabled 
with enable_language before, but this works only for src-files that are provided 
to the add_executable() instead of the c-files (c->src with a custom 
target before, calling the compiler). The assembler is not applied to the 
automatically generated .src files in the first step … that means if I 
provide (for testing) some c-files and some src-files, both are processed correctly, 
but not the src-files resulting from the compiler during the build of the target.

My third option was to implement both the compiler and assembler call 
by means of custom target … however .. don’t’ work until now 
and seems more or less the ugly solution.
 
Has anyone experience with this kind of building … without using custom targets? 
What is the general method to enable such two-step build process? 
My goal is to provide a toolchain-configuration with the specification 
of assembler, compiler, linker and archiver … for me is also not completely clear 
how to enable an assembler like the compiler with CMAKE_C_COMPILER. 
E.g. CMAKE_C_CREATE_ASSEMBLY_SOURCE has no effect on my configuration.

So far I did not found a comprehensive documentation of this feature(s), even 
in the cmake-book. Therefore I would be very thankfull for any kind of information ;-) 

Cu, Alex


More information about the CMake mailing list