[cmake-developers] How to deal with assembler files
Alexander Neundorf
neundorf at kde.org
Tue Aug 17 16:39:24 EDT 2010
Hi,
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
in them.
But if that's the case, the assembler files should be actually processed by
the C (or C++ ?) compiler.
Currently you can do
enable_language(ASM)
This should be the somehow generic one.
-> enable the ASM language, which is either "as" or "gas", *.s, *.S, *.asm
enable_language(ASM-ATT)
-> also "as" or "gas", assembler files should be AT&T syntax
enable_language(ASM_MASM)
-> 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:
1)
enable_language(ASM)
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,
ASM_NASM, etc.
2) Only issue: what to do when the C compiler is not able to process assembler
files ?
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
used.
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 ?
Alex
More information about the cmake-developers
mailing list