MimIR
0.5-dev
MimIR is my Intermediate Representation
Toggle main menu visibility
Loading...
Searching...
No Matches
run-logged.cmake
Go to the documentation of this file.
1
# Usage: cmake -P run-logged.cmake -- <log> <command> [args...]
2
#
3
# Runs <command> with stdout and stderr streamed into <log> instead of the build
4
# log. A non-zero exit dumps <log> so the failure is not swallowed.
5
6
if(CMAKE_ARGC LESS 7)
7
message(FATAL_ERROR
"usage: cmake -P run-logged.cmake -- <log> <command> [args...]"
)
8
endif()
9
10
set(LOG
"${CMAKE_ARGV4}"
)
11
math(EXPR _last
"${CMAKE_ARGC} - 1"
)
12
set(CMD)
13
foreach(_i RANGE 5 ${_last})
14
# An unescaped ';' would split one argument into several list elements.
15
string(REPLACE
";"
"\\;"
_arg
"${CMAKE_ARGV${_i}}"
)
16
list(APPEND CMD
"${_arg}"
)
17
endforeach()
18
19
cmake_path(GET LOG PARENT_PATH _dir)
20
file(MAKE_DIRECTORY
"${_dir}"
)
21
22
execute_process(
23
COMMAND ${CMD}
24
OUTPUT_FILE
"${LOG}"
25
ERROR_FILE
"${LOG}"
26
RESULT_VARIABLE _res
27
)
28
29
if(NOT _res EQUAL 0)
30
file(READ
"${LOG}"
_log)
31
message(
"${_log}"
)
32
list(JOIN CMD
" "
_cmdline)
33
message(FATAL_ERROR
"failed (${_res}), see ${LOG}:\n ${_cmdline}"
)
34
endif()
cmake
run-logged.cmake
Generated by
1.18.0