Difference between Make and Ninja when adding simple language support

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:

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()).

set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT
    "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <FLAGS> -b -d <SOURCE> <TARGET>"
)
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

set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT
    "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <FLAGS> -b -d <SOURCE> <OBJECT>"
)
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.