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

Brad King brad.king at kitware.com
Fri Jul 7 09:46:08 EDT 2006


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.

-Brad


More information about the CMake mailing list