CMake: Improve error reporting for failed linker no undefined flag
Capture the output of the check_cxx_source_compiles calls in qt_internal_add_link_flags_no_undefined like we do for qt_config_compile_test. Amends 3334a77ecfb792fba0144e99887f11cd0fa2506d Pick-to: 6.9 6.8 Task-number: QTBUG-137198 Change-Id: Ic7dd4eae0ac1af0f8293f2ce285d2987e4e26249 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 7542aaea604907ff69ed03f650421403388b5463) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
c39a3edb50
commit
f35f45642c
@ -1601,17 +1601,9 @@ function(qt_run_config_compile_test name)
|
|||||||
set(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
|
set(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
|
||||||
set(CMAKE_REQUIRED_LIBRARIES "${arg_LIBRARIES}")
|
set(CMAKE_REQUIRED_LIBRARIES "${arg_LIBRARIES}")
|
||||||
|
|
||||||
# OUTPUT_VARIABLE is an internal undocumented variable of check_cxx_source_compiles
|
_qt_internal_get_check_cxx_source_compiles_out_var(try_compile_output extra_args)
|
||||||
# since 3.23. Allow an opt out in case this breaks in the future.
|
|
||||||
set(try_compile_output "")
|
|
||||||
set(output_var "")
|
|
||||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.23"
|
|
||||||
AND NOT QT_INTERNAL_NO_TRY_COMPILE_OUTPUT_VARIABLE)
|
|
||||||
set(output_var OUTPUT_VARIABLE try_compile_output)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
check_cxx_source_compiles(
|
check_cxx_source_compiles(
|
||||||
"${arg_UNPARSED_ARGUMENTS} ${arg_CODE}" HAVE_${name} ${output_var}
|
"${arg_UNPARSED_ARGUMENTS} ${arg_CODE}" HAVE_${name} ${extra_args}
|
||||||
)
|
)
|
||||||
set(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}")
|
set(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}")
|
||||||
|
|
||||||
|
@ -166,13 +166,15 @@ function(qt_internal_add_link_flags_no_undefined target)
|
|||||||
set(previous_CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
|
set(previous_CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_LINK_OPTIONS "-Wl,-undefined,error")
|
set(CMAKE_REQUIRED_LINK_OPTIONS "-Wl,-undefined,error")
|
||||||
check_cxx_source_compiles("int main() {}" HAVE_DASH_UNDEFINED_SYMBOLS)
|
_qt_internal_get_check_cxx_source_compiles_out_var(test_output_undefined_error extra_args)
|
||||||
|
check_cxx_source_compiles("int main() {}" HAVE_DASH_UNDEFINED_SYMBOLS ${extra_args})
|
||||||
if(HAVE_DASH_UNDEFINED_SYMBOLS)
|
if(HAVE_DASH_UNDEFINED_SYMBOLS)
|
||||||
set(no_undefined_flag "-Wl,-undefined,error")
|
set(no_undefined_flag "-Wl,-undefined,error")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_LINK_OPTIONS "-Wl,--no-undefined")
|
set(CMAKE_REQUIRED_LINK_OPTIONS "-Wl,--no-undefined")
|
||||||
check_cxx_source_compiles("int main() {}" HAVE_DASH_DASH_NO_UNDEFINED)
|
_qt_internal_get_check_cxx_source_compiles_out_var(test_output_no_undefined extra_args)
|
||||||
|
check_cxx_source_compiles("int main() {}" HAVE_DASH_DASH_NO_UNDEFINED ${extra_args})
|
||||||
if(HAVE_DASH_DASH_NO_UNDEFINED)
|
if(HAVE_DASH_DASH_NO_UNDEFINED)
|
||||||
set(no_undefined_flag "-Wl,--no-undefined")
|
set(no_undefined_flag "-Wl,--no-undefined")
|
||||||
endif()
|
endif()
|
||||||
@ -180,7 +182,10 @@ function(qt_internal_add_link_flags_no_undefined target)
|
|||||||
set(CMAKE_REQUIRED_LINK_OPTIONS ${previous_CMAKE_REQUIRED_LINK_OPTIONS})
|
set(CMAKE_REQUIRED_LINK_OPTIONS ${previous_CMAKE_REQUIRED_LINK_OPTIONS})
|
||||||
|
|
||||||
if (NOT HAVE_DASH_UNDEFINED_SYMBOLS AND NOT HAVE_DASH_DASH_NO_UNDEFINED)
|
if (NOT HAVE_DASH_UNDEFINED_SYMBOLS AND NOT HAVE_DASH_DASH_NO_UNDEFINED)
|
||||||
message(FATAL_ERROR "Platform linker doesn't support erroring upon encountering undefined symbols. Target:\"${target}\".")
|
message(FATAL_ERROR
|
||||||
|
"Platform linker doesn't support erroring upon encountering undefined symbols. "
|
||||||
|
"Target:\"${target}\". "
|
||||||
|
"Test errors: \n ${test_output_undefined_error} \n ${test_output_no_undefined}")
|
||||||
endif()
|
endif()
|
||||||
target_link_options("${target}" PRIVATE "${no_undefined_flag}")
|
target_link_options("${target}" PRIVATE "${no_undefined_flag}")
|
||||||
endif()
|
endif()
|
||||||
|
@ -174,6 +174,21 @@ function(__qt_internal_prefix_paths_to_roots out_var prefix_paths)
|
|||||||
set("${out_var}" "${result}" PARENT_SCOPE)
|
set("${out_var}" "${result}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
function(_qt_internal_get_check_cxx_source_compiles_out_var out_output_var out_func_args)
|
||||||
|
# This just resets the output var in the parent scope to an empty string.
|
||||||
|
set(${out_output_var} "" PARENT_SCOPE)
|
||||||
|
|
||||||
|
# OUTPUT_VARIABLE is an internal undocumented variable of check_cxx_source_compiles
|
||||||
|
# since 3.23. Allow an opt out in case this breaks in the future.
|
||||||
|
set(extra_func_args "")
|
||||||
|
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.23"
|
||||||
|
AND NOT QT_INTERNAL_NO_TRY_COMPILE_OUTPUT_VARIABLE)
|
||||||
|
set(extra_func_args OUTPUT_VARIABLE ${out_output_var})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(${out_func_args} "${extra_func_args}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
# This function gets all targets below this directory
|
# This function gets all targets below this directory
|
||||||
#
|
#
|
||||||
# Multi-value Arguments:
|
# Multi-value Arguments:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user