CMake: Fix qt_run_linker_version_script_support to use active linker

The version script compile test did not use the linker that the build
system determined to use to link Qt, but rather the system linker.

Run qt_run_linker_version_script_support only after the global qtbase
features have been evaluated and make sure to include the active
linker flags.

Pick-to: 6.2 6.3
Change-Id: I0ff82406828daaf0dc5ec25a55f53ac7d98e3347
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Alexandru Croitor 2021-12-16 13:25:43 +01:00
parent d6066d53fa
commit 9198a9b8cc
2 changed files with 12 additions and 1 deletions

View File

@ -118,6 +118,13 @@ VERS_1;
set(CMAKE_REQUIRED_FLAGS "")
endif()
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=\"${CMAKE_CURRENT_BINARY_DIR}/version_flag.map\"")
# Pass the linker that the main project uses to the version script compile test.
qt_internal_get_active_linker_flags(linker_flags)
if(linker_flags)
set(CMAKE_REQUIRED_LINK_OPTIONS ${linker_flags})
endif()
check_cxx_source_compiles("int main(void){return 0;}" HAVE_LD_VERSION_SCRIPT)
if(DEFINED CMAKE_REQUIRED_FLAGS_SAVE)
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
@ -164,7 +171,6 @@ endfunction()
function(qt_run_qtbase_config_tests)
qt_run_config_test_architecture()
qt_run_linker_version_script_support()
qt_internal_ensure_latest_win_nt_api()
endfunction()

View File

@ -107,6 +107,11 @@ endif()
qt_feature_module_end(GlobalConfig OUT_VAR_PREFIX "__GlobalConfig_")
# The version script support check has to happen after we determined which linker is going
# to be used. The linker decision happens in the qtbase/configure.cmake file that is processed
# above.
qt_run_linker_version_script_support()
qt_generate_global_config_pri_file()
qt_generate_global_module_pri_file()
qt_generate_global_device_pri_file()