# output of cmake command to a file

**URL:** https://discourse.cmake.org/t/output-of-cmake-command-to-a-file/2287
**Category:** Code
**Created:** [December 3, 2020, 3:06pm UTC](https://discourse.cmake.org/t/output-of-cmake-command-to-a-file/2287 "2020-12-03T15:06:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Tzlil\_Gavra](https://discourse.cmake.org/user_avatar/discourse.cmake.org/tzlil_gavra/32/991_2.png) [@Tzlil\_Gavra](https://discourse.cmake.org/u/Tzlil_Gavra)
#### Post date: [December 3, 2020, 3:06pm UTC](https://discourse.cmake.org/t/output-of-cmake-command-to-a-file/2287/1 "2020-12-03T15:06:00Z")

</div>

I’m trying to get the output of my compiler while building a project (with the command `cmake --build build_dir --target all -- -j 3`)  
Because I want every target to be printed in a separate file, I can’t use simple piping mechanism.  
Is there a way to tell the cmake to print its output to a file?  
Something like a flag to output not just the .o files, but also the compiler stdout stream?

---

<div class="post-metadata">

### Author: ![robert.maynard](https://discourse.cmake.org/user_avatar/discourse.cmake.org/robert.maynard/32/4_2.png) [@robert.maynard](https://discourse.cmake.org/u/robert.maynard)
#### Post date: [December 3, 2020, 3:37pm UTC](https://discourse.cmake.org/t/output-of-cmake-command-to-a-file/2287/2 "2020-12-03T15:37:17Z")

</div>

You might be able to do this by writing a custom compiler wrapper and setting it via `CMAKE_<LANG>_COMPILER_LAUNCHER`. This would give you full control over each compiler invocation.
