# Creating logs

**URL:** https://discourse.cmake.org/t/creating-logs/10035
**Category:** Usage
**Tags:** os:windows, gen:makefiles, gen:ninja
**Created:** [February 8, 2024, 1:13pm UTC](https://discourse.cmake.org/t/creating-logs/10035 "2024-02-08T13:13:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Bert](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/9e8a1a/32.png) [@Bert](https://discourse.cmake.org/u/Bert)
#### Post date: [February 8, 2024, 1:13pm UTC](https://discourse.cmake.org/t/creating-logs/10035/1 "2024-02-08T13:13:40Z")

</div>

I know this question has been asked before, but I still can’t quite figure it out. Regarding the toolchain, I am using CMake 3.27, ninja for the generator, and arm-none-eabi for the GCC compiler toolchain, where my host machine is Windows, and the target firmware is built against a Cortex-M.

After building, I would like to create a post-build step that parses the resulting log file and pulls out all the compiler warnings (there are a lot in this project I have inherited). The problem is that the log file Ninja creates has no compiler warnings; stdout is the only place I can see the compiler warnings.

Not that it matters, but I am using CMakePresets, so when I build, technically, I could do something like this:  
cmake --build --preset foo \>\> build\_log.txt

However, I have a group of devs, so each one would have to remember to type that exact command, or, I would have to wrap it in a script, but that adds another layer of complexity. Presets have been the norm for the team, but I can’t ask people to also create log files. Instead, I want to find a way to do this implicitly.

I \*_almost_ had things working in a hacky sort of way, by leveraging _CMAKE\_RULE\_LAUNCH\_COMPILE_. I never did get it working, as it was kind of an abuse of functionality on my end, but it was worth a try.

Anyway, do you know of any hacks or workarounds that would let me write the compiler warnings to a file as part of the build? Maybe there are some different generators like Make that support logs? Or maybe there’s a flag I can pass to Ninja to show the compiler warnings in the log? I’ve searched all over, so this was my last hope.

Thanks!

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [February 9, 2024, 11:15pm UTC](https://discourse.cmake.org/t/creating-logs/10035/2 "2024-02-09T23:15:43Z")

</div>

Try [builddriver](https://pypi.org/project/builddriver/), that may help

---

<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: [February 17, 2024, 5:47am UTC](https://discourse.cmake.org/t/creating-logs/10035/3 "2024-02-17T05:47:14Z")

</div>

In addition to `builddriver` (I’ve never used it myself), you can use `CMAKE_CXX_COMPILER_LAUNCHER` to be a script that wraps up the “real” compiler to do your logging (synchronization in a parallel build may be an issue). Alternatively, you can use a CTest script to do `ctest_build`. CTest can parse out warning and error lines and puts them…somwhere under `Testing/`. You can also upload that to CDash for a web viewer into the warning/error state of the build.
