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

**URL:** https://discourse.cmake.org/t/change-c-compilation-to-two-step-transformation-like-m-bc-o/15349
**Category:** Code
**Tags:** comp:clang
**Created:** [November 27, 2025, 10:16am UTC](https://discourse.cmake.org/t/change-c-compilation-to-two-step-transformation-like-m-bc-o/15349 "2025-11-27T10:16:43Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mulle-nat](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mulle-nat/32/4251_2.png) [@mulle-nat](https://discourse.cmake.org/u/mulle-nat)
#### Post date: [November 27, 2025, 10:16am UTC](https://discourse.cmake.org/t/change-c-compilation-to-two-step-transformation-like-m-bc-o/15349/1 "2025-11-27T10:16:44Z")

</div>

I actually want to write this `make` like rule in cmake

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