2 # vcpkg_execute_in_download_mode
4 Execute a process even in download mode.
8 vcpkg_execute_in_download_mode(
9 COMMAND <cmd> [<arguments>]
10 [WORKING_DIRECTORY <dir>]
12 [RESULT_VARIABLE <variable>]
13 [OUTPUT_VARIABLE <variable>]
14 [ERROR_VARIABLE <variable>]
20 [OUTPUT_STRIP_TRAILING_WHITESPACE]
21 [ERROR_STRIP_TRAILING_WHITESPACE]
26 The signature of this function is identical to `execute_process()` except that
27 it only accepts one COMMAND argument, i.e., does not support chaining multiple
30 See [`execute_process()`] for a detailed description of the parameters.
32 [`execute_process()`]: https://cmake.org/cmake/help/latest/command/execute_process.html
35 function(vcpkg_execute_in_download_mode)
36 # parse parameters such that semicolons in options arguments to COMMAND don't get erased
37 cmake_parse_arguments(PARSE_ARGV 0 vcpkg_execute_in_download_mode
38 "OUTPUT_QUIET;ERROR_QUIET;OUTPUT_STRIP_TRAILING_WHITESPACE;ERROR_STRIP_TRAILING_WHITESPACE"
39 "WORKING_DIRECTORY;TIMEOUT;RESULT_VARIABLE;RESULTS_VARIABLE;OUTPUT_VARIABLE;ERROR_VARIABLE;INPUT_FILE;OUTPUT_FILE;ERROR_FILE;ENCODING"
42 # collect all other present parameters
44 foreach(arg OUTPUT_QUIET ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE)
45 if(vcpkg_execute_in_download_mode_${arg})
46 list(APPEND other_args ${arg})
49 foreach(arg WORKING_DIRECTORY TIMEOUT RESULT_VARIABLE RESULTS_VARIABLE OUTPUT_VARIABLE ERROR_VARIABLE INPUT_FILE OUTPUT_FILE ERROR_FILE ENCODING)
50 if(vcpkg_execute_in_download_mode_${arg})
51 list(APPEND other_args ${arg} ${vcpkg_execute_in_download_mode_${arg}})
55 if (DEFINED VCPKG_DOWNLOAD_MODE)
56 _execute_process(COMMAND ${vcpkg_execute_in_download_mode_COMMAND} ${other_args})
58 execute_process(COMMAND ${vcpkg_execute_in_download_mode_COMMAND} ${other_args})
61 # pass output parameters back to caller's scope
62 foreach(arg RESULT_VARIABLE RESULTS_VARIABLE OUTPUT_VARIABLE ERROR_VARIABLE)
63 if(vcpkg_execute_in_download_mode_${arg})
64 set(${vcpkg_execute_in_download_mode_${arg}} ${${vcpkg_execute_in_download_mode_${arg}}} PARENT_SCOPE)