summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWouter Klouwen <wouter.klouwen@youview.com>2018-10-12 18:33:36 +0100
committerWouter Klouwen <wouter.klouwen@youview.com>2018-10-19 15:32:51 +0100
commit7ddc9e353b097a9f6b0910d7d4875bd9c68c64d8 (patch)
tree0598d805dea707dd90166abb58dac20605b58ee0
parentb6f6cac378f4107d64b32981ba311b311157ce04 (diff)
downloadcmake-7ddc9e353b097a9f6b0910d7d4875bd9c68c64d8.tar.gz
ExternalProject: option LOG_MERGED_STDOUTERR to combine stdout and stderr
In some circumstances the user of ExternalProject may not desire the split log files for stdout and stderr. In particular with a project has many errors it can be difficult to correlate the output error with the command that it resulted from. This commit adds the LOG_MERGED_STDOUTERR option that when enabled outputs into a unified <name>-<step>.log for each step. If disabled it will default to the previous behaviour of <name>-<step>-out.log and <name>-<step>-err.log.
-rw-r--r--Auxiliary/vim/syntax/cmake.vim1
-rw-r--r--Help/release/dev/ExternalProject-log-options.rst5
-rw-r--r--Modules/ExternalProject.cmake17
-rw-r--r--Tests/ExternalProject/CMakeLists.txt1
4 files changed, 21 insertions, 3 deletions
diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim
index 64011b6e52..25384e45be 100644
--- a/Auxiliary/vim/syntax/cmake.vim
+++ b/Auxiliary/vim/syntax/cmake.vim
@@ -876,6 +876,7 @@ syn keyword cmakeKWExternalProject contained
\ LOG_DIR
\ LOG_DOWNLOAD
\ LOG_INSTALL
+ \ LOG_MERGED_STDOUTERR
\ LOG_TEST
\ LOG_UPDATE
\ MAKE_EXE
diff --git a/Help/release/dev/ExternalProject-log-options.rst b/Help/release/dev/ExternalProject-log-options.rst
new file mode 100644
index 0000000000..2fc4c4fe78
--- /dev/null
+++ b/Help/release/dev/ExternalProject-log-options.rst
@@ -0,0 +1,5 @@
+ExternalProject-log-options
+---------------------------
+
+* The :module:`ExternalProject` module :command:`ExternalProject_Add` command
+ gained ``LOG_DIR`` and ``LOG_MERGED_STDOUTERR`` options to control logging.
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 41ee7a427b..a8c31ed8d3 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -544,6 +544,9 @@ External Project Definition
``LOG_TEST <bool>``
When enabled, the output of the test step is logged to files.
+ ``LOG_MERGED_STDOUTERR <bool>``
+ When enabled, the output the step is not split by stdout and stderr.
+
**Terminal Access Options:**
Steps can be given direct access to the terminal in some cases. Giving a
step access to the terminal may allow it to receive terminal input if
@@ -1946,21 +1949,29 @@ endif()
# Wrap the command in a script to log output to files.
set(script ${stamp_dir}/${name}-${step}-$<CONFIG>.cmake)
set(logbase ${log_dir}/${name}-${step})
+ get_property(log_merged TARGET ${name} PROPERTY _EP_LOG_MERGED_STDOUTERR)
+ if (log_merged)
+ set(stdout_log "${logbase}.log")
+ set(stderr_log "${logbase}.log")
+ else()
+ set(stdout_log "${logbase}-out.log")
+ set(stderr_log "${logbase}-err.log")
+ endif()
set(code "
${code_cygpath_make}
set(command \"${command}\")
execute_process(
COMMAND \${command}
RESULT_VARIABLE result
- OUTPUT_FILE \"${logbase}-out.log\"
- ERROR_FILE \"${logbase}-err.log\"
+ OUTPUT_FILE \"${stdout_log}\"
+ ERROR_FILE \"${stderr_log}\"
)
if(result)
set(msg \"Command failed: \${result}\\n\")
foreach(arg IN LISTS command)
set(msg \"\${msg} '\${arg}'\")
endforeach()
- set(msg \"\${msg}\\nSee also\\n ${logbase}-*.log\")
+ set(msg \"\${msg}\\nSee also\\n ${stderr_log}\")
message(FATAL_ERROR \"\${msg}\")
else()
set(msg \"${name} ${step} command succeeded. See also ${logbase}-*.log\")
diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt
index fd60306692..5adcbd9e22 100644
--- a/Tests/ExternalProject/CMakeLists.txt
+++ b/Tests/ExternalProject/CMakeLists.txt
@@ -640,6 +640,7 @@ ExternalProject_Add(${proj}
CONFIGURE_COMMAND "${configure_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "configure"
BUILD_COMMAND "${build_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "build"
INSTALL_COMMAND "${install_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "install"
+ LOG_MERGED_STDOUTERR 1
LOG_DIR ${CMAKE_CURRENT_BINARY_DIR}/different_log
LOG_DOWNLOAD 1
LOG_PATCH 1