# CMake generating invalid Ninja build rules for asm

**URL:** https://discourse.cmake.org/t/cmake-generating-invalid-ninja-build-rules-for-asm/1389
**Category:** Usage
**Tags:** gen:ninja
**Created:** [June 13, 2020, 5:46pm UTC](https://discourse.cmake.org/t/cmake-generating-invalid-ninja-build-rules-for-asm/1389 "2020-06-13T17:46:45Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![tbrearley](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/cab0a1/32.png) [@tbrearley](https://discourse.cmake.org/u/tbrearley)
#### Post date: [June 13, 2020, 5:46pm UTC](https://discourse.cmake.org/t/cmake-generating-invalid-ninja-build-rules-for-asm/1389/1 "2020-06-13T17:46:46Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [June 15, 2020, 11:50am UTC](https://discourse.cmake.org/t/cmake-generating-invalid-ninja-build-rules-for-asm/1389/2 "2020-06-15T11:50:26Z")

</div>

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

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [June 15, 2020, 12:01pm UTC](https://discourse.cmake.org/t/cmake-generating-invalid-ninja-build-rules-for-asm/1389/3 "2020-06-15T12:01:12Z")

</div>

There was recent work on this:

- [https://gitlab.kitware.com/cmake/cmake/-/merge\_requests/4460](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4460)
- [https://gitlab.kitware.com/cmake/cmake/-/merge\_requests/4838](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4838)

Please try CMake 3.18.

---

<div class="post-metadata">

### Author: ![tbrearley](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/cab0a1/32.png) [@tbrearley](https://discourse.cmake.org/u/tbrearley)
#### Post date: [June 15, 2020, 4:11pm UTC](https://discourse.cmake.org/t/cmake-generating-invalid-ninja-build-rules-for-asm/1389/4 "2020-06-15T16:11:58Z")

</div>

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 🙂
