CMake: Improve compile test error reporting in configure summary
Starting with 605913f9d7a60461939c1a8fb8dac05054cade2d we run configure.cmake compile tests lazily during feature evaluation. This means that qt_config_compile_test() calls will no longer set TEST_foo_OUTPUT variables in the scope of configure.cmake files and thus the build output of compile tests is no longer available for configure summary error reports. Instead of setting the output variable in the caller scope, save the output in a global property. Then, when we add error reports that mention compile tests either in CONDITION or in a newly introduced COMPILE_TESTS_TO_SHOW_ON_ERROR option, dump those outputs in the error report. We continue to set the output in the parent scope, in case if qt_run_config_compile_test is called manually. Amends 3334a77ecfb792fba0144e99887f11cd0fa2506d Amends 605913f9d7a60461939c1a8fb8dac05054cade2d Pick-to: 6.8 6.9 6.10 Fixes: QTBUG-137198 Change-Id: Idc0470556a053123286983c44063e17b7eb9949d Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
7542aaea60
commit
a20a40095a
@ -555,11 +555,54 @@ function(qt_configure_add_report_error error)
|
||||
qt_configure_add_report_entry(TYPE ERROR MESSAGE "${error}" CONDITION TRUE ${ARGN})
|
||||
endfunction()
|
||||
|
||||
# Goes through each token in given in `CONDITION` or `COMPILE_TESTS_TO_SHOW_ON_ERROR`, checks if
|
||||
# the token starts with TEST_ which means it represents a Qt compile test, queries its
|
||||
# compile output if available, and appends it to `out_var`.
|
||||
# The compile output for a test is only available on first configuration, because we don't cache it
|
||||
# across cmake invocations.
|
||||
function(qt_internal_get_try_compile_output_from_tests_in_condition out_var)
|
||||
set(opt_args "")
|
||||
set(single_args "")
|
||||
set(multi_args
|
||||
CONDITION
|
||||
COMPILE_TESTS_TO_SHOW_ON_ERROR
|
||||
)
|
||||
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
|
||||
_qt_internal_validate_all_args_are_parsed(arg)
|
||||
|
||||
set(content "")
|
||||
|
||||
foreach(token IN LISTS arg_CONDITION arg_COMPILE_TESTS_TO_SHOW_ON_ERROR)
|
||||
if(token MATCHES "TEST_(.+)")
|
||||
set(name "${CMAKE_MATCH_1}")
|
||||
get_cmake_property(try_compile_output _qt_run_config_compile_test_output_${name})
|
||||
|
||||
if(try_compile_output)
|
||||
string(APPEND content "\n TEST_${name} output: \n\n${try_compile_output}")
|
||||
endif()
|
||||
else()
|
||||
continue()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(content)
|
||||
string(PREPEND content "\n Compile test outputs:\n")
|
||||
endif()
|
||||
|
||||
set(${out_var} "${content}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(qt_configure_process_add_report_entry)
|
||||
cmake_parse_arguments(PARSE_ARGV 0 arg
|
||||
""
|
||||
"TYPE;MESSAGE"
|
||||
"CONDITION")
|
||||
set(opt_args "")
|
||||
set(single_args
|
||||
TYPE
|
||||
MESSAGE
|
||||
)
|
||||
set(multi_args
|
||||
CONDITION
|
||||
COMPILE_TESTS_TO_SHOW_ON_ERROR
|
||||
)
|
||||
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
|
||||
_qt_internal_validate_all_args_are_parsed(arg)
|
||||
|
||||
set(possible_types NOTE WARNING ERROR FATAL_ERROR)
|
||||
@ -591,6 +634,23 @@ function(qt_configure_process_add_report_entry)
|
||||
|
||||
if("${arg_CONDITION}" STREQUAL "" OR condition_result)
|
||||
set(new_report "${prefix}${arg_MESSAGE}")
|
||||
|
||||
set(compile_test_args "")
|
||||
if(arg_CONDITION)
|
||||
list(APPEND compile_test_args CONDITION ${arg_CONDITION})
|
||||
endif()
|
||||
if(arg_COMPILE_TESTS_TO_SHOW_ON_ERROR)
|
||||
list(APPEND compile_test_args
|
||||
COMPILE_TESTS_TO_SHOW_ON_ERROR ${arg_COMPILE_TESTS_TO_SHOW_ON_ERROR})
|
||||
endif()
|
||||
|
||||
qt_internal_get_try_compile_output_from_tests_in_condition(extra_output
|
||||
${compile_test_args}
|
||||
)
|
||||
if(extra_output)
|
||||
string(APPEND new_report "\n${extra_output}")
|
||||
endif()
|
||||
|
||||
string(APPEND "${contents_var}" "\n${new_report}")
|
||||
|
||||
if(arg_TYPE STREQUAL "ERROR" OR arg_TYPE STREQUAL "FATAL_ERROR")
|
||||
|
@ -1616,7 +1616,14 @@ function(qt_run_config_compile_test name)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Note this is assigned to the parent scope, and is not a CACHE var, which means the value is
|
||||
# only available on first configuration.
|
||||
set(TEST_${name}_OUTPUT "${try_compile_output}" PARENT_SCOPE)
|
||||
|
||||
# Story the compile output for a test in a global property. It will only be available on first
|
||||
# configuration, because we don't cache it across cmake invocations.
|
||||
set_property(GLOBAL PROPERTY _qt_run_config_compile_test_output_${name} "${try_compile_output}")
|
||||
|
||||
set(TEST_${name} "${HAVE_${name}}" CACHE INTERNAL "${arg_LABEL}")
|
||||
endfunction()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user