CMake generating invalid Ninja build rules for asm

I am attempting to use CMake with the Ninja generator to cross compile a project for ARM. Part of this project consists of .asm files that are passed to arm-none-eabi-as during the build process.

However, when I attempt to build the project I am returned with the following error when Ninja invokes arm-none-eabi-as:

/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-as: invalid option -- 'F'

Looking at the rules.ninja file generated by CMake I can find the corresponding rule:

rule ASM_COMPILER__qpc_
  depfile = $DEP_FILE
  deps = gcc
  command = /opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-as $DEFINES $INCLUDES $FLAGS -MD -MT $out -MF $DEP_FILE -o $out -c $in
  description = Building ASM object $out

As far as I can tell -MF is a supported argument for GCC, but it is not for GNU as.

What I am failing to grasp though is whether this is the result of a misconfiguration in my CMake project or a bug in CMake. I am using CMake version 3.17.3.

Could anyone shed any light?

Thank you

Hmm. We have tests for Ninja + ASM somewhere I’m sure. The flags are probably coming from CMAKE_DEPFILE_FLAGS_ASM as set in Modules/Compiler/GNU.cmake.

Cc: @kyle.edwards @brad.king

There was recent work on this:

Please try CMake 3.18.

Lucky me, I have just tested with CMake 3.18.0-rc1 and the issues appears to have gone away!

Thanks for your help @ben.boeckel @brad.king, I will wait for 3.18 to be released :slight_smile: