Fix non-portable link to uiautomationcore

548351 changed QWindowsIntegrationPlugin and
QWindowsDirect2DIntegrationPlugin so that their CMake targets link
directly to UIAutomationCore.lib/.a instead of loading
UIAutomationCore.dll dynamically at runtime; however, it did this by
first locating the library via `find_library()` and then using the
absolute path to the DLL import library found. If Qt was built
statically, this would cause that absolute path to be added to the
INTERFACE_LINK_LIBRARIES of their export targets, breaking the build
if moved to another machine where the location of that lib differed.

Instead, simply list uiautomationcore as a library link by name only,
which shifts responsibility of locating the .lib/.a when consumers
build to the linker, as is done for all other Windows system libraries.
This ensures that the library is found correctly regardless of which
system Qt was built on.

Currently this only applies to MSVC due to limitations with
uiautomationcore.a when using MINGW, where the lib is still dynamically
loaded.

Pick-to: 6.8.1
Change-Id: I20011a51935af4093de83fff75efe2141da0655b
Reviewed-by: Zhao Yuhang <2546789017@qq.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit da367d0bffcd58a3217af937d767cf4f392d3c15)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Christian Heimlich 2024-11-24 01:39:20 -05:00 committed by Qt Cherry-pick Bot
parent b325a93e34
commit 0467b8278e
2 changed files with 10 additions and 18 deletions

View File

@ -209,15 +209,11 @@ qt_internal_extend_target(QWindowsDirect2DIntegrationPlugin CONDITION QT_FEATURE
../windows/uiautomation/qwindowsuiawindowprovider.cpp ../windows/uiautomation/qwindowsuiawindowprovider.h
)
if(QT_FEATURE_accessibility)
find_library(UI_AUTOMATION_LIBRARY uiautomationcore)
if(UI_AUTOMATION_LIBRARY)
qt_internal_extend_target(QWindowsDirect2DIntegrationPlugin
LIBRARIES
${UI_AUTOMATION_LIBRARY}
)
endif()
endif()
# This is loaded dynamically when using MINGW as its import library is incomplete
qt_internal_extend_target(QWindowsDirect2DIntegrationPlugin CONDITION MSVC AND QT_FEATURE_accessibility
LIBRARIES
uiautomationcore
)
qt_internal_extend_target(QWindowsDirect2DIntegrationPlugin CONDITION MINGW AND QT_FEATURE_accessibility
LIBRARIES

View File

@ -198,15 +198,11 @@ qt_internal_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_accessi
uiautomation/qwindowsuiawindowprovider.cpp uiautomation/qwindowsuiawindowprovider.h
)
if(QT_FEATURE_accessibility)
find_library(UI_AUTOMATION_LIBRARY uiautomationcore)
if(UI_AUTOMATION_LIBRARY)
qt_internal_extend_target(QWindowsIntegrationPlugin
LIBRARIES
${UI_AUTOMATION_LIBRARY}
)
endif()
endif()
# This is loaded dynamically when using MINGW as its import library is incomplete
qt_internal_extend_target(QWindowsIntegrationPlugin CONDITION MSVC AND QT_FEATURE_accessibility
LIBRARIES
uiautomationcore
)
qt_internal_extend_target(QWindowsIntegrationPlugin CONDITION MINGW AND QT_FEATURE_accessibility
LIBRARIES