[CMake] How to pass -D options when compiling assembly files using gcc?

Marcel Loose loose at astron.nl
Sun Jul 12 17:56:44 EDT 2009


On Sun, 2009-07-12 at 00:09 +0200, Eric Noulard wrote:
> 2009/7/11 Marcel Loose <loose at astron.nl>:
> > Hi Bill,
> >
> > The problem is not in the invocation of gcc. That works fine. The
> > problem is that I lose the preprocessor definitions that were added with
> > add_definitions() when compiling assembly files. These assembly files
> > must be preprocessed by gcc. I have the feeling that CMake purposely
> > drops these. So the question is how I can persuade CMake to keep the -D
> > options on the command line.
> 
> I don't know if you can persuade CMake to keep those for "compiling"
> ASM instead of C but you may be you get the
> currently added definitions using properties:
> (on directory, target or source
>  see cmake --help-properties)
> 
> e.g.:
> 
> get_directory_property(ASM_DEF DEFINITION)
> 
> then use the value of ASM_DEF in your *ASM*.cmake.
> 
> Take my opinion as "pure guess" because I does not know
> much on how CMake*Compiler.cmake works so I don't know
> if you may "share" some variables values between
> the standard C  and your custom ASM.
> 
> 
> > Note that I have defined an assembler for BG/P that uses gcc as
> > frontend, using the *ASM*.cmake macros mentioned in my previous mail.
> 
> 
Hi Eric,

Thanks, I'll try that tomorrow. Another option that occurred to me today
is that, since I'm using gcc to preprocess and compile the assembly
sources, I might add .S as source file extension to 
CMAKE_C_SOURCE_FILE_EXTENSIONS. Any idea if that might work?

Best regards,
Marcel Loose.




More information about the CMake mailing list