# Difference between Make and Ninja when adding simple language support

**URL:** <https://discourse.cmake.org/t/difference-between-make-and-ninja-when-adding-simple-language-support/4271>\
**Category:** Code\
**Created:** [October 13, 2021, 8:26pm UTC](https://discourse.cmake.org/t/difference-between-make-and-ninja-when-adding-simple-language-support/4271 "2021-10-13T20:26:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cerna](https://discourse.cmake.org/user_avatar/discourse.cmake.org/cerna/32/1299_2.png) [@cerna](https://discourse.cmake.org/u/cerna)\
**Post date:** [October 13, 2021, 8:26pm UTC](https://discourse.cmake.org/t/difference-between-make-and-ninja-when-adding-simple-language-support/4271/1 "2021-10-13T20:26:44Z")

</div>

Hello,  
I need to add simple language support to CMake for an assembler flavour. (Assembling special firmware for on-chip peripheral hardware.)

The assembling process is relatively trivial. It takes a single source file (`.p`) and from this creates an output file (`.bin`). There are no include directories (all includes must be done from the code with the relative include path to the main source) and no additional input files. The command for assembling is:

```auto
asm-executable -flag -flag input-source-file.p output-file

```

The output file cannot have the extension specified (`.bin`) and the executable will complain (error out) if there is any dot (`.`) in _output-file_ path.

So, I solved it with using only the **COMPILE\_OBJECT** step and having the **LINK\_EXECUTABLE** empty (I am adding the firmware as a `add_executable()`).

```auto
set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT
    "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <FLAGS> -b -d <SOURCE> <TARGET>"
)

```

```auto
set(CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE "")

```

And that - even though it is a dirty hack - worked fine, but only for a _Makefile_ generator, it does not work for Ninja. Ninja is not capable of recognizing and replacing the `<TARGET>` in object compile step. It is only able to translate the `<OBJECT>` identifier in **COMPILE\_OBJECT**.

Problem is, if I try something akin to

```auto
set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT
    "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <FLAGS> -b -d <SOURCE> <OBJECT>"
)

```

```auto
set(CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE "${CMAKE_COMMAND} -E copy_if_different <OBJECTS> <TARGET>.bin")

```

I have the problem that the object path has two dots (`src/firmware/CMakeFiles/firmware.dir/build/firmware.bin`) - on which the assembler errors out.

Thus, I need one of these things:

1. Better idea how to assemble the target

2. Way how to specify the output file for the object build (`${CMAKE_CURRENT_BINARY_DIR}/<TARGET_NAME>`)

3. Way how to change the `OBJECT_DIR` in `<OBJECT>` in object compilation step. (I can `set(CMAKE_ASM${ASM_DIALECT}_OUTPUT_EXTENSION "")` to remove the object extension.)

Any ideas?  
Thanks.
