I have assembly files(*.asm extension) with C preprocessor statements. These files are recognized by CMAKE as ASM files. On compilers where the control program/compiler itself supports pre-processing and assembling I do not run into any problems. On the compilers where the compiler only supported preprocessing and assembling has to be done by the seperate assembler, I run into problems(as I can either send the files to the compiler to preprocess or to the assembler to assembler but not both).
Can someone point me to the right direction on what would be the best way to preprocess the .asm using the CMAKE_C_COMPILER and then piping the output over to the CMAKE_ASM_COMPILER for assembling.
CMake does not model explicit preprocessing in general. ASM sources may be preprocessed if the assembler itself supports doing so. Many assemblers support preprocessing upper-case extensions, particularly when the C compiler itself is used as the assembler.
Otherwise, one could look at using add_custom_command to run the C preprocessor first and generate an already-preprocessed source that is then given to add_library or add_executable as an ASM source.
Our customer faced the same problem.
Assembler preprocessing is done by gcc and, most probably, armclang if -x assembler-with-cpp CLI options are provided. So for me add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-x$<SEMICOLON>assembler-with-cpp>) clause does the trick.