message: Support for Printing Multiple Messages to a Single Line
Summary/Story
I want to be able to print multiple output statements using individual commands on a single line during CMake configuration.
Version
Windows 10 - CMAKE 3.23.2 - GUI Console/Command Line
Example
CMake Code:
message(STATUS "Hello, ")
# ... Do other arbitrary configuration
message(STATUS "World!")
Result:
Hello,
World!
Desired Result:
Hello, World!
Alternative 1
execute_process(COMMAND ${CMAKE_COMMAND} -E echo -n "Hello, ") # `-n` echo option is not currently supported
# ... Do other arbitrary configuration
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "World!")
Desired Result:
Hello, World!
Alternative 2
This is more specific, but it could be nice:
message(CHECK_START "Hello, ")
# ... Do conditional configuration
message(CHECK_PASS " World!")
Result:
Hello,
Hello, - World!
Desired Result:
Hello, - World!
- (or simply
Hello, World!
)
Insights
There may be a way to achieve this already on Linux/Unix-like shell, i.e.:
execute_process(COMMAND bash "-c" "echo -n Hello, World!")
but I am looking for a native, convenient option.
My example here is of course trivial, but in reality I'm dealing with many thousands of lines of configuration output, many of them are similar in sequence and it is much easier to see patterns in output when similar output messages (looping) are on a single line. By adding support for this, I can essentially create a table of output which will greatly help me to optimize/improve/debug the CMake configuration for a very large software suite I am supporting.
Reference
Here are a few sources that I referenced while attempting to get something working.
- https://stackoverflow.com/questions/51040536/how-to-print-without-newline-in-cmake/75770357#75770357
- https://stackoverflow.com/questions/24967260/c-remove-a-newline-character-that-has-already-been-printed
- https://unix.stackexchange.com/questions/167798/how-to-append-line-to-previous-line
- https://www.howtogeek.com/446071/how-to-use-the-echo-command-on-linux/
- https://stackoverflow.com/questions/35689501/cmakes-execute-process-and-arbitrary-shell-scripts#35695350