diff options
| author | Joerg Bornemann <joerg.bornemann@qt.io> | 2026-03-06 12:41:57 +0100 |
|---|---|---|
| committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2026-03-10 15:15:04 +0000 |
| commit | 09d858a0deb0afeb01d195836a58a8d4f0ac4e18 (patch) | |
| tree | 5e803a863dc9a45fe8891a0d554f8d9c8b7274eb | |
| parent | 8bd36b1d0d68002ec60130c73c75585eb6028e16 (diff) | |
CMake's message() writes to stderr, making it
unnecessarily cumbersome to pipe -help
output. Write output via a temp file and cmake -E cat to send it to
stdout instead.
Change-Id: I71710aeb503076586609a69cada94c8a5e30e3be
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
| -rw-r--r-- | cmake/QtIRCommandLineHelpers.cmake | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/cmake/QtIRCommandLineHelpers.cmake b/cmake/QtIRCommandLineHelpers.cmake index 51aa21a48..a1dd25990 100644 --- a/cmake/QtIRCommandLineHelpers.cmake +++ b/cmake/QtIRCommandLineHelpers.cmake @@ -5,6 +5,37 @@ # with renamed functions, because we need similar logic for init-repository, but # we can't access qtbase before we clone it. +function(qt_ir_print_to_stdout text) + set(tmp_candidates + "${CMAKE_CURRENT_BINARY_DIR}" + "$ENV{TMPDIR}" + "$ENV{TEMP}" + "/tmp" + ) + set(tmp "") + foreach(dir IN LISTS tmp_candidates) + if(dir STREQUAL "") + continue() + endif() + set(candidate "${dir}/.qt_configure_stdout_tmp") + execute_process( + COMMAND "${CMAKE_COMMAND}" -E touch "${candidate}" + RESULT_VARIABLE touch_result + ) + if(touch_result EQUAL 0) + set(tmp "${candidate}") + break() + endif() + endforeach() + if(tmp STREQUAL "") + message("${text}") # last resort fallback (stderr) + return() + endif() + file(WRITE "${tmp}" "${text}") + execute_process(COMMAND "${CMAKE_COMMAND}" -E cat "${tmp}") + file(REMOVE "${tmp}") +endfunction() + # Call a function with the given arguments. function(qt_ir_call_function func) set(call_code "${func}(") @@ -368,16 +399,17 @@ endfunction() # Shows help for the command line options. function(qt_ir_show_help) + set(help "") set(help_file "${CMAKE_CURRENT_LIST_DIR}/QtIRHelp.txt") if(EXISTS "${help_file}") file(READ "${help_file}" content) - message("${content}") + string(APPEND help "${content}") endif() - - message([[ + string(APPEND help [[ General Options: -help, -h ............ Display this help screen ]]) + qt_ir_print_to_stdout("${help}") endfunction() # Gets the unhandled command line args. |
