Avoid using the PROJECT_VERSION_MAJOR as the HostInfo variable prefix

Manage the HostInfo variable prefix the correct way. The prefix
takes the HostInfo PROJECT_VERSION_MAJOR as the version specifier,
which is not necessary is the same as the PROJECT_VERSION_MAJOR
of the project that uses respective API. Instead of relying on the
current PROJECT_VERSION, use the version info stored in HostInfo
package and adjust the prefix accordingly. This will allow version
mismatching between the project that uses API and HostInfo version.

Change-Id: Idbaec1c7bb203448ceb0f15c9173ad3985c7112d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2025-03-17 18:55:27 +01:00
parent fc95651996
commit 6b9c494543
9 changed files with 46 additions and 18 deletions

View File

@ -444,6 +444,7 @@ macro(qt_internal_setup_build_and_global_variables)
qt_internal_setup_build_examples()
qt_internal_set_qt_host_path()
qt_internal_setup_find_host_info_package()
qt_internal_setup_build_docs()
@ -465,7 +466,6 @@ macro(qt_internal_setup_build_and_global_variables)
qt_internal_check_msvc_versions()
qt_internal_check_host_path_set_for_cross_compiling()
qt_internal_setup_android_platform_specifics()
qt_internal_setup_find_host_info_package()
qt_internal_setup_tool_path_command()
qt_internal_setup_default_target_function_options()
qt_internal_set_default_rpath_settings()

View File

@ -263,3 +263,20 @@ macro(qt_internal_setup_paths_and_prefixes)
qt_internal_set_qt_apple_support_files_path()
endmacro()
# Returns the prefix for the variables defined by HostInfo package. The prefix
# is based on version information provided by HostInfo. Falls back to current
# project version if ${INSTALL_CMAKE_NAMESPACE}HostInfo_VERSION_MAJOR is not
# defined.
function(qt_internal_get_host_info_var_prefix out_var)
if(${INSTALL_CMAKE_NAMESPACE}HostInfo_VERSION_MAJOR)
set(${out_var} "QT${${INSTALL_CMAKE_NAMESPACE}HostInfo_VERSION_MAJOR}_HOST_INFO"
PARENT_SCOPE)
else()
# This is not a valid way to define the host info versioned prefix, but
# it's backward compatible with Qt versions older than 6.10.
#
# TODO: remove once Qt LTS versions older than 6.10 reach end of life.
set(${out_var} "QT${PROJECT_VERSION_MAJOR}_HOST_INFO" PARENT_SCOPE)
endif()
endfunction()

View File

@ -131,8 +131,9 @@ function(qt_internal_add_docs)
set(tool_dependencies_enabled TRUE)
if(NOT "${QT_HOST_PATH}" STREQUAL "")
set(tool_dependencies_enabled FALSE)
set(doc_tools_bin "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}")
set(doc_tools_libexec "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_LIBEXECDIR}")
qt_internal_get_host_info_var_prefix(host_info_var_prefix)
set(doc_tools_bin "${QT_HOST_PATH}/${${host_info_var_prefix}_BINDIR}")
set(doc_tools_libexec "${QT_HOST_PATH}/${${host_info_var_prefix}_LIBEXECDIR}")
elseif(NOT "${QT_OPTIONAL_TOOLS_PATH}" STREQUAL "")
set(tool_dependencies_enabled FALSE)
set(doc_tools_bin "${QT_OPTIONAL_TOOLS_PATH}/${INSTALL_BINDIR}")

View File

@ -114,7 +114,8 @@ macro(qt_internal_setup_platform_definitions_and_mkspec)
endif()
if(CMAKE_CROSSCOMPILING)
set(QT_QMAKE_HOST_MKSPEC "${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_QMAKE_MKSPEC}")
qt_internal_get_host_info_var_prefix(host_info_var_prefix)
set(QT_QMAKE_HOST_MKSPEC "${${host_info_var_prefix}_QMAKE_MKSPEC}")
else()
set(QT_QMAKE_HOST_MKSPEC "${QT_QMAKE_TARGET_MKSPEC}")
endif()

View File

