]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/tools/vcpkg/scripts/cmake/vcpkg_execute_in_download_mode.cmake
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / tools / vcpkg / scripts / cmake / vcpkg_execute_in_download_mode.cmake
1 #[===[.md:
2 # vcpkg_execute_in_download_mode
3
4 Execute a process even in download mode.
5
6 ## Usage
7 ```cmake
8 vcpkg_execute_in_download_mode(
9 COMMAND <cmd> [<arguments>]
10 [WORKING_DIRECTORY <dir>]
11 [TIMEOUT <seconds>]
12 [RESULT_VARIABLE <variable>]
13 [OUTPUT_VARIABLE <variable>]
14 [ERROR_VARIABLE <variable>]
15 [INPUT_FILE <file>]
16 [OUTPUT_FILE <file>]
17 [ERROR_FILE <file>]
18 [OUTPUT_QUIET]
19 [ERROR_QUIET]
20 [OUTPUT_STRIP_TRAILING_WHITESPACE]
21 [ERROR_STRIP_TRAILING_WHITESPACE]
22 [ENCODING <name>]
23 )
24 ```
25
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
28 commands with pipes.
29
30 See [`execute_process()`] for a detailed description of the parameters.
31
32 [`execute_process()`]: https://cmake.org/cmake/help/latest/command/execute_process.html
33 #]===]
34
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"
40 "COMMAND")
41
42 # collect all other present parameters
43 set(other_args "")
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})
47 endif()
48 endforeach()
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}})
52 endif()
53 endforeach()
54
55 if (DEFINED VCPKG_DOWNLOAD_MODE)
56 _execute_process(COMMAND ${vcpkg_execute_in_download_mode_COMMAND} ${other_args})
57 else()
58 execute_process(COMMAND ${vcpkg_execute_in_download_mode_COMMAND} ${other_args})
59 endif()
60
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)
65 endif()
66 endforeach()
67 endfunction()