8

Here is a sample output of my cmake:

2017/10/27 07:51:46 Platform overridden to 'RHEL5_64'
-- cmake version: 3.2.3
-- Configuring done
-- Generating done
-- Build files have been written to: /local/home/etc
[3/3] Linking CXX shared library libsample_z.so

The last line actually shows progress (as indicated by [3/3]) and thus overwritten in-place; so I cannot see all the logs (i.e the messages correspond to [1/3] and [2/3]). I want cmake to print all logs to stay on its own line, like:

Linking CXX shared library libsample_x.so
Linking CXX shared library libsample_y.so
Linking CXX shared library libsample_z.so

What can be done in cmake to log like this?

Nawaz
  • 353,942
  • 115
  • 666
  • 851

3 Answers3

4

The "problem" with ninja is, that it automatically detects if you are running from a shell where it can replace the progress output in line. And there are - as of October 2017 - no command line switches or environment variables to change this behavior.

Since it checks for the console's output buffer, I found that piping the output on my Windows console somewhere else does show multi-line outputs again. So i used the following pipe command:

cmake -G "Ninja" ..
cmake --build . > CON

NOTE: That will only work if you don't have this call inside a script that needs the stdout output itself again for piping it e.g. into a log file. Meaning the output is no longer on stdout after this pipe command.

Florian
  • 39,996
  • 9
  • 133
  • 149
  • 1
    If you DO want to see output on stdout (seems obvious), use `cmake --build . | tee /dev/null` where dev/null can be name of file that will contain output as well. This usually disables color output (from compiler warnings etc.) – MateuszL Jan 29 '21 at 11:29
2

Similar to the accept answer, another option is to tick ninja into not seeing the terminal by piping to cat.

ninja | cat -

This will get you multi line output, but you will loose any console coloring as well.

0

From man ninja:

-v     show all command lines while building
Zitrax
  • 19,036
  • 20
  • 88
  • 110