Change C compilation to two step transformation like .m -> .bc -> .o

I actually want to write this make like rule in cmake

%.o: %.m
   mulle-clang $(LLVM_FLAGS) -c -emit-llvm -o $*.bc $<
   emcc $(EMCC_FLAGS) -c -o $@ $*.bc

This is not trivial it seems. At least I haven’t figured it out from the cmake codebase how the build system defines those rules and how to override them.

A workable solution would be to replace the mulle-clang/emcc calls with a script that does both steps. But my life would be LOT easier, if I could get cmake to do the two step compilation for me. This would I guess be analogous to compiling .c → .s → .o in two steps.