[cmake-developers] How to deal with assembler files
neundorf at kde.org
Tue Aug 17 16:39:24 EDT 2010
current support for assembler has the shortcoming that in all cases the
assembler is called directly (e.g. as, gas, masm, nasm, etc.).
This works as long as the assembler files don't have preprocessor directives
But if that's the case, the assembler files should be actually processed by
the C (or C++ ?) compiler.
Currently you can do
This should be the somehow generic one.
-> enable the ASM language, which is either "as" or "gas", *.s, *.S, *.asm
-> also "as" or "gas", assembler files should be AT&T syntax
-> ml.exe or ml64.exe, *.asm, using masm syntax
(ASM_NASM will come soon)
These special versions for assembler are necessary since within one project
there can be files which need to be processed e.g. with gas, while others
need to be processed with nasm, so it must be possible to differentiate
between different assembler files within one project.
Still, there is the preprocessing bug.
So here's my idea how to modify the behaviour:
will in general use the C compiler for the assembler files. It seems most C
compilers can do that. This will make these files being preprocessed, and it
will be the "default" syntax for the toolchain.
When a different asm syntax is needed, this can still be enabled via ASM_ATT,
2) Only issue: what to do when the C compiler is not able to process assembler
It seems e.g. when using the IAR toolchain, the assembler *must* be called for
asm files, not the C compiler. So here just using the C compiler for ASM
would fail. But having to enable e.g. "ASM_IAR" should not be necessary,
since for this toolchain there is probably no other assembler which could be
How about this: when C and/or C++ are enabled, they can set a hint what to use
for ASM. E.g. for IAR-C.cmake could "set(CMAKE_ASM_SUGGESTED_COMPILER
iasmarm)", which could then be preferred by CMakeDetermineASMCompiler.cmake.
It could also directly preset CMAKE_ASM_COMPILER or CMAKE_ASM_COMPILER_INIT.
Does that sound reasonable ?
More information about the cmake-developers