0

In my CMake file, I set up a Python test environment:

execute_process(
  COMMAND pip install -U -r ${REQUIREMENTS}
  RESULT_VARIABLE STATUS
)

The issue is, I usually don't need its verbose OUTPUT. So I want to optionally hide it. This is what I've done:

if(SHOW_PIP_LOGS)
  execute_process(...)
else()
  execute_process(... OUTPUT_QUIET)
endif()

The thing is, there is already a way to control what logs are shown in CMake: it's --log-level coupled with message(). This way I don't need to manage any logging-related variables. But the command outputs directly to stdout, without going through CMake log system.

Can I somehow forward the output of a command invocation to CMake's logs?

The output must be printed on-line, without buffering everything to a variable first, so that if a pip takes a long time installing packages, I can see what's going on.

Anton3
  • 577
  • 4
  • 14
  • It seems that if this feature is implemented, I'll be able to conditionally enable `OUTPUT_QUIET` based on the log level: https://gitlab.kitware.com/cmake/cmake/-/issues/22627 – Anton3 Apr 13 '22 at 10:28
  • How about usiing `OUTPUT_VARIABLE` of `execute_process` with standard `message`? – ixSci Apr 13 '22 at 10:51
  • @ixSci That works, but now the output is buffered and not printed interactively – Anton3 Apr 13 '22 at 11:12

0 Answers0