Difference between Make and Ninja when adding simple language support

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


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


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?