# Post-compilation step

**URL:** <https://discourse.cmake.org/t/post-compilation-step/1265>\
**Category:** Code\
**Created:** [May 23, 2020, 4:57pm UTC](https://discourse.cmake.org/t/post-compilation-step/1265 "2020-05-23T16:57:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cola](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/77aa72/32.png) [@cola](https://discourse.cmake.org/u/cola)\
**Post date:** [May 23, 2020, 4:57pm UTC](https://discourse.cmake.org/t/post-compilation-step/1265/1 "2020-05-23T16:57:58Z")

</div>

Hi!

I have a project with several custom toolchains. When using one of the toolchains and building Release I have to do som post-compile processing of the object-files before linking, so currently I have a PRE\_LINK custom command inside an if-block in the code that is common for all toolchains which calls a cmake-script with all the object files as argument (`-DFILES=$<TARGET_OBJECTS:${PROJECT_NAME}>`) if the toolchain is X and build type is Release.

I would rather have this functionality specified in the toolchain file, so that the post-compile is done after each compilation. But I’ve hit a brick wall here and have no idea on how to solve this, or if it is even possible, and any help would be appreciated.

Expressed in makefile-ish its something like this I’m after:

```auto
%.obj : %.c
    cc %.c -o %.obj
    strip %.obj

```

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [December 30, 2020, 7:50pm UTC](https://discourse.cmake.org/t/post-compilation-step/1265/2 "2020-12-30T19:50:30Z")

</div>

I’m not sure that such a thing is possible as-is. You might be able to leverage the [`CMAKE_<LANG>_COMPILER_LAUNCHER`](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_LAUNCHER.html#variable:CMAKE_%3CLANG%3E_COMPILER_LAUNCHER) variable to use a script to do this (though you’ll likely have to extract the output file manually).