@ -136,8 +136,10 @@ define_property(TARGET
# Returns test execution arguments for Android targets
function(qt_internal_android_test_runner_arguments target out_test_runner out_test_arguments)
set(${out_test_runner} "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}/androidtestrunner" PARENT_SCOPE)
set(deployment_tool "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}/androiddeployqt")
qt_internal_get_host_info_var_prefix(host_info_var_prefix)
set(host_bin_dir "${QT_HOST_PATH}/${${host_info_var_prefix}_BINDIR}")
set(${out_test_runner} "${host_bin_dir}/androidtestrunner" PARENT_SCOPE)
set(deployment_tool "${host_bin_dir}/androiddeployqt")
qt_internal_android_get_target_android_build_dir(${target} android_build_dir)
set(${out_test_arguments}

View File

@ -738,9 +738,10 @@ function(qt_generate_global_config_pri_file)
endif()
if(CMAKE_CROSSCOMPILING)
qt_internal_get_host_info_var_prefix(host_info_var_prefix)
string(APPEND content "host_build {
QT_ARCH = ${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_ARCH}
QT_BUILDABI = ${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BUILDABI}
QT_ARCH = ${${host_info_var_prefix}_ARCH}
QT_BUILDABI = ${${host_info_var_prefix}_BUILDABI}
QT_TARGET_ARCH = ${TEST_architecture_arch}
QT_TARGET_BUILDABI = ${TEST_buildAbi}
} else {
@ -965,8 +966,9 @@ function(qt_generate_global_module_pri_file)
set(arch "${TEST_architecture_arch}")
list(JOIN TEST_subarch_result " " subarchs)
if(CMAKE_CROSSCOMPILING)
set(host_arch "${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_ARCH}")
list(JOIN QT${PROJECT_VERSION_MAJOR}_HOST_INFO_SUBARCHS " " host_subarchs)
qt_internal_get_host_info_var_prefix(host_info_var_prefix)
set(host_arch "${${host_info_var_prefix}_ARCH}")
list(JOIN ${host_info_var_prefix}_SUBARCHS " " host_subarchs)
string(APPEND content "host_build {
QT_CPU_FEATURES.${host_arch} = ${host_subarchs}
} else {

View File

@ -125,6 +125,7 @@ Prefix=${prefix}
endif()
endif()
qt_internal_get_host_info_var_prefix(host_info_var_prefix)
string(APPEND content
"[Paths]
Prefix=${ext_prefix_relative_to_conf_file}
@ -142,9 +143,9 @@ Examples=${INSTALL_EXAMPLESDIR}
Tests=${INSTALL_TESTSDIR}
Settings=${INSTALL_SYSCONFDIR}
HostPrefix=${host_prefix_relative_to_conf_file}
HostBinaries=${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}
HostLibraries=${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_LIBDIR}
HostLibraryExecutables=${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_LIBEXECDIR}
HostBinaries=${${host_info_var_prefix}_BINDIR}
HostLibraries=${${host_info_var_prefix}_LIBDIR}
HostLibraryExecutables=${${host_info_var_prefix}_LIBEXECDIR}
HostData=${ext_datadir_relative_to_host_prefix}
Sysroot=${sysroot}
SysrootifyPrefix=${sysrootify_prefix}
@ -169,7 +170,7 @@ HostSpec=${QT_QMAKE_HOST_MKSPEC}
set(wrapper_prefix "host-")
endif()
set(host_qt_bindir "${host_prefix}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}")
set(host_qt_bindir "${host_prefix}/${${host_info_var_prefix}_BINDIR}")
file(TO_NATIVE_PATH "${host_qt_bindir}" host_qt_bindir)
if(QT_CREATE_VERSIONED_HARD_LINK AND QT_WILL_INSTALL)

View File

@ -1239,9 +1239,10 @@ function(qt_internal_create_tracepoints name tracepoints_file)
endif()
if(NOT "${QT_HOST_PATH}" STREQUAL "")
qt_internal_get_host_info_var_prefix(host_info_var_prefix)
qt_path_join(tracegen
"${QT_HOST_PATH}"
"${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_LIBEXECDIR}"
"${${host_info_var_prefix}_LIBEXECDIR}"
"tracegen")
else()
set(tracegen "${QT_CMAKE_EXPORT_NAMESPACE}::tracegen")
@ -1276,9 +1277,10 @@ function(qt_internal_generate_tracepoints name provider)
endforeach()
if(NOT "${QT_HOST_PATH}" STREQUAL "")
qt_internal_get_host_info_var_prefix(host_info_var_prefix)
qt_path_join(tracepointgen
"${QT_HOST_PATH}"
"${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_LIBEXECDIR}"
"${${host_info_var_prefix}_LIBEXECDIR}"
"tracepointgen")
else()
set(tracepointgen "${QT_CMAKE_EXPORT_NAMESPACE}::tracepointgen")
@ -1309,9 +1311,10 @@ function(qt_internal_generate_tracepoints name provider)
endif()
if(NOT "${QT_HOST_PATH}" STREQUAL "")
qt_internal_get_host_info_var_prefix(host_info_var_prefix)
qt_path_join(tracegen
"${QT_HOST_PATH}"
"${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_LIBEXECDIR}"
"${${host_info_var_prefix}_LIBEXECDIR}"
"tracegen")
else()
set(tracegen "${QT_CMAKE_EXPORT_NAMESPACE}::tracegen")

View File

@ -961,9 +961,10 @@ if (QT_FEATURE_vulkan)
if(CMAKE_HOST_WIN32)
set(host_executable_suffix ".exe")
endif()
qt_internal_get_host_info_var_prefix(host_info_var_prefix)
qt_path_join(qvkgen
"${QT_HOST_PATH}"
"${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_LIBEXECDIR}"
"${${host_info_var_prefix}_LIBEXECDIR}"
"qvkgen${host_executable_suffix}")
elseif(QT_OPTIONAL_TOOLS_PATH)
qt_path_join(qvkgen