[CMake] how to add capability to generate preprocessed and not-yet-compiled files ?

Alexander Neundorf a.neundorf-work at gmx.net
Sat Jul 15 17:30:33 EDT 2006


Hi,

Von: Brad King <brad.king at kitware.com>

> Alexander Neundorf wrote:
> > -------- Original-Nachricht --------
> > Von: Brad King <brad.king at kitware.com>
> > 
> >> Alexander Neundorf wrote:
> >>> Hi,
> >>>
> >>> it would be nice if it would be possible to have for each object file
> >> also a target which only preprocesses the file and one which
> >> preprocesses and compiles, but not assembles the file (so that you get
> >> the assembler code).
> >>> Is there a way to do this with macros ? 
> >>> I almost think this would have to be done in cmake itself. Probably
> >> somewhere where the object rules are created additionally for each
> object the
> >> same rule but with "-E" instead of "-c" would have to be created. It
> >> wouldn't be required to be executed on all, just on direct invocation:
> >>> make foo.o/pre
> >>> make foo.o/as
> >>>
> >>>
> >>> What do you think about this ?
> >>> Would you accept a patch ?
> >> Look in Modules/CMakeCInformation.cmake for the variable 
> >> CMAKE_C_COMPILE_OBJECT.  Other modules in the Platform directory set it
> >> also.  Just duplicate the variable with one called 
> >> CMAKE_C_PREPROCESS_OBJECT and then setup 
> >> cmLocalUnixMakefileGenerator3.cxx to create rules with ".E" extensions 
> >> instead of ".o".  You should be able to locate places that lookup 
> >> *_COMPILE_OBJECT vars.  See Modules/CMakeCXXInformation.cmake for the 
> >> C++ version.
> > 
> > Ok, yesterday I had a look at it and managed to get the rules for
> preprocessed files produced.
> > It ended up in cmMakefileTargetGenerator::WriteObjectBuildFile().
> > Problem: the rule was created in
> builddir/CMakeFiles/target.dir/build.make, but not in builddir/Makefile, so I had to enter "make -f
> CMakeFiles/target.dir/build.make main.o.E".
> > What do I have to do to have this rule also appear in the Makefile in
> the build dir ?
> 
> There are "convenience" targets written to the builddir/Makefile for
> each object file in that directory with a rule to just invoke the
> appropriate build.make copy of the rule.  You'll have to locate the code
> that does this and add one for the .E files also.

Attached is a first try of a patch against 2.4 branch.
It introduces two new variables CMAKE_CREATE_PREPROCESS_RULES and CMAKE_CREATE_ASSEMBLE_RULES. I think especially the name CMAKE_CREATE_ASSEMBLE_RULES is not good (since actually everything except assembling is done).
The created files are named foo.o.E and foo.o.S (was easier than to replace the suffix.
I know only the compiler switches for gcc, so I added them only in gcc.cmake.

What do you think ?

Bye
Alex


-- 


"Feel free" – 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
-------------- next part --------------
A non-text attachment was scrubbed...
Name: preprocess-and-assemble.diff
Type: text/x-diff
Size: 8997 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/cmake/attachments/20060715/1cbdc701/preprocess-and-assemble.bin


More information about the CMake mailing list