diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2020-10-23 12:42:02 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2020-10-23 13:49:51 (GMT) |
commit | ae7c81c6226cea5ae2fb5af53fa0d5a7b4bd3990 (patch) | |
tree | 81d9c34348593c5c04e6f6842fb3bbeab1209f9f /Modules | |
parent | d11338dba11dda1d9887ab9a2c174a87a024faf6 (diff) | |
download | CMake-ae7c81c6226cea5ae2fb5af53fa0d5a7b4bd3990.zip CMake-ae7c81c6226cea5ae2fb5af53fa0d5a7b4bd3990.tar.gz CMake-ae7c81c6226cea5ae2fb5af53fa0d5a7b4bd3990.tar.bz2 |
ExternalData: add support for suppressing progress during the build
During CI builds (at least), download progress is just noise. Allow it
to be suppressed.
Default to `OFF` for Ninja due to the tool's behavior of not showing
output until a command is complete (which makes any progress reporting
of little use) and `ON` otherwise.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/ExternalData.cmake | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 6fe8685..294167c 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -78,7 +78,8 @@ Module Functions manage local instances of data files stored externally:: ExternalData_Add_Target( - <target> # Name of data management target + <target> # Name of data management target + [SHOW_PROGRESS <ON|OFF>] # Show progress during the download ) It creates custom commands in the target as necessary to make data @@ -89,6 +90,11 @@ Module Functions in one of the paths specified in the ``ExternalData_OBJECT_STORES`` variable. + The ``SHOW_PROGRESS`` argument may be passed to suppress progress information + during the download of objects. If not provided, it defaults to ``OFF`` for + :generator:`Ninja` and :generator:`Ninja Multi-Config` generators and ``ON`` + otherwise. + Typically only one target is needed to manage all external data within a project. Call this function once at the end of configuration after all data references have been processed. @@ -344,6 +350,30 @@ function(ExternalData_add_target target) endif() set(_ExternalData_CONFIG_CODE "") + cmake_parse_arguments(PARSE_ARGV 1 _ExternalData_add_target + "" + "SHOW_PROGRESS" + "") + if (_ExternalData_add_target_UNPARSED_ARGUMENTS) + message(AUTHOR_WARNING + "Ignoring unrecognized arguments passed to ExternalData_add_target: " + "`${_ExternalData_add_target_UNPARSED_ARGUMENTS}`") + endif () + + # Turn `SHOW_PROGRESS` into a boolean + if (NOT DEFINED _ExternalData_add_target_SHOW_PROGRESS) + # The default setting + if (CMAKE_GENERATOR MATCHES "Ninja") + set(_ExternalData_add_target_SHOW_PROGRESS OFF) + else () + set(_ExternalData_add_target_SHOW_PROGRESS ON) + endif () + elseif (_ExternalData_add_target_SHOW_PROGRESS) + set(_ExternalData_add_target_SHOW_PROGRESS ON) + else () + set(_ExternalData_add_target_SHOW_PROGRESS OFF) + endif () + # Store custom script configuration. foreach(url_template IN LISTS ExternalData_URL_TEMPLATES) if("${url_template}" MATCHES "^ExternalDataCustomScript://([^/]*)/(.*)$") @@ -423,6 +453,7 @@ function(ExternalData_add_target target) COMMAND ${CMAKE_COMMAND} -Drelative_top=${CMAKE_BINARY_DIR} -Dfile=${file} -Dname=${name} -DExternalData_ACTION=local + -DExternalData_SHOW_PROGRESS=${_ExternalData_add_target_SHOW_PROGRESS} -DExternalData_CONFIG=${config} -P ${_ExternalData_SELF} MAIN_DEPENDENCY "${name}" @@ -459,6 +490,7 @@ function(ExternalData_add_target target) COMMAND ${CMAKE_COMMAND} -Drelative_top=${CMAKE_BINARY_DIR} -Dfile=${file} -Dname=${name} -Dexts=${exts} -DExternalData_ACTION=fetch + -DExternalData_SHOW_PROGRESS=${_ExternalData_add_target_SHOW_PROGRESS} -DExternalData_CONFIG=${config} -P ${_ExternalData_SELF} # Update whenever the object hash changes. @@ -925,7 +957,11 @@ function(_ExternalData_download_file url file err_var msg_var) else() set(absolute_timeout "") endif() - file(DOWNLOAD "${url}" "${file}" STATUS status LOG log ${inactivity_timeout} ${absolute_timeout} SHOW_PROGRESS) + set(show_progress_args) + if (ExternalData_SHOW_PROGRESS) + list(APPEND show_progress_args SHOW_PROGRESS) + endif () + file(DOWNLOAD "${url}" "${file}" STATUS status LOG log ${inactivity_timeout} ${absolute_timeout} ${show_progress_args}) list(GET status 0 err) list(GET status 1 msg) if(err) |