CMake: Fix empty value of CMAKE_SIZEOF_VOID_P when looking for tools
Our initial approach to looking for host Qt tools when cross-compiling to a platform with a different architecture bitness compared to the host one was to unset CMAKE_SIZEOF_VOID_P before calling find_package(Qt6FooTools) and then restoring the value. That works to bypass the architecture bitness test in the ConfigVersion files, but it also influences the paths that find_package() searches in, specifically the lib<arch> paths like /usr/lib64 will not be searched in. Fortunately since CMake 3.14, write_basic_package_version_file() can take an additional ARCH_INDEPENDENT parameter. This disables the architecture bitness test when looking for the package, while allowing to still search in the /usr/lib64 like paths. Use it when creating the QtFooToolConfigVersion.cmake files. One could argue we should actually check if the tool executables could run on the host system where find_package is called for cross-compilation. We could do that in another change if the problem ever arises. Amends03aa74e40d
Amends914b367c7f
Change-Id: I1181ff637ac80064a6a8538170b28a41743fc90c Fixes: QTBUG-81672 Reviewed-by: Christophe Giboudeaux <christophe@krop.fr> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
707d29d5d7
commit
9e044765ec
@ -3578,6 +3578,7 @@ endif()
|
||||
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersion.cmake"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
ARCH_INDEPENDENT
|
||||
)
|
||||
|
||||
qt_install(FILES
|
||||
@ -4916,8 +4917,6 @@ function(qt_add_tool target_name)
|
||||
# in the host system.
|
||||
set(BACKUP_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ${CMAKE_FIND_ROOT_PATH_MODE_PACKAGE})
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE "BOTH")
|
||||
set(BACKUP_CMAKE_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}")
|
||||
set(CMAKE_SIZEOF_VOID_P "")
|
||||
find_package(
|
||||
${tools_package_name}
|
||||
${PROJECT_VERSION}
|
||||
@ -4927,7 +4926,6 @@ function(qt_add_tool target_name)
|
||||
NO_CMAKE_PACKAGE_REGISTRY
|
||||
NO_CMAKE_SYSTEM_PATH
|
||||
NO_CMAKE_SYSTEM_PACKAGE_REGISTRY)
|
||||
set(CMAKE_SIZEOF_VOID_P "${BACKUP_CMAKE_SIZEOF_VOID_P}")
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE "${BACKUP_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE}")
|
||||
set(CMAKE_PREFIX_PATH "${BACKUP_CMAKE_PREFIX_PATH}")
|
||||
|
||||
|
@ -35,11 +35,6 @@ endforeach()
|
||||
# Find Qt tool package.
|
||||
set(_tool_deps "@main_module_tool_deps@")
|
||||
|
||||
# The tools do not provide linkage targets but executables, where a mismatch
|
||||
# between 32-bit target and 64-bit host does not matter.
|
||||
set(BACKUP_@target@_CMAKE_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}")
|
||||
set(CMAKE_SIZEOF_VOID_P "")
|
||||
|
||||
if(QT_HOST_PATH)
|
||||
# Make sure that the tools find the host tools first
|
||||
set(BACKUP_@target@_CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH})
|
||||
@ -56,7 +51,6 @@ foreach(_target_dep ${_tool_deps})
|
||||
|
||||
if (NOT ${pkg}_FOUND)
|
||||
set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
|
||||
set(CMAKE_SIZEOF_VOID_P "${BACKUP_@target@_CMAKE_SIZEOF_VOID_P}")
|
||||
if(QT_HOST_PATH)
|
||||
set(CMAKE_PREFIX_PATH ${BACKUP_@target@_CMAKE_PREFIX_PATH})
|
||||
set(CMAKE_FIND_ROOT_PATH ${BACKUP_@target@_CMAKE_FIND_ROOT_PATH})
|
||||
@ -68,7 +62,6 @@ if(QT_HOST_PATH)
|
||||
set(CMAKE_PREFIX_PATH ${BACKUP_@target@_CMAKE_PREFIX_PATH})
|
||||
set(CMAKE_FIND_ROOT_PATH ${BACKUP_@target@_CMAKE_FIND_ROOT_PATH})
|
||||
endif()
|
||||
set(CMAKE_SIZEOF_VOID_P "${BACKUP_@target@_CMAKE_SIZEOF_VOID_P}")
|
||||
|
||||
# note: target_deps example: "Qt6Core\;5.12.0;Qt6Gui\;5.12.0"
|
||||
set(_target_deps "@target_deps@")
|
||||
|
Loading…
Reference in New Issue
Block a user