1 | |
---|
2 | cmake_minimum_required(VERSION 3.15) |
---|
3 | |
---|
4 | set(command "/opt/local/bin/cmake;--build;.") |
---|
5 | set(log_merged "") |
---|
6 | set(log_output_on_failure "") |
---|
7 | set(stdout_log "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_science_root6/root6/work/build/googletest-prefix/src/googletest-stamp/googletest-build-out.log") |
---|
8 | set(stderr_log "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_science_root6/root6/work/build/googletest-prefix/src/googletest-stamp/googletest-build-err.log") |
---|
9 | execute_process( |
---|
10 | COMMAND ${command} |
---|
11 | RESULT_VARIABLE result |
---|
12 | OUTPUT_FILE "${stdout_log}" |
---|
13 | ERROR_FILE "${stderr_log}" |
---|
14 | ) |
---|
15 | macro(read_up_to_max_size log_file output_var) |
---|
16 | file(SIZE ${log_file} determined_size) |
---|
17 | set(max_size 10240) |
---|
18 | if (determined_size GREATER max_size) |
---|
19 | math(EXPR seek_position "${determined_size} - ${max_size}") |
---|
20 | file(READ ${log_file} ${output_var} OFFSET ${seek_position}) |
---|
21 | set(${output_var} "...skipping to end...\n${${output_var}}") |
---|
22 | else() |
---|
23 | file(READ ${log_file} ${output_var}) |
---|
24 | endif() |
---|
25 | endmacro() |
---|
26 | if(result) |
---|
27 | set(msg "Command failed: ${result}\n") |
---|
28 | foreach(arg IN LISTS command) |
---|
29 | set(msg "${msg} '${arg}'") |
---|
30 | endforeach() |
---|
31 | if (${log_merged}) |
---|
32 | set(msg "${msg}\nSee also\n ${stderr_log}") |
---|
33 | else() |
---|
34 | set(msg "${msg}\nSee also\n /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_science_root6/root6/work/build/googletest-prefix/src/googletest-stamp/googletest-build-*.log") |
---|
35 | endif() |
---|
36 | if (${log_output_on_failure}) |
---|
37 | message(SEND_ERROR "${msg}") |
---|
38 | if (${log_merged}) |
---|
39 | read_up_to_max_size("${stderr_log}" error_log_contents) |
---|
40 | message(STATUS "Log output is:\n${error_log_contents}") |
---|
41 | else() |
---|
42 | read_up_to_max_size("${stdout_log}" out_log_contents) |
---|
43 | read_up_to_max_size("${stderr_log}" err_log_contents) |
---|
44 | message(STATUS "stdout output is:\n${out_log_contents}") |
---|
45 | message(STATUS "stderr output is:\n${err_log_contents}") |
---|
46 | endif() |
---|
47 | message(FATAL_ERROR "Stopping after outputting logs.") |
---|
48 | else() |
---|
49 | message(FATAL_ERROR "${msg}") |
---|
50 | endif() |
---|
51 | else() |
---|
52 | if(NOT "Ninja" MATCHES "Ninja") |
---|
53 | set(msg "googletest build command succeeded. See also /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_science_root6/root6/work/build/googletest-prefix/src/googletest-stamp/googletest-build-*.log") |
---|
54 | message(STATUS "${msg}") |
---|
55 | endif() |
---|
56 | endif() |
---|